Reuse utility methods from FontPreferencesTest

and use only actually available fonts in tests to prevent a fallback to
default font.
This commit is contained in:
Rustam Vishnyakov
2017-08-07 17:31:39 +03:00
parent 4979a2bf90
commit be84707cb1
2 changed files with 9 additions and 13 deletions
@@ -432,10 +432,8 @@ public class EditorColorsSchemeImplTest extends EditorColorSchemeTestCase {
}
public void testReadFontPreferences() throws Exception {
String[] fontFamilyNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
if (fontFamilyNames.length < 2) return;
String name1 = fontFamilyNames[0];
String name2 = fontFamilyNames[1];
String name1 = getExistingNonDefaultFontName();
String name2 = getAnotherExistingNonDefaultFontName();
EditorColorsScheme scheme = loadScheme(
"<scheme name=\"fira\" version=\"142\" parent_scheme=\"Default\">\n" +
" <option name=\"LINE_SPACING\" value=\"0.93\" />\n" +
@@ -459,9 +457,7 @@ public class EditorColorsSchemeImplTest extends EditorColorSchemeTestCase {
}
public void testReadFontPreferencesIdea176762() throws Exception {
String[] fontFamilyNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
if (fontFamilyNames.length == 0) return;
String fontName = fontFamilyNames[0];
String fontName = getExistingNonDefaultFontName();
EditorColorsScheme scheme = loadScheme(
"<scheme name=\"_@user_Default\" version=\"142\" parent_scheme=\"Default\">\n" +
" <option name=\"FONT_SCALE\" value=\"1.5\" />\n" +
@@ -15,10 +15,7 @@
*/
package com.intellij.openapi.editor.impl;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.FontPreferences;
import com.intellij.openapi.editor.colors.ModifiableFontPreferences;
import com.intellij.openapi.editor.colors.*;
import com.intellij.openapi.editor.colors.impl.AppEditorFontOptions;
import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl;
import com.intellij.openapi.editor.colors.impl.FontPreferencesImpl;
@@ -26,6 +23,8 @@ import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.testFramework.TestFileType;
import org.jetbrains.annotations.NotNull;
import static com.intellij.openapi.editor.colors.FontPreferencesTest.getExistingNonDefaultFontName;
public class EditorColorsSchemeDelegateTest extends AbstractEditorTest {
private EditorColorsScheme mySavedScheme;
private EditorColorsScheme myTestScheme;
@@ -54,6 +53,7 @@ public class EditorColorsSchemeDelegateTest extends AbstractEditorTest {
}
public void testSecondaryFontIsAvailable() throws Exception {
String secondaryFont = getExistingNonDefaultFontName();
FontPreferences globalPrefs = AppEditorFontOptions.getInstance().getFontPreferences();
FontPreferences tempCopy = new FontPreferencesImpl();
globalPrefs.copyTo(tempCopy);
@@ -61,7 +61,7 @@ public class EditorColorsSchemeDelegateTest extends AbstractEditorTest {
init("blah", TestFileType.TEXT);
assertInstanceOf(globalPrefs, ModifiableFontPreferences.class);
((ModifiableFontPreferences)globalPrefs).register("DummyFont", globalPrefs.getSize(globalPrefs.getFontFamily()));
((ModifiableFontPreferences)globalPrefs).register(secondaryFont, globalPrefs.getSize(globalPrefs.getFontFamily()));
LOG.debug(dumpFontPreferences("globalPrefs", globalPrefs));
assertEquals(2, globalPrefs.getRealFontFamilies().size());
((EditorEx)myEditor).reinitSettings();
@@ -69,7 +69,7 @@ public class EditorColorsSchemeDelegateTest extends AbstractEditorTest {
FontPreferences editorPrefs = myEditor.getColorsScheme().getFontPreferences();
LOG.debug(dumpFontPreferences("editorPrefs", editorPrefs));
assertEquals(2, editorPrefs.getRealFontFamilies().size());
assertEquals("DummyFont", editorPrefs.getRealFontFamilies().get(1));
assertEquals(secondaryFont, editorPrefs.getRealFontFamilies().get(1));
}
finally {
tempCopy.copyTo(globalPrefs);