aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-07-19 00:08:26 +0000
committerNick Burch <nick@apache.org>2015-07-19 00:08:26 +0000
commit7ca07949a779ee174c67b33878995361738a31b9 (patch)
tree056eb72d014be4a971fa6ec1cdc650fa17ce7816 /src/testcases
parenta27b7d5b2c80b11bc9d0c49170c684f0201b16fe (diff)
downloadpoi-7ca07949a779ee174c67b33878995361738a31b9.tar.gz
poi-7ca07949a779ee174c67b33878995361738a31b9.zip
#58130 More CF Icon unit tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691787 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java91
1 files changed, 83 insertions, 8 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
index b8eeb2053d..1204355fae 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
@@ -101,6 +101,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
/**
* Test format conditions based on a boolean formula
*/
+ @SuppressWarnings("deprecation")
public void testBooleanFormulaConditions() {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sh = wb.createSheet();
@@ -136,6 +137,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals("B1:B3", ranges2[0].formatAsString());
}
+ @SuppressWarnings("deprecation")
public void testSingleFormulaConditions() {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sh = wb.createSheet();
@@ -207,6 +209,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(ComparisonOperator.NOT_BETWEEN, rule9.getComparisonOperation());
}
+ @SuppressWarnings("deprecation")
public void testCopy() {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet1 = wb.createSheet();
@@ -546,8 +549,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
Sheet s = wb.getSheet("CF");
ConditionalFormatting cf = null;
ConditionalFormattingRule cr = null;
- IconMultiStateFormatting icon = null;
- ConditionalFormattingThreshold th = null;
+
// Sanity check data
assertEquals("Values", s.getRow(0).getCell(0).toString());
@@ -696,22 +698,95 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertIconSetPercentages(cf, IconSet.GYRB_4_TRAFFIC_LIGHTS, 0d, 25d, 50d, 75d);
- // Icons : 3 symbols - Column L
- // Icons : 3 flags - Column M
- // Icons : 3 symbols 2 - Column N
- // Icons : 3 arrows - Column O
+ // Icons : 3 symbols with backgrounds - Column L
+ cf = sheetCF.getConditionalFormattingAt(9);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("L2:L17", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.GYR_3_SYMBOLS_CIRCLE, 0d, 33d, 67d);
+
+
+ // Icons : 3 flags - Column M2 Only
+ cf = sheetCF.getConditionalFormattingAt(10);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("M2", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.GYR_3_FLAGS, 0d, 33d, 67d);
+
+ // Icons : 3 flags - Column M (all)
+ cf = sheetCF.getConditionalFormattingAt(11);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("M2:M17", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.GYR_3_FLAGS, 0d, 33d, 67d);
+
+
+ // Icons : 3 symbols 2 (no background) - Column N
+ cf = sheetCF.getConditionalFormattingAt(12);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("N2:N17", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.GYR_3_SYMBOLS, 0d, 33d, 67d);
+
+
+ // Icons : 3 arrows - Column O
+ cf = sheetCF.getConditionalFormattingAt(13);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("O2:O17", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.GYR_3_ARROW, 0d, 33d, 67d);
+
+
// Icons : 5 arrows grey - Column P
+ cf = sheetCF.getConditionalFormattingAt(14);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("P2:P17", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.GREY_5_ARROWS, 0d, 20d, 40d, 60d, 80d);
+
+
// Icons : 3 stars (ext) - Column Q
+ // TODO Support EXT formattings
+
+
// Icons : 4 ratings - Column R
+ cf = sheetCF.getConditionalFormattingAt(15);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("R2:R17", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.RATINGS_4, 0d, 25d, 50d, 75d);
+
+
// Icons : 5 ratings - Column S
+ cf = sheetCF.getConditionalFormattingAt(16);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("S2:S17", cf.getFormattingRanges()[0].formatAsString());
+ assertIconSetPercentages(cf, IconSet.RATINGS_5, 0d, 20d, 40d, 60d, 80d);
+
+
// Custom Icon+Format - Column T
+ cf = sheetCF.getConditionalFormattingAt(17);
+ assertEquals(1, cf.getFormattingRanges().length);
+ assertEquals("T2:T17", cf.getFormattingRanges()[0].formatAsString());
+
+ // TODO Support IconSet + Other CFs with 2 rules
+// assertEquals(2, cf.getNumberOfRules());
+// cr = cf.getRule(0);
+// assertIconSetPercentages(cr, IconSet.GYR_3_TRAFFIC_LIGHTS_BOX, 0d, 33d, 67d);
+// cr = cf.getRule(1);
+// assertEquals(ConditionType.FORMULA, cr.getConditionTypeType());
+// assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
+// // TODO Why aren't these two the same between formats?
+// if (cr instanceof HSSFConditionalFormattingRule) {
+// assertEquals("MOD(ROW($T1),2)=1", cr.getFormula1());
+// } else {
+// assertEquals("MOD(ROW($T2),2)=1", cr.getFormula1());
+// }
+// assertEquals(null, cr.getFormula2());
+
+
// Mixed icons - Column U
-
+ // TODO Support EXT formattings
}
private void assertIconSetPercentages(ConditionalFormatting cf, IconSet iconset, Double...vals) {
assertEquals(1, cf.getNumberOfRules());
ConditionalFormattingRule cr = cf.getRule(0);
-
+ assertIconSetPercentages(cr, iconset, vals);
+ }
+ private void assertIconSetPercentages(ConditionalFormattingRule cr, IconSet iconset, Double...vals) {
assertEquals(ConditionType.ICON_SET, cr.getConditionTypeType());
assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
assertEquals(null, cr.getFormula1());