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 
22424494b0SLi 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 
40424494b0SLi Feng Wang public class SubtotalsFunctions {
4129cdfe15SLiu Zhe 
42*fd348426SLi Feng Wang 	@Rule
43*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
44*fd348426SLi Feng Wang 
4529cdfe15SLiu Zhe 	@Before
4629cdfe15SLiu Zhe 	public void setUp() throws Exception {
474d3496b1SLiu Zhe 		app.start(true);
4895269d92SLiu Zhe 		String file = prepareData("sc/SubtotalsSampleFile.ods");
49424494b0SLi Feng Wang 		open(file);
50b4d2d410SLiu Zhe 		SCTool.selectRange("A1:E7");
513816404dSLiu Zhe 		app.dispatch(".uno:DataSubTotals");
5229cdfe15SLiu Zhe 	}
5329cdfe15SLiu Zhe 
5429cdfe15SLiu Zhe 	@After
5529cdfe15SLiu Zhe 	public void tearDown() throws Exception {
56424494b0SLi Feng Wang 		app.stop();
5722a14f28SLiu Zhe 
5829cdfe15SLiu Zhe 	}
5929cdfe15SLiu Zhe 
6029cdfe15SLiu Zhe 	/**
6122a14f28SLiu Zhe 	 * Just support en-US language Verify Average function in SubTotals
6229cdfe15SLiu Zhe 	 */
6329cdfe15SLiu Zhe 	@Test
6429cdfe15SLiu Zhe 	public void testAverage() {
65b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
6622a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25); // In different platform, can
6722a14f28SLiu Zhe 		// not focus on same checkbox
68b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
69b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
704d3496b1SLiu Zhe 		sleep(1);
71b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
72b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
7329cdfe15SLiu Zhe 		sleep(1);
7429cdfe15SLiu Zhe 
75424494b0SLi 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" },
7622a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "20", "", "A Average", "" }, { "BS", "20", "4", "B", "Elle" }, { "MS", "10", "3", "B", "Kevin" },
7722a14f28SLiu Zhe 				{ "", "15", "", "B Average", "" }, { "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Average", "" }, { "", "18.33333333", "", "Grand Total", "" } },
78b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
7929cdfe15SLiu Zhe 	}
8029cdfe15SLiu Zhe 
8129cdfe15SLiu Zhe 	/**
8222a14f28SLiu Zhe 	 * Just support en-US language Verify Count Numbers only function in
8322a14f28SLiu Zhe 	 * SubTotals
8429cdfe15SLiu Zhe 	 */
8529cdfe15SLiu Zhe 	@Test
8629cdfe15SLiu Zhe 	public void testCountNumbersOnly() {
8722a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
88b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
89b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
90b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(6); // "Count (numbers only)"
91b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
9229cdfe15SLiu Zhe 		sleep(1);
9329cdfe15SLiu Zhe 
94424494b0SLi 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" },
9522a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Count", "", "3", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Count", "", "1", "", "" },
9622a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Count", "", "2", "", "" }, { "Grand Total", "", "6", "", "" } },
97b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
9829cdfe15SLiu Zhe 	}
9929cdfe15SLiu Zhe 
10029cdfe15SLiu Zhe 	/**
10122a14f28SLiu Zhe 	 * Just support en-US language Verify Max Numbers function in SubTotals
10229cdfe15SLiu Zhe 	 */
10329cdfe15SLiu Zhe 	@Test
10429cdfe15SLiu Zhe 	public void testMax() {
10522a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
106b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
107b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
108b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
109b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
11029cdfe15SLiu Zhe 		sleep(1);
11129cdfe15SLiu Zhe 
112424494b0SLi 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" },
11322a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Max", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Max", "", "5", "", "" },
11422a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Max", "", "3", "", "" }, { "Grand Total", "", "6", "", "" } },
115b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
11629cdfe15SLiu Zhe 	}
11729cdfe15SLiu Zhe 
11829cdfe15SLiu Zhe 	/**
11922a14f28SLiu Zhe 	 * Just support en-US language Verify Min Numbers function in SubTotals
12029cdfe15SLiu Zhe 	 */
12129cdfe15SLiu Zhe 	@Test
12229cdfe15SLiu Zhe 	public void testMin() {
12322a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
124b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
125b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
126b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(4); // "Min"
127b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
12829cdfe15SLiu Zhe 		sleep(1);
12929cdfe15SLiu Zhe 
130424494b0SLi 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" },
13122a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Min", "", "2", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Min", "", "5", "", "" },
13222a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Min", "", "1", "", "" }, { "Grand Total", "", "1", "", "" } },
133b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
13429cdfe15SLiu Zhe 	}
13529cdfe15SLiu Zhe 
13629cdfe15SLiu Zhe 	/**
13722a14f28SLiu Zhe 	 * Just support en-US language Verify Product function in SubTotals
13829cdfe15SLiu Zhe 	 */
13929cdfe15SLiu Zhe 	@Test
14029cdfe15SLiu Zhe 	public void testProduct() {
14122a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
142b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
143b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
144b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(5); // "Product"
145b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
14629cdfe15SLiu Zhe 		sleep(1);
14729cdfe15SLiu Zhe 
148424494b0SLi 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" },
14922a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Product", "", "48", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Product", "", "5", "", "" },
15022a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Product", "", "3", "", "" }, { "Grand Total", "", "720", "", "" } },
151b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
15229cdfe15SLiu Zhe 	}
15329cdfe15SLiu Zhe 
15429cdfe15SLiu Zhe 	/**
15522a14f28SLiu Zhe 	 * Just support en-US language Verify StDevP (Population) function in
15622a14f28SLiu Zhe 	 * SubTotals
15729cdfe15SLiu Zhe 	 */
15829cdfe15SLiu Zhe 	@Test
15929cdfe15SLiu Zhe 	public void testStDevPPopulation() {
16022a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
161b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
162b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
163b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(8); // "StDevP (Population)"
164b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
16529cdfe15SLiu Zhe 		sleep(1);
16629cdfe15SLiu Zhe 
167424494b0SLi 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" },
16822a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS StDev", "", "1.63299316", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS StDev", "", "0", "", "" },
16922a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS StDev", "", "1", "", "" }, { "Grand Total", "", "1.70782513", "", "" } },
170b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
17129cdfe15SLiu Zhe 	}
17229cdfe15SLiu Zhe 
17329cdfe15SLiu Zhe 	/**
17422a14f28SLiu Zhe 	 * Just support en-US language Verify sum function in SubTotals
17529cdfe15SLiu Zhe 	 */
17629cdfe15SLiu Zhe 	@Test
17729cdfe15SLiu Zhe 	public void testSum() {
17822a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
179b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
180b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
181b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(0); // "Sum"
182b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
18329cdfe15SLiu Zhe 		sleep(1);
18429cdfe15SLiu Zhe 
185424494b0SLi 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" },
18622a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
18722a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
188b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
18929cdfe15SLiu Zhe 	}
19029cdfe15SLiu Zhe 
19129cdfe15SLiu Zhe 	/**
19222a14f28SLiu Zhe 	 * Just support en-US language Verify Var Sample function in SubTotals
19329cdfe15SLiu Zhe 	 */
19429cdfe15SLiu Zhe 	@Test
19529cdfe15SLiu Zhe 	public void testVarSample() {
19622a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
197b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
198b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
199b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(9); // "Var (Sample)"
200b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
20129cdfe15SLiu Zhe 		sleep(1);
20229cdfe15SLiu Zhe 
203424494b0SLi 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" },
20422a14f28SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Var", "", "4", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Var", "", "#DIV/0!", "", "" },
20522a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Var", "", "2", "", "" }, { "Grand Total", "", "3.5", "", "" } },
206b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
20729cdfe15SLiu Zhe 	}
20829cdfe15SLiu Zhe 
20929cdfe15SLiu Zhe 	/**
21022a14f28SLiu Zhe 	 * Just support en-US language Verify Don't sort in Sub totals
21129cdfe15SLiu Zhe 	 */
21229cdfe15SLiu Zhe 	@Test
21329cdfe15SLiu Zhe 	public void testDoNotSortOption() {
214b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
21522a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
216b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
217b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
218b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.select();
219b4d2d410SLiu Zhe 		scSubtotalsPreSortToGroupCheckBox.uncheck();
220b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
22129cdfe15SLiu Zhe 		sleep(1);
22229cdfe15SLiu Zhe 
223424494b0SLi Feng Wang 		assertArrayEquals("Wrong Not Sort option in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "B Sum", "" },
22422a14f28SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Sum", "" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
22522a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "60", "", "A Sum", "" }, { "MS", "10", "3", "B", "Kevin" }, { "", "10", "", "B Sum", "" },
226b4d2d410SLiu Zhe 				{ "", "110", "", "Grand Total", "" } }, SCTool.getCellTexts("A1:E12"));
22729cdfe15SLiu Zhe 	}
22829cdfe15SLiu Zhe 
22929cdfe15SLiu Zhe 	/**
23022a14f28SLiu Zhe 	 * Just support en-US language Verify SubTotals Options default UI
23129cdfe15SLiu Zhe 	 */
23229cdfe15SLiu Zhe 	@Test
23329cdfe15SLiu Zhe 	public void testDefaultUI() {
234b4d2d410SLiu Zhe 		assertArrayEquals("Group List: ", new String[] { "- none -", "Level", "Code", "No.", "Team", "Name" }, scSubTotalsGroupByListBox.getItemsText());
235b4d2d410SLiu Zhe 
236b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.select();
237424494b0SLi Feng Wang 		assertFalse("Wrong default value of InsertPageBreak checkbox",scSubtotalsInsertPageBreakCheckBox.isChecked());
238424494b0SLi Feng Wang 		assertFalse("Wrong default value of CaseSensitive checkbox",scSubtotalsCaseSensitiveCheckBox.isChecked());
239424494b0SLi Feng Wang 		assertTrue("Worng default value of PreSortToGroup checkbox",scSubtotalsPreSortToGroupCheckBox.isChecked());
240424494b0SLi Feng Wang 		assertTrue("Wrong default value of SortAscending Radio button",scSubtotalSortAscendingRadioButton.isChecked());
241424494b0SLi Feng Wang 		assertFalse("Wrong default value of SortDescending Radio button",scSubtotalSortDescendingRadioButton.isChecked());
242424494b0SLi Feng Wang 		assertFalse("Wrong default value of InludeFormat checkbox",scSubtotalsIncludeFormatsCheckBox.isChecked());
243424494b0SLi Feng Wang 		assertFalse("Wrong default value of CustomSortOrder checkbox",scSubtotalsCustomSortOrderCheckBox.isChecked());
244424494b0SLi Feng Wang 		assertFalse("Wrong default value of CustomSort listbox",scSubtotalsCustomSortListBox.isEnabled());
245b4d2d410SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
24629cdfe15SLiu Zhe 	}
24729cdfe15SLiu Zhe 
24829cdfe15SLiu Zhe 	/**
24922a14f28SLiu Zhe 	 * Just support en-US language Verify Subtotals using all group
25029cdfe15SLiu Zhe 	 */
25129cdfe15SLiu Zhe 	@Test
25229cdfe15SLiu Zhe 	public void testUsingAllGroup() {
253b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.select();
254b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(1); // "Level"
25522a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
256b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
257b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
258b4d2d410SLiu Zhe 		scSubTotalsGroup2Dialog.select();
259b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
26022a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
261b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
262b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
263b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
264b4d2d410SLiu Zhe 		scSubTotalsGroup3Dialog.select();
265b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(5); // "Name"
26622a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
267b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
268b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
269b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.select();
270b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
27129cdfe15SLiu Zhe 		sleep(1);
27229cdfe15SLiu Zhe 
273424494b0SLi Feng Wang 		assertArrayEquals("Not all group in Subtotal", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "2", "A", "Chcomic" }, { "", "20", "", "", "Chcomic Sum" },
27422a14f28SLiu Zhe 				{ "", "20", "", "A Max", "" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "", "Elle Sum" }, { "", "20", "", "B Max", "" },
27522a14f28SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "", "Sweet Sum" }, { "", "20", "", "C Max", "" }, { "BS Sum", "", "12", "", "" },
27622a14f28SLiu Zhe 				{ "CS", "30", "5", "A", "Ally" }, { "", "30", "", "", "Ally Sum" }, { "", "30", "", "A Max", "" }, { "CS Sum", "", "5", "", "" },
27722a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "10", "", "", "Joker Sum" }, { "", "10", "", "A Max", "" }, { "MS", "10", "3", "B", "Kevin" },
27822a14f28SLiu Zhe 				{ "", "10", "", "", "Kevin Sum" }, { "", "10", "", "B Max", "" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
279b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E23"));
28029cdfe15SLiu Zhe 	}
28122a14f28SLiu Zhe 
28229cdfe15SLiu Zhe 	/**
28322a14f28SLiu Zhe 	 * Just support en-US language Verify Subtotals_Recalculate and refresh
28422a14f28SLiu Zhe 	 * results when data rows deleted.
28529cdfe15SLiu Zhe 	 */
28629cdfe15SLiu Zhe 	@Test
28729cdfe15SLiu Zhe 	public void testRecalculateAfterRowDeleted() {
28822a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,45);
289b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(2);
290b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
291b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
29229cdfe15SLiu Zhe 		sleep(1);
29322a14f28SLiu Zhe 
294424494b0SLi Feng Wang 		assertArrayEquals("Subtotal table not equal before deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
29529cdfe15SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" },
29629cdfe15SLiu Zhe 				{ "CS Sum", "", "5", "", "" }, { "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" },
297b4d2d410SLiu Zhe 				{ "Grand Total", "", "21", "", "" } }, SCTool.getCellTexts("A1:E11"));
29822a14f28SLiu Zhe 
299b4d2d410SLiu Zhe 		SCTool.selectRange("A3:E3");
3003816404dSLiu Zhe 		app.dispatch(".uno:DeleteCell");
301b4d2d410SLiu Zhe 		scDeleteCellsDeleteRowsRadioButton.check();
302b4d2d410SLiu Zhe 		scDeleteCellsDialog.ok();
30329cdfe15SLiu Zhe 		sleep(1);
30422a14f28SLiu Zhe 
305424494b0SLi Feng Wang 		assertArrayEquals("Subtotal table not equal after deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
30629cdfe15SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
30722a14f28SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "15", "", "" }, { "", "", "", "", "" } },
308b4d2d410SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
30922a14f28SLiu Zhe 
31029cdfe15SLiu Zhe 	}
31122a14f28SLiu Zhe 
31229cdfe15SLiu Zhe 	/**
31322a14f28SLiu Zhe 	 * Verify Recalculates when source data changed with Average function in
31422a14f28SLiu Zhe 	 * SubTotals
31529cdfe15SLiu Zhe 	 */
31629cdfe15SLiu Zhe 	@Test
31729cdfe15SLiu Zhe 	public void testRecalculateWhenDataChanged() {
318b4d2d410SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
31922a14f28SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,25);
320b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.select(1);
321b4d2d410SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
322b4d2d410SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
323b4d2d410SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
32429cdfe15SLiu Zhe 		sleep(1);
32522a14f28SLiu Zhe 
326b4d2d410SLiu Zhe 		SCTool.selectRange("B4");
32729cdfe15SLiu Zhe 		typeKeys("40" + "<enter>");
32829cdfe15SLiu Zhe 		sleep(1);
329424494b0SLi Feng Wang 		assertEquals("B5's cell text is not 30","30", SCTool.getCellText("B5"));
330424494b0SLi Feng Wang 		assertEquals("B11's cell text is not 23.33333333","23.33333333", SCTool.getCellText("B11"));
33122a14f28SLiu Zhe 
332b4d2d410SLiu Zhe 		SCTool.selectRange("B7");
33329cdfe15SLiu Zhe 		typeKeys("50" + "<enter>");
33429cdfe15SLiu Zhe 		sleep(1);
335424494b0SLi Feng Wang 		assertEquals("B8's cell text is not 35","35", SCTool.getCellText("B8"));
336424494b0SLi Feng Wang 		assertEquals("B11's cell text is not 30","30", SCTool.getCellText("B11"));
33722a14f28SLiu Zhe 
338b4d2d410SLiu Zhe 		SCTool.selectRange("B9");
33929cdfe15SLiu Zhe 		typeKeys("30" + "<enter>");
34029cdfe15SLiu Zhe 		sleep(1);
341424494b0SLi Feng Wang 		assertEquals("B10's cell text is not 30","30", SCTool.getCellText("B10"));
342424494b0SLi Feng Wang 		assertEquals("B11's cell text is not 31.66666667","31.66666667", SCTool.getCellText("B11"));
34329cdfe15SLiu Zhe 	}
34429cdfe15SLiu Zhe }
345