mirror of
https://github.com/apache/poi.git
synced 2025-02-08 02:58:18 +00:00
#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
This commit is contained in:
parent
c82aaba62c
commit
40a9294e6f
@ -559,7 +559,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
|
|||||||
SheetConditionalFormatting sheetCF = s.getSheetConditionalFormatting();
|
SheetConditionalFormatting sheetCF = s.getSheetConditionalFormatting();
|
||||||
int numCF = 3;
|
int numCF = 3;
|
||||||
int numCF12 = 15;
|
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());
|
assertEquals(numCF+numCF12+numCFEX, sheetCF.getNumConditionalFormattings());
|
||||||
|
|
||||||
int fCF = 0, fCF12 = 0, fCFEX = 0;
|
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
|
// 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);
|
cf = sheetCF.getConditionalFormattingAt(3);
|
||||||
assertEquals(1, cf.getFormattingRanges().length);
|
assertEquals(1, cf.getFormattingRanges().length);
|
||||||
assertEquals("F2:F17", cf.getFormattingRanges()[0].formatAsString());
|
assertEquals("F2:F17", cf.getFormattingRanges()[0].formatAsString());
|
||||||
|
assertColorScale(cf, "F8696B", "FFEB84", "63BE7B");
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
// Colours BWR - Column G
|
// Colours Blue->White->Red - Column G
|
||||||
cf = sheetCF.getConditionalFormattingAt(4);
|
cf = sheetCF.getConditionalFormattingAt(4);
|
||||||
assertEquals(1, cf.getFormattingRanges().length);
|
assertEquals(1, cf.getFormattingRanges().length);
|
||||||
assertEquals("G2:G17", cf.getFormattingRanges()[0].formatAsString());
|
assertEquals("G2:G17", cf.getFormattingRanges()[0].formatAsString());
|
||||||
|
assertColorScale(cf, "5A8AC6", "FCFCFF", "F8696B");
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
// Icons : Default - Column H, percentage thresholds
|
// Icons : Default - Column H, percentage thresholds
|
||||||
@ -809,6 +801,50 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public void testCreateFontFormatting() {
|
||||||
Workbook workbook = _testDataProvider.createWorkbook();
|
Workbook workbook = _testDataProvider.createWorkbook();
|
||||||
Sheet sheet = workbook.createSheet();
|
Sheet sheet = workbook.createSheet();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user