[hg] main-silver: Fixed failing SyntaxHighlightingTest.

  • From: Miloslav Metelka < >
  • To: ,
  • Subject: [hg] main-silver: Fixed failing SyntaxHighlightingTest.
  • Date: Fri, 29 Mar 2013 15:43:56 -0700

changeset f99855ecc320 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/f99855ecc320
description:
        Fixed failing SyntaxHighlightingTest.

diffstat:

 
editor.lib2/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlighting.java
               |   5 ++
 
editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlightingTest.java
 |  24 ++-------
 2 files changed, 12 insertions(+), 17 deletions(-)

diffs (118 lines):

diff --git 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlighting.java
 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlighting.java
--- 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlighting.java
+++ 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlighting.java
@@ -652,7 +652,12 @@
             this.listeners = new ListenerList<ChangeListener>();
             Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimePath));
             result = lookup.lookupResult(FontColorSettings.class);
+            // Do not listen on font color settings changes in tests
+            // since "random" lookup events translate into highlight change 
events
+            // that are monitored by tests and so the tests may then fail
+            if (TEST_FALLBACK_COLORING == null) {
             result.addLookupListener(this);
+            }
             updateFCS();
         }
         
diff --git 
a/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlightingTest.java
 
b/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlightingTest.java
--- 
a/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlightingTest.java
+++ 
b/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/highlighting/SyntaxHighlightingTest.java
@@ -79,7 +79,9 @@
         super(name);
         List<String> includes = new ArrayList<String>();
 //        includes.add("testSimple");
+//        includes.add("testNoPrologEpilogEmbedding");
 //        includes.add("testEmbedded");
+//        includes.add("testRanges");
 //        filterTests(includes);
     }
 
@@ -148,7 +150,6 @@
             text,
             TokenHierarchy.create(text, 
TestTokenId.language()).tokenSequence(),
             layer.getHighlights(Integer.MIN_VALUE, Integer.MAX_VALUE),
-            true,
             ""
         );
 
@@ -173,7 +174,8 @@
         assertFalse("There should only be one highlight", hs.moveNext());
 
         hs = layer.getHighlights(5, 11);
-        checkHighlights("Wrong highlights", hs, new Integer [] { 5, 6, 6, 9, 
9, 11 });
+        // Embeddings in "bbb" -> split to single chars by 
SimpleLanguageProvider.findLanguageEmbedding()
+        checkHighlights("Wrong highlights", hs, new Integer [] { 5, 6, 6, 7, 
7, 8, 8, 9, 9, 11 });
     }
 
     public void testEmbeddedRanges() {
@@ -205,7 +207,7 @@
 
         HighlightsSequence hs = layer.getHighlights(Integer.MIN_VALUE, 
Integer.MAX_VALUE);
         TokenHierarchy<?> tokens = TokenHierarchy.create(text, lang);
-        assertHighlights(text, tokens.tokenSequence(), hs, true, "");
+        assertHighlights(text, tokens.tokenSequence(), hs, "");
         assertFalse("Unexpected highlights at the end of the sequence", 
hs.moveNext());
         System.out.println("------------------------\n");
     }
@@ -222,7 +224,7 @@
         }
     }
     
-    private void assertHighlights(String text, TokenSequence<?> ts, 
HighlightsSequence hs, boolean moveHs, String indent) {
+    private void assertHighlights(String text, TokenSequence<?> ts, 
HighlightsSequence hs, String indent) {
         int newlineOffset = Integer.MIN_VALUE;
         while (ts.moveNext()) {
             if (newlineOffset == Integer.MIN_VALUE) { // Init
@@ -276,10 +278,7 @@
                         hiEOffset = Math.min(limitOffset, newlineOffset);
                     }
                     if (hiEOffset > hiSOffset) {
-                        if (moveHs) {
                             assertTrue("Cannot move highlight sequence to 
next highlight", hs.moveNext());
-                        }
-                        moveHs = true;
                         System.out.println(indent + "Highlight: <" + 
hs.getStartOffset() + ", " + hs.getEndOffset() + ">");
                         assertEquals("Wrong starting offset", hiSOffset, 
hs.getStartOffset());
                         assertEquals("Wrong ending offset", hiEOffset, 
hs.getEndOffset());
@@ -320,10 +319,7 @@
                                 hiEOffset = Math.min(limitOffset, 
newlineOffset);
                             }
                             if (hiEOffset > hiSOffset) {
-                                if (moveHs) {
                                     assertTrue("Cannot move highlight 
sequence to next highlight", hs.moveNext());
-                                }
-                                moveHs = true;
                                 System.out.println(indent + "Highlight: <" + 
hs.getStartOffset() + ", " + hs.getEndOffset() + ">");
                                 assertEquals("Wrong starting offset", 
hiSOffset, hs.getStartOffset());
                                 assertEquals("Wrong ending offset", 
hiEOffset, hs.getEndOffset());
@@ -332,7 +328,7 @@
                         // XXX: compare attributes as well
                     }
                     
-                    assertHighlights(text, ts.embedded(), hs, prologueLength 
> 0, indent + "  ");
+                    assertHighlights(text, ts.embedded(), hs, indent + "  ");
                     hiEOffset = tokenEndOffset - epilogLength;
                     if (epilogLength > 0) {
                         int limitOffset = tokenEndOffset;
@@ -363,10 +359,7 @@
                                 hiEOffset = Math.min(limitOffset, 
newlineOffset);
                             }
                             if (hiEOffset > hiSOffset) {
-                                if (moveHs) {
                                     assertTrue("Cannot move highlight 
sequence to next highlight", hs.moveNext());
-                                }
-                                moveHs = true;
                                 System.out.println(indent + "Highlight: <" + 
hs.getStartOffset() + ", " + hs.getEndOffset() + ">");
                                 assertEquals("Wrong starting offset", 
hiSOffset, hs.getStartOffset());
                                 assertEquals("Wrong ending offset", 
hiEOffset, hs.getEndOffset());
@@ -403,10 +396,7 @@
                             hiEOffset = Math.min(limitOffset, newlineOffset);
                         }
                         if (hiEOffset > hiSOffset) {
-                            if (moveHs) {
                                 assertTrue("Cannot move highlight sequence 
to next highlight", hs.moveNext());
-                            }
-                            moveHs = true;
                             System.out.println(indent + "Highlight: <" + 
hs.getStartOffset() + ", " + hs.getEndOffset() + ">");
                             assertEquals("Wrong starting offset", hiSOffset, 
hs.getStartOffset());
                             assertEquals("Wrong ending offset", hiEOffset, 
hs.getEndOffset());

[hg] main-silver: Fixed failing SyntaxHighlightingTest.

Miloslav Metelka 03/29/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close