package com.approximatrix.draco.application.preferences;


import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.Arrays;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

public class EditorPreferencesTest {

	private static final String EXPECTED_FONT_ID = "Monospaced-PLAIN-12";
	
	private EditorPreferences prefs = null;
	
	@Before
	public void setUp() throws Exception {
		prefs = new EditorPreferences();
	}

	@After
	public void tearDown() throws Exception {
		prefs = null;
	}

	@Test
	public void testGetFontName() {
		
		String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
		Arrays.sort(fonts);
		assertTrue("An invalid font was selected as default...",Arrays.binarySearch(fonts, prefs.getFontName()) > 0);
		
		prefs.setFontName("Big");
		assertEquals("Big",prefs.getFontName());
		
	}
	
	@Test
	public void testGetFontSize() {
		prefs.setFontSize(48);
		assertEquals(48,prefs.getFontSize());
	}
	
	@Test
	public void testIsAntiAliasing() {
		prefs.setAntiAliasing(true);
		assertTrue(prefs.isAntiAliasing());
		
		prefs.setAntiAliasing(false);
		assertFalse(prefs.isAntiAliasing());
	}
 
	@Test
	public void testTag() {
		assertEquals("editor",EditorPreferences.TAG);
	}
	
}
