You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2020/03/17 20:03:55 UTC

svn commit: r1875321 - /pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CSSColorTest.java

Author: rwhitcomb
Date: Tue Mar 17 20:03:55 2020
New Revision: 1875321

URL: http://svn.apache.org/viewvc?rev=1875321&view=rev
Log:
Refine the testing in CSSColorTest because of avoidable failures.


Modified:
    pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CSSColorTest.java

Modified: pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CSSColorTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CSSColorTest.java?rev=1875321&r1=1875320&r2=1875321&view=diff
==============================================================================
--- pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CSSColorTest.java (original)
+++ pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CSSColorTest.java Tue Mar 17 20:03:55 2020
@@ -32,6 +32,17 @@ import org.apache.pivot.wtk.util.ColorUt
  * Tests the {@link CSSColor} enum and various {@link ColorUtilities} methods.
  */
 public class CSSColorTest {
+    private void testColors(CSSColor original, CSSColor lookup) {
+        // Doing an exact match here is problematic because many of the
+        // CSS colors have duplicate color values, even synonyms
+        // (vis. DarkGray and DarkGrey), so do some clever checking
+        if (!original.equals(lookup)) {
+            if (!original.getColor().equals(lookup.getColor())) {
+                fail("CSSColor " + original.toString() + " gets wrong color by lookup " + lookup.toString());
+            }
+        }
+    }
+
     @Test
     public void test() {
         // We're going to do a full round-trip cycle to test everything
@@ -42,12 +53,12 @@ public class CSSColorTest {
             assertEquals(css, lookupByName);
 
             CSSColor lookupByColor = CSSColor.fromColor(underlyingColor);
-            assertEquals(css, lookupByColor);
+            testColors(css, lookupByColor);
 
             String stringValue = ColorUtilities.toStringValue(css);
             Color decodedColor = GraphicsUtilities.decodeColor(stringValue, name);
             CSSColor lookupByDecodedValue = CSSColor.fromColor(decodedColor);
-            assertEquals(css, lookupByDecodedValue);
+            testColors(css, lookupByDecodedValue);
 
             String enumName = ((Object)css).toString();
             CSSColor lookupByEnumName = CSSColor.fromString(enumName);