]> source.dussan.org Git - poi.git/commitdiff
Get theme and non-theme rows consistent in the test file
authorNick Burch <nick@apache.org>
Sun, 9 Aug 2015 13:30:35 +0000 (13:30 +0000)
committerNick Burch <nick@apache.org>
Sun, 9 Aug 2015 13:30:35 +0000 (13:30 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1694889 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/model/TestThemesTable.java
test-data/spreadsheet/Themes2.xls
test-data/spreadsheet/Themes2.xlsx

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