From 40a9294e6ff591765ad0e6923c88fa1a71f3809b Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 19 Jul 2015 02:54:25 +0000 Subject: [PATCH] #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 --- .../BaseTestConditionalFormatting.java | 62 +++++++++++++++---- 1 file 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