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 
22*424494b0SLi Feng Wang 
2380a6f5c5SLiu Zhe package fvt.gui.sc.subtotals;
2429cdfe15SLiu Zhe 
2529cdfe15SLiu Zhe import static org.junit.Assert.*;
2695269d92SLiu Zhe import static org.openoffice.test.common.Testspace.*;
2722a14f28SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
28b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
2995269d92SLiu Zhe import static testlib.gui.UIMap.*;
3029cdfe15SLiu Zhe 
3129cdfe15SLiu Zhe import org.junit.After;
3229cdfe15SLiu Zhe import org.junit.Before;
3329cdfe15SLiu Zhe import org.junit.Rule;
3429cdfe15SLiu Zhe import org.junit.Test;
3522a14f28SLiu Zhe import org.openoffice.test.common.Logger;
3629cdfe15SLiu Zhe 
37b4d2d410SLiu Zhe import testlib.gui.SCTool;
3829cdfe15SLiu Zhe 
3929cdfe15SLiu Zhe 
40*424494b0SLi Feng Wang public class SubtotalsFunctions {
4129cdfe15SLiu Zhe 
4229cdfe15SLiu Zhe 	@Before
4329cdfe15SLiu Zhe 	public void setUp() throws Exception {
444d3496b1SLiu Zhe 		app.start(true);
4595269d92SLiu Zhe 		String file = prepareData("sc/SubtotalsSampleFile.ods");
46*424494b0SLi Feng Wang 		open(file);
47b4d2d410SLiu Zhe 		SCTool.selectRange("A1:E7");
483816404dSLiu Zhe 		app.dispatch(".uno:DataSubTotals");
4929cdfe15SLiu Zhe 	}
5029cdfe15SLiu Zhe 
5129cdfe15SLiu Zhe 	@After
5229cdfe15SLiu Zhe 	public void tearDown() throws Exception {
53*424494b0SLi Feng Wang 		app.stop();
5422a14f28SLiu Zhe 
5529cdfe15SLiu Zhe 	}
5629cdfe15SLiu Zhe 
5729cdfe15SLiu Zhe 	/**
5822a14f28SLiu Zhe 	 * Just support en-US language Verify Average function in SubTotals
5929cdfe15SLiu Zhe 	 */
6029cdfe15SLiu Zhe 	@Test
6129cdfe15SLiu Zhe 	public void testAverage() {
62b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
6322a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25); // In different platform, can
6422a14f28SLiu Zhe 		// not focus on same checkbox
65b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
66b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
674d3496b1SLiu Zhe 		sleep(1);
68b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
69b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
7029cdfe15SLiu Zhe 		sleep(1);
7129cdfe15SLiu Zhe 
72*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Average function in Subtotal ", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
7322a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "20", "", "A Average", "" }, { "BS", "20", "4", "B", "Elle" }, { "MS", "10", "3", "B", "Kevin" },
7422a14f28SLiu Zhe 				{ "", "15", "", "B Average", "" }, { "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Average", "" }, { "", "18.33333333", "", "Grand Total", "" } },
75b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
7629cdfe15SLiu Zhe 	}
7729cdfe15SLiu Zhe 
7829cdfe15SLiu Zhe 	/**
7922a14f28SLiu Zhe 	 * Just support en-US language Verify Count Numbers only function in
8022a14f28SLiu Zhe 	 * SubTotals
8129cdfe15SLiu Zhe 	 */
8229cdfe15SLiu Zhe 	@Test
8329cdfe15SLiu Zhe 	public void testCountNumbersOnly() {
8422a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
85b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
86b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
87b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(6); // "Count (numbers only)"
88b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
8929cdfe15SLiu Zhe 		sleep(1);
9029cdfe15SLiu Zhe 
91*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Count Numbers only function in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
9222a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Count", "", "3", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Count", "", "1", "", "" },
9322a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Count", "", "2", "", "" }, { "Grand Total", "", "6", "", "" } },
94b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
9529cdfe15SLiu Zhe 	}
9629cdfe15SLiu Zhe 
9729cdfe15SLiu Zhe 	/**
9822a14f28SLiu Zhe 	 * Just support en-US language Verify Max Numbers function in SubTotals
9929cdfe15SLiu Zhe 	 */
10029cdfe15SLiu Zhe 	@Test
10129cdfe15SLiu Zhe 	public void testMax() {
10222a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
103b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
104b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
105b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
106b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
10729cdfe15SLiu Zhe 		sleep(1);
10829cdfe15SLiu Zhe 
109*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Max Numbers function in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
11022a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Max", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Max", "", "5", "", "" },
11122a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Max", "", "3", "", "" }, { "Grand Total", "", "6", "", "" } },
112b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
11329cdfe15SLiu Zhe 	}
11429cdfe15SLiu Zhe 
11529cdfe15SLiu Zhe 	/**
11622a14f28SLiu Zhe 	 * Just support en-US language Verify Min Numbers function in SubTotals
11729cdfe15SLiu Zhe 	 */
11829cdfe15SLiu Zhe 	@Test
11929cdfe15SLiu Zhe 	public void testMin() {
12022a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
121b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
122b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
123b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(4); // "Min"
124b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
12529cdfe15SLiu Zhe 		sleep(1);
12629cdfe15SLiu Zhe 
127*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Min Numbers function in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
12822a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Min", "", "2", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Min", "", "5", "", "" },
12922a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Min", "", "1", "", "" }, { "Grand Total", "", "1", "", "" } },
130b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
13129cdfe15SLiu Zhe 	}
13229cdfe15SLiu Zhe 
13329cdfe15SLiu Zhe 	/**
13422a14f28SLiu Zhe 	 * Just support en-US language Verify Product function in SubTotals
13529cdfe15SLiu Zhe 	 */
13629cdfe15SLiu Zhe 	@Test
13729cdfe15SLiu Zhe 	public void testProduct() {
13822a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
139b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
140b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
141b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(5); // "Product"
142b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
14329cdfe15SLiu Zhe 		sleep(1);
14429cdfe15SLiu Zhe 
145*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Product function in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
14622a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Product", "", "48", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Product", "", "5", "", "" },
14722a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Product", "", "3", "", "" }, { "Grand Total", "", "720", "", "" } },
148b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
14929cdfe15SLiu Zhe 	}
15029cdfe15SLiu Zhe 
15129cdfe15SLiu Zhe 	/**
15222a14f28SLiu Zhe 	 * Just support en-US language Verify StDevP (Population) function in
15322a14f28SLiu Zhe 	 * SubTotals
15429cdfe15SLiu Zhe 	 */
15529cdfe15SLiu Zhe 	@Test
15629cdfe15SLiu Zhe 	public void testStDevPPopulation() {
15722a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
158b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
159b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
160b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(8); // "StDevP (Population)"
161b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
16229cdfe15SLiu Zhe 		sleep(1);
16329cdfe15SLiu Zhe 
164*424494b0SLi Feng Wang 		assertArrayEquals("Wrong StdevP function in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
16522a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS StDev", "", "1.63299316", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS StDev", "", "0", "", "" },
16622a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS StDev", "", "1", "", "" }, { "Grand Total", "", "1.70782513", "", "" } },
167b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
16829cdfe15SLiu Zhe 	}
16929cdfe15SLiu Zhe 
17029cdfe15SLiu Zhe 	/**
17122a14f28SLiu Zhe 	 * Just support en-US language Verify sum function in SubTotals
17229cdfe15SLiu Zhe 	 */
17329cdfe15SLiu Zhe 	@Test
17429cdfe15SLiu Zhe 	public void testSum() {
17522a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
176b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
177b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
178b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(0); // "Sum"
179b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
18029cdfe15SLiu Zhe 		sleep(1);
18129cdfe15SLiu Zhe 
182*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Sum Function in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
18322a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
18422a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
185b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
18629cdfe15SLiu Zhe 	}
18729cdfe15SLiu Zhe 
18829cdfe15SLiu Zhe 	/**
18922a14f28SLiu Zhe 	 * Just support en-US language Verify Var Sample function in SubTotals
19029cdfe15SLiu Zhe 	 */
19129cdfe15SLiu Zhe 	@Test
19229cdfe15SLiu Zhe 	public void testVarSample() {
19322a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
194b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
195b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
196b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(9); // "Var (Sample)"
197b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
19829cdfe15SLiu Zhe 		sleep(1);
19929cdfe15SLiu Zhe 
200*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Var Sample function in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
20122a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Var", "", "4", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Var", "", "#DIV/0!", "", "" },
20222a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Var", "", "2", "", "" }, { "Grand Total", "", "3.5", "", "" } },
203b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
20429cdfe15SLiu Zhe 	}
20529cdfe15SLiu Zhe 
20629cdfe15SLiu Zhe 	/**
20722a14f28SLiu Zhe 	 * Just support en-US language Verify Don't sort in Sub totals
20829cdfe15SLiu Zhe 	 */
20929cdfe15SLiu Zhe 	@Test
21029cdfe15SLiu Zhe 	public void testDoNotSortOption() {
211b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
21222a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
213b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
214b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
215b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.select();
216b4d2d410SLiu Zhe 		scSubtotalsPreSortToGroupCheckBox.uncheck();
217b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
21829cdfe15SLiu Zhe 		sleep(1);
21929cdfe15SLiu Zhe 
220*424494b0SLi Feng Wang 		assertArrayEquals("Wrong Not Sort option in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "B Sum", "" },
22122a14f28SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Sum", "" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
22222a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "60", "", "A Sum", "" }, { "MS", "10", "3", "B", "Kevin" }, { "", "10", "", "B Sum", "" },
223b4d2d410SLiu Zhe 				{ "", "110", "", "Grand Total", "" } }, SCTool.getCellTexts("A1:E12"));
22429cdfe15SLiu Zhe 	}
22529cdfe15SLiu Zhe 
22629cdfe15SLiu Zhe 	/**
22722a14f28SLiu Zhe 	 * Just support en-US language Verify SubTotals Options default UI
22829cdfe15SLiu Zhe 	 */
22929cdfe15SLiu Zhe 	@Test
23029cdfe15SLiu Zhe 	public void testDefaultUI() {
231b4d2d410SLiu Zhe 		assertArrayEquals("Group List: ", new String[] { "- none -", "Level", "Code", "No.", "Team", "Name" }, scSubTotalsGroupByListBox.getItemsText());
232b4d2d410SLiu Zhe 
233b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.select();
234*424494b0SLi Feng Wang 		assertFalse("Wrong default value of InsertPageBreak checkbox",scSubtotalsInsertPageBreakCheckBox.isChecked());
235*424494b0SLi Feng Wang 		assertFalse("Wrong default value of CaseSensitive checkbox",scSubtotalsCaseSensitiveCheckBox.isChecked());
236*424494b0SLi Feng Wang 		assertTrue("Worng default value of PreSortToGroup checkbox",scSubtotalsPreSortToGroupCheckBox.isChecked());
237*424494b0SLi Feng Wang 		assertTrue("Wrong default value of SortAscending Radio button",scSubtotalSortAscendingRadioButton.isChecked());
238*424494b0SLi Feng Wang 		assertFalse("Wrong default value of SortDescending Radio button",scSubtotalSortDescendingRadioButton.isChecked());
239*424494b0SLi Feng Wang 		assertFalse("Wrong default value of InludeFormat checkbox",scSubtotalsIncludeFormatsCheckBox.isChecked());
240*424494b0SLi Feng Wang 		assertFalse("Wrong default value of CustomSortOrder checkbox",scSubtotalsCustomSortOrderCheckBox.isChecked());
241*424494b0SLi Feng Wang 		assertFalse("Wrong default value of CustomSort listbox",scSubtotalsCustomSortListBox.isEnabled());
242b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
24329cdfe15SLiu Zhe 	}
24429cdfe15SLiu Zhe 
24529cdfe15SLiu Zhe 	/**
24622a14f28SLiu Zhe 	 * Just support en-US language Verify Subtotals using all group
24729cdfe15SLiu Zhe 	 */
24829cdfe15SLiu Zhe 	@Test
24929cdfe15SLiu Zhe 	public void testUsingAllGroup() {
250b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.select();
251b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(1); // "Level"
25222a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
253b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
254b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
255b4d2d410SLiu Zhe 		scSubTotalsGroup2Dialog.select();
256b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
25722a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
258b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
259b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
260b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
261b4d2d410SLiu Zhe 		scSubTotalsGroup3Dialog.select();
262b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(5); // "Name"
26322a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
264b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
265b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
266b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.select();
267b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
26829cdfe15SLiu Zhe 		sleep(1);
26929cdfe15SLiu Zhe 
270*424494b0SLi Feng Wang 		assertArrayEquals("Not all group in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "2", "A", "Chcomic" }, { "", "20", "", "", "Chcomic Sum" },
27122a14f28SLiu Zhe 				{ "", "20", "", "A Max", "" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "", "Elle Sum" }, { "", "20", "", "B Max", "" },
27222a14f28SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "", "Sweet Sum" }, { "", "20", "", "C Max", "" }, { "BS Sum", "", "12", "", "" },
27322a14f28SLiu Zhe 				{ "CS", "30", "5", "A", "Ally" }, { "", "30", "", "", "Ally Sum" }, { "", "30", "", "A Max", "" }, { "CS Sum", "", "5", "", "" },
27422a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "10", "", "", "Joker Sum" }, { "", "10", "", "A Max", "" }, { "MS", "10", "3", "B", "Kevin" },
27522a14f28SLiu Zhe 				{ "", "10", "", "", "Kevin Sum" }, { "", "10", "", "B Max", "" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
276b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E23"));
27729cdfe15SLiu Zhe 	}
27822a14f28SLiu Zhe 
27929cdfe15SLiu Zhe 	/**
28022a14f28SLiu Zhe 	 * Just support en-US language Verify Subtotals_Recalculate and refresh
28122a14f28SLiu Zhe 	 * results when data rows deleted.
28229cdfe15SLiu Zhe 	 */
28329cdfe15SLiu Zhe 	@Test
28429cdfe15SLiu Zhe 	public void testRecalculateAfterRowDeleted() {
28522a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,45);
286b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
287b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
288b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
28929cdfe15SLiu Zhe 		sleep(1);
29022a14f28SLiu Zhe 
291*424494b0SLi Feng Wang 		assertArrayEquals("Subtotal table not equal before deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
29229cdfe15SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" },
29329cdfe15SLiu Zhe 				{ "CS Sum", "", "5", "", "" }, { "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" },
294b4d2d410SLiu Zhe 				{ "Grand Total", "", "21", "", "" } }, SCTool.getCellTexts("A1:E11"));
29522a14f28SLiu Zhe 
296b4d2d410SLiu Zhe 		SCTool.selectRange("A3:E3");
2973816404dSLiu Zhe 		app.dispatch(".uno:DeleteCell");
298b4d2d410SLiu Zhe 		scDeleteCellsDeleteRowsRadioButton.check();
299b4d2d410SLiu Zhe 		scDeleteCellsDialog.ok();
30029cdfe15SLiu Zhe 		sleep(1);
30122a14f28SLiu Zhe 
302*424494b0SLi Feng Wang 		assertArrayEquals("Subtotal table not equal after deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
30329cdfe15SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
30422a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "15", "", "" }, { "", "", "", "", "" } },
305b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
30622a14f28SLiu Zhe 
30729cdfe15SLiu Zhe 	}
30822a14f28SLiu Zhe 
30929cdfe15SLiu Zhe 	/**
31022a14f28SLiu Zhe 	 * Verify Recalculates when source data changed with Average function in
31122a14f28SLiu Zhe 	 * SubTotals
31229cdfe15SLiu Zhe 	 */
31329cdfe15SLiu Zhe 	@Test
31429cdfe15SLiu Zhe 	public void testRecalculateWhenDataChanged() {
315b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
31622a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,25);
317b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
318b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
319b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
320b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
32129cdfe15SLiu Zhe 		sleep(1);
32222a14f28SLiu Zhe 
323b4d2d410SLiu Zhe 		SCTool.selectRange("B4");
32429cdfe15SLiu Zhe 		typeKeys("40" + "<enter>");
32529cdfe15SLiu Zhe 		sleep(1);
326*424494b0SLi Feng Wang 		assertEquals("B5's cell text is not 30","30", SCTool.getCellText("B5"));
327*424494b0SLi Feng Wang 		assertEquals("B11's cell text is not 23.33333333","23.33333333", SCTool.getCellText("B11"));
32822a14f28SLiu Zhe 
329b4d2d410SLiu Zhe 		SCTool.selectRange("B7");
33029cdfe15SLiu Zhe 		typeKeys("50" + "<enter>");
33129cdfe15SLiu Zhe 		sleep(1);
332*424494b0SLi Feng Wang 		assertEquals("B8's cell text is not 35","35", SCTool.getCellText("B8"));
333*424494b0SLi Feng Wang 		assertEquals("B11's cell text is not 30","30", SCTool.getCellText("B11"));
33422a14f28SLiu Zhe 
335b4d2d410SLiu Zhe 		SCTool.selectRange("B9");
33629cdfe15SLiu Zhe 		typeKeys("30" + "<enter>");
33729cdfe15SLiu Zhe 		sleep(1);
338*424494b0SLi Feng Wang 		assertEquals("B10's cell text is not 30","30", SCTool.getCellText("B10"));
339*424494b0SLi Feng Wang 		assertEquals("B11's cell text is not 31.66666667","31.66666667", SCTool.getCellText("B11"));
34029cdfe15SLiu Zhe 	}
34129cdfe15SLiu Zhe }
342