1 19 20 package org.netbeans.modules.xml.xam.ui.highlight; 21 22 import java.util.Collections ; 23 import java.util.List ; 24 import java.util.Set ; 25 import junit.framework.Test; 26 import junit.framework.TestCase; 27 import junit.framework.TestSuite; 28 import org.netbeans.modules.xml.schema.model.Schema; 29 import org.netbeans.modules.xml.schema.model.SchemaModel; 30 import org.netbeans.modules.xml.xam.Component; 31 import org.netbeans.modules.xml.xam.ui.Util; 32 33 38 public class DefaultHighlightManagerTest extends TestCase { 39 private Schema schema; 40 private SchemaModel model; 41 42 public DefaultHighlightManagerTest(String testName) { 43 super(testName); 44 } 45 46 @Override 47 protected void setUp() throws Exception { 48 model = Util.loadSchemaModel(Util.PO_XSD); 49 schema = model.getSchema(); 50 } 51 52 @Override 53 protected void tearDown() throws Exception { 54 } 55 56 59 public void testHighlightGroups() { 60 DefaultHighlightManager instance = new DefaultHighlightManager(); 61 HighlightGroup group = new HighlightGroup("type"); 62 group.addHighlight(new TestHighlight(schema, "a")); 63 group.addHighlight(new TestHighlight(schema, "b")); 64 group.addHighlight(new TestHighlight(schema, "c")); 65 instance.addHighlightGroup(group); 66 List <HighlightGroup> groups = instance.getHighlightGroups("type"); 67 assertTrue(groups.contains(group)); 68 assertEquals(1, groups.size()); 69 instance.removeHighlightGroup(group); 70 groups = instance.getHighlightGroups("type"); 71 assertFalse(groups.contains(group)); 72 assertEquals(0, groups.size()); 73 } 74 75 78 public void testHighlightListeners() { 79 DefaultHighlightManager instance = new DefaultHighlightManager(); 80 TestLighter l1 = new TestLighter(); 81 instance.addHighlighted(l1); 82 TestLighter l2 = new TestLighter(); 83 instance.addHighlighted(l2); 84 instance.removeHighlighted(l1); 85 instance.removeHighlighted(l2); 86 } 87 88 private static class TestLighter implements Highlighted { 89 90 public Set <Component> getComponents() { 91 return Collections.emptySet(); 92 } 93 94 public void highlightAdded(Highlight hl) { 95 } 96 97 public void highlightRemoved(Highlight hl) { 98 } 99 } 100 } 101 | Popular Tags |