aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2014-12-22 09:00:18 +0000
committerDominik Stadler <centic@apache.org>2014-12-22 09:00:18 +0000
commita9f4fb8027b724e90cfa97bb5963aab5597a8020 (patch)
treefa0764d625e6ceb92548708d7024a1f0a5f9be02 /src/testcases/org/apache
parent124cda92e637b3ab014fa93f0ffd557d928cb79c (diff)
downloadpoi-a9f4fb8027b724e90cfa97bb5963aab5597a8020.tar.gz
poi-a9f4fb8027b724e90cfa97bb5963aab5597a8020.zip
Bug 57171 and 57163: Adjust the active sheet in setSheetOrder() and removeSheet() for both HSSF and XSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647264 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
index ce3b78712a..1d1184a88f 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
@@ -192,20 +192,45 @@ public abstract class BaseTestWorkbook {
workbook.createSheet("sheet2");
workbook.createSheet("sheet3");
assertEquals(3, workbook.getNumberOfSheets());
+
+ assertEquals(0, workbook.getActiveSheetIndex());
+
workbook.removeSheetAt(1);
assertEquals(2, workbook.getNumberOfSheets());
assertEquals("sheet3", workbook.getSheetName(1));
+ assertEquals(0, workbook.getActiveSheetIndex());
+
workbook.removeSheetAt(0);
assertEquals(1, workbook.getNumberOfSheets());
assertEquals("sheet3", workbook.getSheetName(0));
+ assertEquals(0, workbook.getActiveSheetIndex());
+
workbook.removeSheetAt(0);
assertEquals(0, workbook.getNumberOfSheets());
+ assertEquals(0, workbook.getActiveSheetIndex());
//re-create the sheets
workbook.createSheet("sheet1");
workbook.createSheet("sheet2");
workbook.createSheet("sheet3");
- assertEquals(3, workbook.getNumberOfSheets());
+ workbook.createSheet("sheet4");
+ assertEquals(4, workbook.getNumberOfSheets());
+
+ assertEquals(0, workbook.getActiveSheetIndex());
+ workbook.setActiveSheet(2);
+ assertEquals(2, workbook.getActiveSheetIndex());
+
+ workbook.removeSheetAt(2);
+ assertEquals(2, workbook.getActiveSheetIndex());
+
+ workbook.removeSheetAt(1);
+ assertEquals(1, workbook.getActiveSheetIndex());
+
+ workbook.removeSheetAt(0);
+ assertEquals(0, workbook.getActiveSheetIndex());
+
+ workbook.removeSheetAt(0);
+ assertEquals(0, workbook.getActiveSheetIndex());
}
@Test
@@ -287,10 +312,17 @@ public abstract class BaseTestWorkbook {
assertEquals(8, wb.getSheetIndex("Sheet 8"));
assertEquals(9, wb.getSheetIndex("Sheet 9"));
+ // check active sheet
+ assertEquals(0, wb.getActiveSheetIndex());
+
// Change
wb.setSheetOrder("Sheet 6", 0);
+ assertEquals(1, wb.getActiveSheetIndex());
wb.setSheetOrder("Sheet 3", 7);
wb.setSheetOrder("Sheet 1", 9);
+
+ // now the first sheet is at index 1
+ assertEquals(1, wb.getActiveSheetIndex());
// Check they're currently right
assertEquals(0, wb.getSheetIndex("Sheet 6"));
@@ -317,6 +349,8 @@ public abstract class BaseTestWorkbook {
assertEquals(8, wbr.getSheetIndex("Sheet 9"));
assertEquals(9, wbr.getSheetIndex("Sheet 1"));
+ assertEquals(1, wb.getActiveSheetIndex());
+
// Now get the index by the sheet, not the name
for(int i=0; i<10; i++) {
Sheet s = wbr.getSheetAt(i);