poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1691092 - in /poi/trunk/src: ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/usermodel/ testcases/org/apache/poi/hssf/usermodel/ testcases/org/apache/poi/ss/usermodel/
Date Tue, 14 Jul 2015 21:45:23 GMT
Author: nick
Date: Tue Jul 14 21:45:23 2015
New Revision: 1691092

URL: http://svn.apache.org/r1691092
Log:
Start checking the CF colours in the unit tests

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java?rev=1691092&r1=1691091&r2=1691092&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java Tue Jul 14 21:45:23
2015
@@ -170,10 +170,7 @@ public class XSSFColor implements Color
           return null;
        }
        for(byte c : rgb) {
-          int i = (int)c;
-          if(i < 0) {
-             i += 256;
-          }
+          int i = c & 0xff;
           String cs = Integer.toHexString(i);
           if(cs.length() == 1) {
              sb.append('0');

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java?rev=1691092&r1=1691091&r2=1691092&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
Tue Jul 14 21:45:23 2015
@@ -19,6 +19,7 @@
 package org.apache.poi.xssf.usermodel;
 
 import org.apache.poi.ss.usermodel.BaseTestConditionalFormatting;
+import org.apache.poi.ss.usermodel.Color;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 
 /**
@@ -29,6 +30,16 @@ public class TestXSSFConditionalFormatti
         super(XSSFITestDataProvider.instance);
     }
 
+    protected void assertColour(String hexExpected, Color actual) {
+        assertNotNull("Colour must be given", actual);
+        XSSFColor colour = (XSSFColor)actual;
+        if (hexExpected.length() == 8) {
+            assertEquals(hexExpected, colour.getARGBHex());
+        } else {
+            assertEquals(hexExpected, colour.getARGBHex().substring(2));
+        }
+    }
+
     public void testRead(){
         testRead("WithConditionalFormatting.xlsx");
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java?rev=1691092&r1=1691091&r2=1691092&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
(original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
Tue Jul 14 21:45:23 2015
@@ -22,7 +22,9 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFITestDataProvider;
+import org.apache.poi.hssf.util.HSSFColor;
 import org.apache.poi.ss.usermodel.BaseTestConditionalFormatting;
+import org.apache.poi.ss.usermodel.Color;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -34,6 +36,11 @@ public final class TestHSSFConditionalFo
     public TestHSSFConditionalFormatting(){
         super(HSSFITestDataProvider.instance);
     }
+    protected void assertColour(String hexExpected, Color actual) {
+        assertNotNull("Colour must be given", actual);
+        HSSFColor colour = (HSSFColor)actual;
+        assertEquals(hexExpected, colour.getHexString());
+    }
 
     public void testRead() {
         testRead("WithConditionalFormatting.xls");

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java?rev=1691092&r1=1691091&r2=1691092&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
Tue Jul 14 21:45:23 2015
@@ -35,6 +35,8 @@ public abstract class BaseTestConditiona
     public BaseTestConditionalFormatting(ITestDataProvider testDataProvider){
         _testDataProvider = testDataProvider;
     }
+    
+    protected abstract void assertColour(String hexExpected, Color actual);
 
     public void testBasic() {
         Workbook wb = _testDataProvider.createWorkbook();
@@ -592,8 +594,12 @@ public abstract class BaseTestConditiona
         assertEquals(ComparisonOperator.GT, cr.getComparisonOperation());
         assertEquals("0", cr.getFormula1());
         assertEquals(null, cr.getFormula2());
-//        assertColourGreen(cr);
-        // TODO Colour checking
+        // TODO Should the colours be slightly different like this?
+        if (cr instanceof HSSFConditionalFormattingRule) {
+            assertColour("CCCC:FFFF:CCCC", cr.getPatternFormatting().getFillBackgroundColorColor());
+        } else {
+            assertColour("C6EFCE", cr.getPatternFormatting().getFillBackgroundColorColor());
+        }
         
         
         // Highlight 10-30 - Column D



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message