diff options
author | Nick Burch <nick@apache.org> | 2015-07-20 02:49:12 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2015-07-20 02:49:12 +0000 |
commit | 85da2c3069abbf5404f43b31e7d5dc576ec26b53 (patch) | |
tree | b31c1b662743a9dea90b557044ab819faa6fcdb2 /src/testcases | |
parent | 998d12700ac73e8131bae984c3b38c62517e8aa9 (diff) | |
download | poi-85da2c3069abbf5404f43b31e7d5dc576ec26b53.tar.gz poi-85da2c3069abbf5404f43b31e7d5dc576ec26b53.zip |
#58130 Support for creating CF Color Scale Formattings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691866 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java index 191e703898..241a2efcb0 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java @@ -1048,6 +1048,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase { ConditionalFormatting cf = sheetCF.getConditionalFormattingAt(0);
assertEquals(1, cf.getNumberOfRules());
rule1 = cf.getRule(0);
+ assertEquals(ConditionType.ICON_SET, rule1.getConditionTypeType());
iconFmt = rule1.getMultiStateFormatting();
assertEquals(IconSet.GYRB_4_TRAFFIC_LIGHTS, iconFmt.getIconSet());
@@ -1066,8 +1067,49 @@ public abstract class BaseTestConditionalFormatting extends TestCase { }
public void testCreateColorScaleFormatting() {
- // TODO Implement then test
+ Workbook workbook = _testDataProvider.createWorkbook();
+ Sheet sheet = workbook.createSheet();
+
+ SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
+ ConditionalFormattingRule rule1 =
+ sheetCF.createConditionalFormattingColorScaleRule();
+ ColorScaleFormatting clrFmt = rule1.getColorScaleFormatting();
+
+ assertEquals(3, clrFmt.getNumControlPoints());
+ assertEquals(3, clrFmt.getColors().length);
+ assertEquals(3, clrFmt.getThresholds().length);
+
+ clrFmt.getThresholds()[0].setRangeType(RangeType.MIN);
+ clrFmt.getThresholds()[1].setRangeType(RangeType.NUMBER);
+ clrFmt.getThresholds()[1].setValue(10d);
+ clrFmt.getThresholds()[2].setRangeType(RangeType.MAX);
+
+ CellRangeAddress [] regions = { CellRangeAddress.valueOf("A1:A5") };
+ sheetCF.addConditionalFormatting(regions, rule1);
+
+ // Save, re-load and re-check
+ workbook = _testDataProvider.writeOutAndReadBack(workbook);
+ sheetCF = sheet.getSheetConditionalFormatting();
+ assertEquals(1, sheetCF.getNumConditionalFormattings());
+
+ ConditionalFormatting cf = sheetCF.getConditionalFormattingAt(0);
+ assertEquals(1, cf.getNumberOfRules());
+ rule1 = cf.getRule(0);
+ clrFmt = rule1.getColorScaleFormatting();
+ assertEquals(ConditionType.COLOR_SCALE, rule1.getConditionTypeType());
+
+ assertEquals(3, clrFmt.getNumControlPoints());
+ assertEquals(3, clrFmt.getColors().length);
+ assertEquals(3, clrFmt.getThresholds().length);
+
+ assertEquals(RangeType.MIN, clrFmt.getThresholds()[0].getRangeType());
+ assertEquals(RangeType.NUMBER, clrFmt.getThresholds()[1].getRangeType());
+ assertEquals(RangeType.MAX, clrFmt.getThresholds()[2].getRangeType());
+ assertEquals(null, clrFmt.getThresholds()[0].getValue());
+ assertEquals(10d, clrFmt.getThresholds()[1].getValue());
+ assertEquals(null, clrFmt.getThresholds()[2].getValue());
}
+
public void testCreateDataBarFormatting() {
// TODO Implement then test
}
|