diff options
author | Nick Burch <nick@apache.org> | 2015-07-19 02:54:25 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2015-07-19 02:54:25 +0000 |
commit | 40a9294e6ff591765ad0e6923c88fa1a71f3809b (patch) | |
tree | 4264d0675ac0189faebd6b5b8b4ad2317236938c /src/testcases/org/apache/poi | |
parent | c82aaba62cb530f1a1329204294267892e54e7cc (diff) | |
download | poi-40a9294e6ff591765ad0e6923c88fa1a71f3809b.tar.gz poi-40a9294e6ff591765ad0e6923c88fa1a71f3809b.zip |
#58130 Stub the CF Color Scale unit tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691789 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi')
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java index 602c334958..1a130b7510 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java @@ -559,7 +559,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase { SheetConditionalFormatting sheetCF = s.getSheetConditionalFormatting();
int numCF = 3;
int numCF12 = 15;
- int numCFEX = 0; // TODO This should be 2, but we don't support CFEX formattings yet
+ int numCFEX = 0; // TODO This should be 2, but we don't support CFEX formattings yet, see #58149
assertEquals(numCF+numCF12+numCFEX, sheetCF.getNumConditionalFormattings());
int fCF = 0, fCF12 = 0, fCFEX = 0;
@@ -648,26 +648,18 @@ public abstract class BaseTestConditionalFormatting extends TestCase { // TODO Support Data Bars, then check the rest of this rule
- // Colours R->G - Column F
+ // Colours Red->Yellow->Green - Column F
cf = sheetCF.getConditionalFormattingAt(3);
assertEquals(1, cf.getFormattingRanges().length);
assertEquals("F2:F17", cf.getFormattingRanges()[0].formatAsString());
-
- assertEquals(1, cf.getNumberOfRules());
- cr = cf.getRule(0);
- assertEquals(ConditionType.COLOR_SCALE, cr.getConditionTypeType());
- // TODO Support Color Scales, then check the rest of this rule
+ assertColorScale(cf, "F8696B", "FFEB84", "63BE7B");
- // Colours BWR - Column G
+ // Colours Blue->White->Red - Column G
cf = sheetCF.getConditionalFormattingAt(4);
assertEquals(1, cf.getFormattingRanges().length);
assertEquals("G2:G17", cf.getFormattingRanges()[0].formatAsString());
-
- assertEquals(1, cf.getNumberOfRules());
- cr = cf.getRule(0);
- assertEquals(ConditionType.COLOR_SCALE, cr.getConditionTypeType());
- // TODO Support Color Scales, then check the rest of this rule
+ assertColorScale(cf, "5A8AC6", "FCFCFF", "F8696B");
// Icons : Default - Column H, percentage thresholds
@@ -808,6 +800,50 @@ public abstract class BaseTestConditionalFormatting extends TestCase { assertEquals(null, th.getFormula());
}
}
+
+ private void assertColorScale(ConditionalFormatting cf, String... colors) {
+ assertEquals(1, cf.getNumberOfRules());
+ ConditionalFormattingRule cr = cf.getRule(0);
+ assertColorScale(cr, colors);
+ }
+ private void assertColorScale(ConditionalFormattingRule cr, String... colors) {
+ assertEquals(ConditionType.COLOR_SCALE, cr.getConditionTypeType());
+ assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
+ assertEquals(null, cr.getFormula1());
+ assertEquals(null, cr.getFormula2());
+
+ // TODO Implement
+/*
+ ColorScaleFormatting color = cr.getColorScaleFormatting();
+ assertNotNull(color);
+ assertNotNull(color.getColors());
+ assertNotNull(color.getThresholds());
+ assertEquals(colors.length, color.getNumControlPoints());
+ assertEquals(colors.length, color.getColors().length);
+ assertEquals(colors.length, color.getThresholds().length);
+
+ // Thresholds should be Min / (evenly spaced) / Max
+ int steps = 100 / (colors.length-1);
+ for (int i=0; i<colors.length; i++) {
+ ConditionalFormattingThreshold th = color.getThresholds()[i];
+ if (i == 0) {
+ assertEquals(RangeType.MIN, th.getRangeType());
+ } else if (i == colors.length-1) {
+ assertEquals(RangeType.MAX, th.getRangeType());
+ } else {
+ assertEquals(RangeType.PERCENT, th.getRangeType());
+ assertEquals(steps*i, th.getValue());
+ }
+ assertEquals(null, th.getFormula());
+ }
+
+ // Colors should match
+ for (int i=0; i<colors.length; i++) {
+ Color c = color.getColors()[i];
+ assertEquals(colors[i], c.toString());
+ }
+*/
+ }
public void testCreateFontFormatting() {
Workbook workbook = _testDataProvider.createWorkbook();
|