Get theme and non-theme rows consistent in the test file

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1694889 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2015-08-09 13:30:35 +00:00
parent 4fefb2bcc9
commit a7bb2f21d5
3 changed files with 17 additions and 20 deletions

View File

@ -150,7 +150,6 @@ public class TestThemesTable {
* Column C = Explicit Colour Foreground * Column C = Explicit Colour Foreground
* Column E = Explicit Colour Background, Black Foreground * Column E = Explicit Colour Background, Black Foreground
* Column G = Conditional Formatting Backgrounds * Column G = Conditional Formatting Backgrounds
* (Row 4 = White by Lt2)
*/ */
@Test @Test
public void themedAndNonThemedColours() { public void themedAndNonThemedColours() {
@ -158,26 +157,23 @@ public class TestThemesTable {
XSSFSheet sheet = wb.getSheetAt(0); XSSFSheet sheet = wb.getSheetAt(0);
XSSFCellStyle style; XSSFCellStyle style;
XSSFColor color; XSSFColor color;
XSSFCell cell;
String[] names = {"Black","White","Grey","Blue","Red","Green"}; String[] names = {"White","Black","Grey","Dark Blue","Blue","Red","Green"};
int[] themes = {1,0,2,3,4,5}; assertEquals(7, names.length);
assertEquals(names.length, themes.length);
// Check the non-CF colours in Columns A, B, C and E // Check the non-CF colours in Columns A, B, C and E
for (int rn=2; rn<8; rn++) { for (int rn=1; rn<8; rn++) {
int idx = rn-2; int idx = rn-1;
XSSFRow row = sheet.getRow(rn); XSSFRow row = sheet.getRow(rn);
assertNotNull("Missing row " + rn, row); assertNotNull("Missing row " + rn, row);
// Theme cells aren't quite in the same order... // Theme cells come first
XSSFCell themeCell = row.getCell(0); XSSFCell themeCell = row.getCell(0);
if (idx == 1) themeCell = sheet.getRow(idx).getCell(0); ThemeElement themeElem = ThemeElement.byId(idx);
if (idx >= 2) themeCell = sheet.getRow(idx+1).getCell(0); assertCellContents(themeElem.name, themeCell);
// Sanity check names // Sanity check names
int themeIdx = themes[idx];
ThemeElement themeElem = ThemeElement.byId(themeIdx);
assertCellContents(themeElem.name, themeCell);
assertCellContents(names[idx], row.getCell(1)); assertCellContents(names[idx], row.getCell(1));
assertCellContents(names[idx], row.getCell(2)); assertCellContents(names[idx], row.getCell(2));
assertCellContents(names[idx], row.getCell(4)); assertCellContents(names[idx], row.getCell(4));
@ -187,16 +183,17 @@ public class TestThemesTable {
style = themeCell.getCellStyle(); style = themeCell.getCellStyle();
color = style.getFont().getXSSFColor(); color = style.getFont().getXSSFColor();
assertEquals(true, color.isThemed()); assertEquals(true, color.isThemed());
assertEquals(themeIdx, color.getTheme()); assertEquals(idx, color.getTheme());
assertEquals(rgbExpected[themeIdx], Hex.encodeHexString(color.getRGB())); assertEquals(rgbExpected[idx], Hex.encodeHexString(color.getRGB()));
// B: Theme Based, Foreground // B: Theme Based, Foreground
style = row.getCell(1).getCellStyle(); cell = row.getCell(1);
style = cell.getCellStyle();
color = style.getFont().getXSSFColor(); color = style.getFont().getXSSFColor();
// TODO Fix this! assertEquals(true, color.isThemed());
if (idx < 2) { // TODO Fix the grey theme color in Column B
assertEquals(true, color.isThemed()); if (idx != 2) {
assertEquals(themeIdx, color.getTheme()); assertEquals(idx, color.getTheme());
assertEquals(rgbExpected[themeIdx], Hex.encodeHexString(color.getRGB())); assertEquals(rgbExpected[idx], Hex.encodeHexString(color.getRGB()));
} }
} }

Binary file not shown.

Binary file not shown.