IDEA-152156 Test

This commit is contained in:
Rustam Vishnyakov
2016-03-01 16:43:16 +03:00
parent 2145921fb1
commit c450fedc6f
@@ -20,6 +20,7 @@ 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.TextAttributesKey;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.WriteExternalException;
@@ -290,6 +291,37 @@ public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase
}
}
@SuppressWarnings("unused")
public void _testIdea152156() throws Exception {
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
EditorColorsScheme parentScheme = (EditorColorsScheme)defaultScheme.clone();
parentScheme.setName("DefaultTest");
EditorColorsScheme editorColorsScheme = new EditorColorsSchemeImpl(parentScheme);
editorColorsScheme.setName("test");
TextAttributes defaultAttributes = new TextAttributes(null, null, Color.BLACK, EffectType.LINE_UNDERSCORE, Font.PLAIN);
TextAttributes attributes = new TextAttributes(null, null, null, EffectType.BOXED, Font.PLAIN);
attributes.setEnforceEmpty(false);
assertTrue(attributes.isFallbackEnabled());
TextAttributesKey testKey = TextAttributesKey.createTextAttributesKey("TEST_KEY", DefaultLanguageHighlighterColors.PARAMETER);
parentScheme.setAttributes(testKey, defaultAttributes);
editorColorsScheme.setAttributes(testKey, attributes);
try {
Element root = new Element("scheme");
((AbstractColorsScheme)editorColorsScheme).writeExternal(root);
EditorColorsScheme targetScheme = new EditorColorsSchemeImpl(parentScheme);
for (final Element child : root.getChildren()) {
if ("attributes".equals(child.getName())) {
((EditorColorsSchemeImpl)targetScheme).readAttributes(child);
}
}
TextAttributes targetAttributes = ((AbstractColorsScheme)targetScheme).getDirectlyDefinedAttributes(testKey);
assertTrue(targetAttributes != null && targetAttributes.isFallbackEnabled());
}
finally {
TextAttributesKey.removeTextAttributesKey(testKey.getExternalName());
}
}
private static EditorColorsScheme loadScheme(@NotNull String docText) throws ParserConfigurationException, IOException, SAXException {