129cdfe15SLiu Zhe /**************************************************************
229cdfe15SLiu Zhe  *
329cdfe15SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
429cdfe15SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
529cdfe15SLiu Zhe  * distributed with this work for additional information
629cdfe15SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
729cdfe15SLiu Zhe  * to you under the Apache License, Version 2.0 (the
829cdfe15SLiu Zhe  * "License"); you may not use this file except in compliance
929cdfe15SLiu Zhe  * with the License.  You may obtain a copy of the License at
1029cdfe15SLiu Zhe  *
1129cdfe15SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1229cdfe15SLiu Zhe  *
1329cdfe15SLiu Zhe  * Unless required by applicable law or agreed to in writing,
1429cdfe15SLiu Zhe  * software distributed under the License is distributed on an
1529cdfe15SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1629cdfe15SLiu Zhe  * KIND, either express or implied.  See the License for the
1729cdfe15SLiu Zhe  * specific language governing permissions and limitations
1829cdfe15SLiu Zhe  * under the License.
1929cdfe15SLiu Zhe  *
2029cdfe15SLiu Zhe  *************************************************************/
2129cdfe15SLiu Zhe 
2229cdfe15SLiu Zhe /**
2329cdfe15SLiu Zhe  *
2429cdfe15SLiu Zhe  */
25*80a6f5c5SLiu Zhe package fvt.gui.sc.subtotals;
2629cdfe15SLiu Zhe 
2729cdfe15SLiu Zhe import static org.junit.Assert.*;
2895269d92SLiu Zhe import static org.openoffice.test.common.Testspace.*;
2922a14f28SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
30b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
3195269d92SLiu Zhe import static testlib.gui.UIMap.*;
3229cdfe15SLiu Zhe 
3329cdfe15SLiu Zhe import org.junit.After;
3429cdfe15SLiu Zhe import org.junit.Before;
3529cdfe15SLiu Zhe import org.junit.Rule;
3629cdfe15SLiu Zhe import org.junit.Test;
3722a14f28SLiu Zhe import org.openoffice.test.common.Logger;
3829cdfe15SLiu Zhe 
39b4d2d410SLiu Zhe import testlib.gui.SCTool;
4029cdfe15SLiu Zhe 
4129cdfe15SLiu Zhe /**
4229cdfe15SLiu Zhe  *
4329cdfe15SLiu Zhe  *
4429cdfe15SLiu Zhe  */
4529cdfe15SLiu Zhe public class SubtotalsFunctions {
4629cdfe15SLiu Zhe 
4729cdfe15SLiu Zhe 	@Rule
4822a14f28SLiu Zhe 	public Logger log = Logger.getLogger(this);
4929cdfe15SLiu Zhe 
5029cdfe15SLiu Zhe 	@Before
5129cdfe15SLiu Zhe 	public void setUp() throws Exception {
524d3496b1SLiu Zhe 		app.start(true);
5395269d92SLiu Zhe 		String file = prepareData("sc/SubtotalsSampleFile.ods");
543816404dSLiu Zhe 		app.dispatch(".uno:Open");
5529cdfe15SLiu Zhe 		submitOpenDlg(file);
56d8cae8adSLiu Zhe 		calc.waitForExistence(10, 2);
57b4d2d410SLiu Zhe 		SCTool.selectRange("A1:E7");
583816404dSLiu Zhe 		app.dispatch(".uno:DataSubTotals");
5929cdfe15SLiu Zhe 	}
6029cdfe15SLiu Zhe 
6129cdfe15SLiu Zhe 	@After
6229cdfe15SLiu Zhe 	public void tearDown() throws Exception {
6322a14f28SLiu Zhe 
6429cdfe15SLiu Zhe 	}
6529cdfe15SLiu Zhe 
6629cdfe15SLiu Zhe 	/**
6722a14f28SLiu Zhe 	 * Just support en-US language Verify Average function in SubTotals
6829cdfe15SLiu Zhe 	 */
6929cdfe15SLiu Zhe 	@Test
7029cdfe15SLiu Zhe 	public void testAverage() {
71b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
7222a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25); // In different platform, can
7322a14f28SLiu Zhe 		// not focus on same checkbox
74b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
75b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
764d3496b1SLiu Zhe 		sleep(1);
77b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
78b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
7929cdfe15SLiu Zhe 		sleep(1);
8029cdfe15SLiu Zhe 
8122a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
8222a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "20", "", "A Average", "" }, { "BS", "20", "4", "B", "Elle" }, { "MS", "10", "3", "B", "Kevin" },
8322a14f28SLiu Zhe 				{ "", "15", "", "B Average", "" }, { "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Average", "" }, { "", "18.33333333", "", "Grand Total", "" } },
84b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
8529cdfe15SLiu Zhe 	}
8629cdfe15SLiu Zhe 
8729cdfe15SLiu Zhe 	/**
8822a14f28SLiu Zhe 	 * Just support en-US language Verify Count Numbers only function in
8922a14f28SLiu Zhe 	 * SubTotals
9029cdfe15SLiu Zhe 	 */
9129cdfe15SLiu Zhe 	@Test
9229cdfe15SLiu Zhe 	public void testCountNumbersOnly() {
9322a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
94b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
95b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
96b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(6); // "Count (numbers only)"
97b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
9829cdfe15SLiu Zhe 		sleep(1);
9929cdfe15SLiu Zhe 
10022a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
10122a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Count", "", "3", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Count", "", "1", "", "" },
10222a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Count", "", "2", "", "" }, { "Grand Total", "", "6", "", "" } },
103b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
10429cdfe15SLiu Zhe 	}
10529cdfe15SLiu Zhe 
10629cdfe15SLiu Zhe 	/**
10722a14f28SLiu Zhe 	 * Just support en-US language Verify Max Numbers function in SubTotals
10829cdfe15SLiu Zhe 	 */
10929cdfe15SLiu Zhe 	@Test
11029cdfe15SLiu Zhe 	public void testMax() {
11122a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
112b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
113b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
114b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
115b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
11629cdfe15SLiu Zhe 		sleep(1);
11729cdfe15SLiu Zhe 
11822a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
11922a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Max", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Max", "", "5", "", "" },
12022a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Max", "", "3", "", "" }, { "Grand Total", "", "6", "", "" } },
121b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
12229cdfe15SLiu Zhe 	}
12329cdfe15SLiu Zhe 
12429cdfe15SLiu Zhe 	/**
12522a14f28SLiu Zhe 	 * Just support en-US language Verify Min Numbers function in SubTotals
12629cdfe15SLiu Zhe 	 */
12729cdfe15SLiu Zhe 	@Test
12829cdfe15SLiu Zhe 	public void testMin() {
12922a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
130b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
131b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
132b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(4); // "Min"
133b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
13429cdfe15SLiu Zhe 		sleep(1);
13529cdfe15SLiu Zhe 
13622a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
13722a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Min", "", "2", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Min", "", "5", "", "" },
13822a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Min", "", "1", "", "" }, { "Grand Total", "", "1", "", "" } },
139b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
14029cdfe15SLiu Zhe 	}
14129cdfe15SLiu Zhe 
14229cdfe15SLiu Zhe 	/**
14322a14f28SLiu Zhe 	 * Just support en-US language Verify Product function in SubTotals
14429cdfe15SLiu Zhe 	 */
14529cdfe15SLiu Zhe 	@Test
14629cdfe15SLiu Zhe 	public void testProduct() {
14722a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
148b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
149b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
150b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(5); // "Product"
151b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
15229cdfe15SLiu Zhe 		sleep(1);
15329cdfe15SLiu Zhe 
15422a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
15522a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Product", "", "48", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Product", "", "5", "", "" },
15622a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Product", "", "3", "", "" }, { "Grand Total", "", "720", "", "" } },
157b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
15829cdfe15SLiu Zhe 	}
15929cdfe15SLiu Zhe 
16029cdfe15SLiu Zhe 	/**
16122a14f28SLiu Zhe 	 * Just support en-US language Verify StDevP (Population) function in
16222a14f28SLiu Zhe 	 * SubTotals
16329cdfe15SLiu Zhe 	 */
16429cdfe15SLiu Zhe 	@Test
16529cdfe15SLiu Zhe 	public void testStDevPPopulation() {
16622a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
167b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
168b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
169b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(8); // "StDevP (Population)"
170b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
17129cdfe15SLiu Zhe 		sleep(1);
17229cdfe15SLiu Zhe 
17322a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
17422a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS StDev", "", "1.63299316", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS StDev", "", "0", "", "" },
17522a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS StDev", "", "1", "", "" }, { "Grand Total", "", "1.70782513", "", "" } },
176b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
17729cdfe15SLiu Zhe 	}
17829cdfe15SLiu Zhe 
17929cdfe15SLiu Zhe 	/**
18022a14f28SLiu Zhe 	 * Just support en-US language Verify sum function in SubTotals
18129cdfe15SLiu Zhe 	 */
18229cdfe15SLiu Zhe 	@Test
18329cdfe15SLiu Zhe 	public void testSum() {
18422a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
185b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
186b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
187b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(0); // "Sum"
188b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
18929cdfe15SLiu Zhe 		sleep(1);
19029cdfe15SLiu Zhe 
19122a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
19222a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
19322a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
194b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
19529cdfe15SLiu Zhe 	}
19629cdfe15SLiu Zhe 
19729cdfe15SLiu Zhe 	/**
19822a14f28SLiu Zhe 	 * Just support en-US language Verify Var Sample function in SubTotals
19929cdfe15SLiu Zhe 	 */
20029cdfe15SLiu Zhe 	@Test
20129cdfe15SLiu Zhe 	public void testVarSample() {
20222a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
203b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
204b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
205b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(9); // "Var (Sample)"
206b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
20729cdfe15SLiu Zhe 		sleep(1);
20829cdfe15SLiu Zhe 
20922a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
21022a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Var", "", "4", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Var", "", "#DIV/0!", "", "" },
21122a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Var", "", "2", "", "" }, { "Grand Total", "", "3.5", "", "" } },
212b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
21329cdfe15SLiu Zhe 	}
21429cdfe15SLiu Zhe 
21529cdfe15SLiu Zhe 	/**
21622a14f28SLiu Zhe 	 * Just support en-US language Verify Don't sort in Sub totals
21729cdfe15SLiu Zhe 	 */
21829cdfe15SLiu Zhe 	@Test
21929cdfe15SLiu Zhe 	public void testDoNotSortOption() {
220b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
22122a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
222b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
223b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
224b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.select();
225b4d2d410SLiu Zhe 		scSubtotalsPreSortToGroupCheckBox.uncheck();
226b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
22729cdfe15SLiu Zhe 		sleep(1);
22829cdfe15SLiu Zhe 
22922a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "B Sum", "" },
23022a14f28SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Sum", "" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
23122a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "60", "", "A Sum", "" }, { "MS", "10", "3", "B", "Kevin" }, { "", "10", "", "B Sum", "" },
232b4d2d410SLiu Zhe 				{ "", "110", "", "Grand Total", "" } }, SCTool.getCellTexts("A1:E12"));
23329cdfe15SLiu Zhe 	}
23429cdfe15SLiu Zhe 
23529cdfe15SLiu Zhe 	/**
23622a14f28SLiu Zhe 	 * Just support en-US language Verify SubTotals Options default UI
23729cdfe15SLiu Zhe 	 */
23829cdfe15SLiu Zhe 	@Test
23929cdfe15SLiu Zhe 	public void testDefaultUI() {
240b4d2d410SLiu Zhe 		assertArrayEquals("Group List: ", new String[] { "- none -", "Level", "Code", "No.", "Team", "Name" }, scSubTotalsGroupByListBox.getItemsText());
241b4d2d410SLiu Zhe 
242b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.select();
243b4d2d410SLiu Zhe 		assertFalse(scSubtotalsInsertPageBreakCheckBox.isChecked());
244b4d2d410SLiu Zhe 		assertFalse(scSubtotalsCaseSensitiveCheckBox.isChecked());
245b4d2d410SLiu Zhe 		assertTrue(scSubtotalsPreSortToGroupCheckBox.isChecked());
246b4d2d410SLiu Zhe 		assertTrue(scSubtotalSortAscendingRadioButton.isChecked());
247b4d2d410SLiu Zhe 		assertFalse(scSubtotalSortDescendingRadioButton.isChecked());
248b4d2d410SLiu Zhe 		assertFalse(scSubtotalsIncludeFormatsCheckBox.isChecked());
249b4d2d410SLiu Zhe 		assertFalse(scSubtotalsCustomSortOrderCheckBox.isChecked());
250b4d2d410SLiu Zhe 		assertFalse(scSubtotalsCustomSortListBox.isEnabled());
251b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
25229cdfe15SLiu Zhe 	}
25329cdfe15SLiu Zhe 
25429cdfe15SLiu Zhe 	/**
25522a14f28SLiu Zhe 	 * Just support en-US language Verify Subtotals using all group
25629cdfe15SLiu Zhe 	 */
25729cdfe15SLiu Zhe 	@Test
25829cdfe15SLiu Zhe 	public void testUsingAllGroup() {
259b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.select();
260b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(1); // "Level"
26122a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
262b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
263b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
264b4d2d410SLiu Zhe 		scSubTotalsGroup2Dialog.select();
265b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
26622a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
267b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
268b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
269b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
270b4d2d410SLiu Zhe 		scSubTotalsGroup3Dialog.select();
271b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(5); // "Name"
27222a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
273b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
274b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
275b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.select();
276b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
27729cdfe15SLiu Zhe 		sleep(1);
27829cdfe15SLiu Zhe 
27922a14f28SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "2", "A", "Chcomic" }, { "", "20", "", "", "Chcomic Sum" },
28022a14f28SLiu Zhe 				{ "", "20", "", "A Max", "" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "", "Elle Sum" }, { "", "20", "", "B Max", "" },
28122a14f28SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "", "Sweet Sum" }, { "", "20", "", "C Max", "" }, { "BS Sum", "", "12", "", "" },
28222a14f28SLiu Zhe 				{ "CS", "30", "5", "A", "Ally" }, { "", "30", "", "", "Ally Sum" }, { "", "30", "", "A Max", "" }, { "CS Sum", "", "5", "", "" },
28322a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "10", "", "", "Joker Sum" }, { "", "10", "", "A Max", "" }, { "MS", "10", "3", "B", "Kevin" },
28422a14f28SLiu Zhe 				{ "", "10", "", "", "Kevin Sum" }, { "", "10", "", "B Max", "" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
285b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E23"));
28629cdfe15SLiu Zhe 	}
28722a14f28SLiu Zhe 
28829cdfe15SLiu Zhe 	/**
28922a14f28SLiu Zhe 	 * Just support en-US language Verify Subtotals_Recalculate and refresh
29022a14f28SLiu Zhe 	 * results when data rows deleted.
29129cdfe15SLiu Zhe 	 */
29229cdfe15SLiu Zhe 	@Test
29329cdfe15SLiu Zhe 	public void testRecalculateAfterRowDeleted() {
29422a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,45);
295b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
296b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
297b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
29829cdfe15SLiu Zhe 		sleep(1);
29922a14f28SLiu Zhe 
30029cdfe15SLiu Zhe 		assertArrayEquals("Subtotal table before deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
30129cdfe15SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" },
30229cdfe15SLiu Zhe 				{ "CS Sum", "", "5", "", "" }, { "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" },
303b4d2d410SLiu Zhe 				{ "Grand Total", "", "21", "", "" } }, SCTool.getCellTexts("A1:E11"));
30422a14f28SLiu Zhe 
305b4d2d410SLiu Zhe 		SCTool.selectRange("A3:E3");
3063816404dSLiu Zhe 		app.dispatch(".uno:DeleteCell");
307b4d2d410SLiu Zhe 		scDeleteCellsDeleteRowsRadioButton.check();
308b4d2d410SLiu Zhe 		scDeleteCellsDialog.ok();
30929cdfe15SLiu Zhe 		sleep(1);
31022a14f28SLiu Zhe 
31129cdfe15SLiu Zhe 		assertArrayEquals("Subtotal table after deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
31229cdfe15SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
31322a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "15", "", "" }, { "", "", "", "", "" } },
314b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
31522a14f28SLiu Zhe 
31629cdfe15SLiu Zhe 	}
31722a14f28SLiu Zhe 
31829cdfe15SLiu Zhe 	/**
31922a14f28SLiu Zhe 	 * Verify Recalculates when source data changed with Average function in
32022a14f28SLiu Zhe 	 * SubTotals
32129cdfe15SLiu Zhe 	 */
32229cdfe15SLiu Zhe 	@Test
32329cdfe15SLiu Zhe 	public void testRecalculateWhenDataChanged() {
324b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
32522a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,25);
326b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
327b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
328b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
329b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
33029cdfe15SLiu Zhe 		sleep(1);
33122a14f28SLiu Zhe 
332b4d2d410SLiu Zhe 		SCTool.selectRange("B4");
33329cdfe15SLiu Zhe 		typeKeys("40" + "<enter>");
33429cdfe15SLiu Zhe 		sleep(1);
335b4d2d410SLiu Zhe 		assertEquals("30", SCTool.getCellText("B5"));
336b4d2d410SLiu Zhe 		assertEquals("23.33333333", SCTool.getCellText("B11"));
33722a14f28SLiu Zhe 
338b4d2d410SLiu Zhe 		SCTool.selectRange("B7");
33929cdfe15SLiu Zhe 		typeKeys("50" + "<enter>");
34029cdfe15SLiu Zhe 		sleep(1);
341b4d2d410SLiu Zhe 		assertEquals("35", SCTool.getCellText("B8"));
342b4d2d410SLiu Zhe 		assertEquals("30", SCTool.getCellText("B11"));
34322a14f28SLiu Zhe 
344b4d2d410SLiu Zhe 		SCTool.selectRange("B9");
34529cdfe15SLiu Zhe 		typeKeys("30" + "<enter>");
34629cdfe15SLiu Zhe 		sleep(1);
347b4d2d410SLiu Zhe 		assertEquals("30", SCTool.getCellText("B10"));
348b4d2d410SLiu Zhe 		assertEquals("31.66666667", SCTool.getCellText("B11"));
34929cdfe15SLiu Zhe 	}
35029cdfe15SLiu Zhe }
351