mirror of https://github.com/apache/poi.git
Start checking the CF colours in the unit tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691092 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b2d6118eeb
commit
1596a62368
|
@ -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');
|
||||
|
|
|
@ -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 TestXSSFConditionalFormatting extends BaseTestConditionalFormatting
|
|||
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");
|
||||
}
|
||||
|
|
|
@ -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 TestHSSFConditionalFormatting extends BaseTestConditionalForm
|
|||
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");
|
||||
|
|
|
@ -35,6 +35,8 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
|
|||
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 BaseTestConditionalFormatting extends TestCase {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue