xref: /AOO41X/test/testgui/source/fvt/gui/sc/subtotals/SubtotalsFunctions.java (revision fd3484265709667881cfaec27d41da15d46b6832)
180a6f5c5SLiu Zhe /**************************************************************
280a6f5c5SLiu Zhe  *
380a6f5c5SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
480a6f5c5SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
580a6f5c5SLiu Zhe  * distributed with this work for additional information
680a6f5c5SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
780a6f5c5SLiu Zhe  * to you under the Apache License, Version 2.0 (the
880a6f5c5SLiu Zhe  * "License"); you may not use this file except in compliance
980a6f5c5SLiu Zhe  * with the License.  You may obtain a copy of the License at
1080a6f5c5SLiu Zhe  *
1180a6f5c5SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1280a6f5c5SLiu Zhe  *
1380a6f5c5SLiu Zhe  * Unless required by applicable law or agreed to in writing,
1480a6f5c5SLiu Zhe  * software distributed under the License is distributed on an
1580a6f5c5SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1680a6f5c5SLiu Zhe  * KIND, either express or implied.  See the License for the
1780a6f5c5SLiu Zhe  * specific language governing permissions and limitations
1880a6f5c5SLiu Zhe  * under the License.
1980a6f5c5SLiu Zhe  *
2080a6f5c5SLiu Zhe  *************************************************************/
2180a6f5c5SLiu Zhe 
22424494b0SLi Feng Wang 
2380a6f5c5SLiu Zhe package fvt.gui.sc.subtotals;
2480a6f5c5SLiu Zhe 
2580a6f5c5SLiu Zhe import static org.junit.Assert.*;
2680a6f5c5SLiu Zhe import static org.openoffice.test.common.Testspace.*;
2780a6f5c5SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
2880a6f5c5SLiu Zhe import static testlib.gui.AppTool.*;
2980a6f5c5SLiu Zhe import static testlib.gui.UIMap.*;
3080a6f5c5SLiu Zhe 
3180a6f5c5SLiu Zhe import org.junit.After;
3280a6f5c5SLiu Zhe import org.junit.Before;
3380a6f5c5SLiu Zhe import org.junit.Rule;
3480a6f5c5SLiu Zhe import org.junit.Test;
3580a6f5c5SLiu Zhe import org.openoffice.test.common.Logger;
3680a6f5c5SLiu Zhe 
3780a6f5c5SLiu Zhe import testlib.gui.SCTool;
3880a6f5c5SLiu Zhe 
3980a6f5c5SLiu Zhe 
40424494b0SLi Feng Wang public class SubtotalsFunctions {
4180a6f5c5SLiu Zhe 
42*fd348426SLi Feng Wang 	@Rule
43*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
44*fd348426SLi Feng Wang 
4580a6f5c5SLiu Zhe 	@Before
setUp()4680a6f5c5SLiu Zhe 	public void setUp() throws Exception {
4780a6f5c5SLiu Zhe 		app.start(true);
4880a6f5c5SLiu Zhe 		String file = prepareData("sc/SubtotalsSampleFile.ods");
49424494b0SLi Feng Wang 		open(file);
5080a6f5c5SLiu Zhe 		SCTool.selectRange("A1:E7");
5180a6f5c5SLiu Zhe 		app.dispatch(".uno:DataSubTotals");
5280a6f5c5SLiu Zhe 	}
5380a6f5c5SLiu Zhe 
5480a6f5c5SLiu Zhe 	@After
tearDown()5580a6f5c5SLiu Zhe 	public void tearDown() throws Exception {
56424494b0SLi Feng Wang 		app.stop();
5780a6f5c5SLiu Zhe 
5880a6f5c5SLiu Zhe 	}
5980a6f5c5SLiu Zhe 
6080a6f5c5SLiu Zhe 	/**
6180a6f5c5SLiu Zhe 	 * Just support en-US language Verify Average function in SubTotals
6280a6f5c5SLiu Zhe 	 */
6380a6f5c5SLiu Zhe 	@Test
testAverage()6480a6f5c5SLiu Zhe 	public void testAverage() {
6580a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
6680a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25); // In different platform, can
6780a6f5c5SLiu Zhe 		// not focus on same checkbox
6880a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
6980a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
7080a6f5c5SLiu Zhe 		sleep(1);
7180a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
7280a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
7380a6f5c5SLiu Zhe 		sleep(1);
7480a6f5c5SLiu 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" },
7680a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "20", "", "A Average", "" }, { "BS", "20", "4", "B", "Elle" }, { "MS", "10", "3", "B", "Kevin" },
7780a6f5c5SLiu Zhe 				{ "", "15", "", "B Average", "" }, { "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Average", "" }, { "", "18.33333333", "", "Grand Total", "" } },
7880a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
7980a6f5c5SLiu Zhe 	}
8080a6f5c5SLiu Zhe 
8180a6f5c5SLiu Zhe 	/**
8280a6f5c5SLiu Zhe 	 * Just support en-US language Verify Count Numbers only function in
8380a6f5c5SLiu Zhe 	 * SubTotals
8480a6f5c5SLiu Zhe 	 */
8580a6f5c5SLiu Zhe 	@Test
testCountNumbersOnly()8680a6f5c5SLiu Zhe 	public void testCountNumbersOnly() {
8780a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
8880a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
8980a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
9080a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(6); // "Count (numbers only)"
9180a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
9280a6f5c5SLiu Zhe 		sleep(1);
9380a6f5c5SLiu 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" },
9580a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Count", "", "3", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Count", "", "1", "", "" },
9680a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Count", "", "2", "", "" }, { "Grand Total", "", "6", "", "" } },
9780a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
9880a6f5c5SLiu Zhe 	}
9980a6f5c5SLiu Zhe 
10080a6f5c5SLiu Zhe 	/**
10180a6f5c5SLiu Zhe 	 * Just support en-US language Verify Max Numbers function in SubTotals
10280a6f5c5SLiu Zhe 	 */
10380a6f5c5SLiu Zhe 	@Test
testMax()10480a6f5c5SLiu Zhe 	public void testMax() {
10580a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
10680a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
10780a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
10880a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
10980a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
11080a6f5c5SLiu Zhe 		sleep(1);
11180a6f5c5SLiu 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" },
11380a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Max", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Max", "", "5", "", "" },
11480a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Max", "", "3", "", "" }, { "Grand Total", "", "6", "", "" } },
11580a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
11680a6f5c5SLiu Zhe 	}
11780a6f5c5SLiu Zhe 
11880a6f5c5SLiu Zhe 	/**
11980a6f5c5SLiu Zhe 	 * Just support en-US language Verify Min Numbers function in SubTotals
12080a6f5c5SLiu Zhe 	 */
12180a6f5c5SLiu Zhe 	@Test
testMin()12280a6f5c5SLiu Zhe 	public void testMin() {
12380a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
12480a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
12580a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
12680a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(4); // "Min"
12780a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
12880a6f5c5SLiu Zhe 		sleep(1);
12980a6f5c5SLiu 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" },
13180a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Min", "", "2", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Min", "", "5", "", "" },
13280a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Min", "", "1", "", "" }, { "Grand Total", "", "1", "", "" } },
13380a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
13480a6f5c5SLiu Zhe 	}
13580a6f5c5SLiu Zhe 
13680a6f5c5SLiu Zhe 	/**
13780a6f5c5SLiu Zhe 	 * Just support en-US language Verify Product function in SubTotals
13880a6f5c5SLiu Zhe 	 */
13980a6f5c5SLiu Zhe 	@Test
testProduct()14080a6f5c5SLiu Zhe 	public void testProduct() {
14180a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
14280a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
14380a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
14480a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(5); // "Product"
14580a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
14680a6f5c5SLiu Zhe 		sleep(1);
14780a6f5c5SLiu 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" },
14980a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Product", "", "48", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Product", "", "5", "", "" },
15080a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Product", "", "3", "", "" }, { "Grand Total", "", "720", "", "" } },
15180a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
15280a6f5c5SLiu Zhe 	}
15380a6f5c5SLiu Zhe 
15480a6f5c5SLiu Zhe 	/**
15580a6f5c5SLiu Zhe 	 * Just support en-US language Verify StDevP (Population) function in
15680a6f5c5SLiu Zhe 	 * SubTotals
15780a6f5c5SLiu Zhe 	 */
15880a6f5c5SLiu Zhe 	@Test
testStDevPPopulation()15980a6f5c5SLiu Zhe 	public void testStDevPPopulation() {
16080a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
16180a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
16280a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
16380a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(8); // "StDevP (Population)"
16480a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
16580a6f5c5SLiu Zhe 		sleep(1);
16680a6f5c5SLiu 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" },
16880a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS StDev", "", "1.63299316", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS StDev", "", "0", "", "" },
16980a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS StDev", "", "1", "", "" }, { "Grand Total", "", "1.70782513", "", "" } },
17080a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
17180a6f5c5SLiu Zhe 	}
17280a6f5c5SLiu Zhe 
17380a6f5c5SLiu Zhe 	/**
17480a6f5c5SLiu Zhe 	 * Just support en-US language Verify sum function in SubTotals
17580a6f5c5SLiu Zhe 	 */
17680a6f5c5SLiu Zhe 	@Test
testSum()17780a6f5c5SLiu Zhe 	public void testSum() {
17880a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
17980a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
18080a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
18180a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(0); // "Sum"
18280a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
18380a6f5c5SLiu Zhe 		sleep(1);
18480a6f5c5SLiu 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" },
18680a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
18780a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
18880a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
18980a6f5c5SLiu Zhe 	}
19080a6f5c5SLiu Zhe 
19180a6f5c5SLiu Zhe 	/**
19280a6f5c5SLiu Zhe 	 * Just support en-US language Verify Var Sample function in SubTotals
19380a6f5c5SLiu Zhe 	 */
19480a6f5c5SLiu Zhe 	@Test
testVarSample()19580a6f5c5SLiu Zhe 	public void testVarSample() {
19680a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
19780a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
19880a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
19980a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(9); // "Var (Sample)"
20080a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
20180a6f5c5SLiu Zhe 		sleep(1);
20280a6f5c5SLiu 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" },
20480a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Var", "", "4", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Var", "", "#DIV/0!", "", "" },
20580a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Var", "", "2", "", "" }, { "Grand Total", "", "3.5", "", "" } },
20680a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
20780a6f5c5SLiu Zhe 	}
20880a6f5c5SLiu Zhe 
20980a6f5c5SLiu Zhe 	/**
21080a6f5c5SLiu Zhe 	 * Just support en-US language Verify Don't sort in Sub totals
21180a6f5c5SLiu Zhe 	 */
21280a6f5c5SLiu Zhe 	@Test
testDoNotSortOption()21380a6f5c5SLiu Zhe 	public void testDoNotSortOption() {
21480a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
21580a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
21680a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
21780a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
21880a6f5c5SLiu Zhe 		scSubTotalsOptionsTabPage.select();
21980a6f5c5SLiu Zhe 		scSubtotalsPreSortToGroupCheckBox.uncheck();
22080a6f5c5SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
22180a6f5c5SLiu Zhe 		sleep(1);
22280a6f5c5SLiu 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", "" },
22480a6f5c5SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Sum", "" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
22580a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "60", "", "A Sum", "" }, { "MS", "10", "3", "B", "Kevin" }, { "", "10", "", "B Sum", "" },
22680a6f5c5SLiu Zhe 				{ "", "110", "", "Grand Total", "" } }, SCTool.getCellTexts("A1:E12"));
22780a6f5c5SLiu Zhe 	}
22880a6f5c5SLiu Zhe 
22980a6f5c5SLiu Zhe 	/**
23080a6f5c5SLiu Zhe 	 * Just support en-US language Verify SubTotals Options default UI
23180a6f5c5SLiu Zhe 	 */
23280a6f5c5SLiu Zhe 	@Test
testDefaultUI()23380a6f5c5SLiu Zhe 	public void testDefaultUI() {
23480a6f5c5SLiu Zhe 		assertArrayEquals("Group List: ", new String[] { "- none -", "Level", "Code", "No.", "Team", "Name" }, scSubTotalsGroupByListBox.getItemsText());
23580a6f5c5SLiu Zhe 
23680a6f5c5SLiu 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());
24580a6f5c5SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
24680a6f5c5SLiu Zhe 	}
24780a6f5c5SLiu Zhe 
24880a6f5c5SLiu Zhe 	/**
24980a6f5c5SLiu Zhe 	 * Just support en-US language Verify Subtotals using all group
25080a6f5c5SLiu Zhe 	 */
25180a6f5c5SLiu Zhe 	@Test
testUsingAllGroup()25280a6f5c5SLiu Zhe 	public void testUsingAllGroup() {
25380a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.select();
25480a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(1); // "Level"
25580a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
25680a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
25780a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
25880a6f5c5SLiu Zhe 		scSubTotalsGroup2Dialog.select();
25980a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
26080a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
26180a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
26280a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
26380a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
26480a6f5c5SLiu Zhe 		scSubTotalsGroup3Dialog.select();
26580a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(5); // "Name"
26680a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
26780a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
26880a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
26980a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.select();
27080a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
27180a6f5c5SLiu Zhe 		sleep(1);
27280a6f5c5SLiu 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" },
27480a6f5c5SLiu Zhe 				{ "", "20", "", "A Max", "" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "", "Elle Sum" }, { "", "20", "", "B Max", "" },
27580a6f5c5SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "", "Sweet Sum" }, { "", "20", "", "C Max", "" }, { "BS Sum", "", "12", "", "" },
27680a6f5c5SLiu Zhe 				{ "CS", "30", "5", "A", "Ally" }, { "", "30", "", "", "Ally Sum" }, { "", "30", "", "A Max", "" }, { "CS Sum", "", "5", "", "" },
27780a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "10", "", "", "Joker Sum" }, { "", "10", "", "A Max", "" }, { "MS", "10", "3", "B", "Kevin" },
27880a6f5c5SLiu Zhe 				{ "", "10", "", "", "Kevin Sum" }, { "", "10", "", "B Max", "" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
27980a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E23"));
28080a6f5c5SLiu Zhe 	}
28180a6f5c5SLiu Zhe 
28280a6f5c5SLiu Zhe 	/**
28380a6f5c5SLiu Zhe 	 * Just support en-US language Verify Subtotals_Recalculate and refresh
28480a6f5c5SLiu Zhe 	 * results when data rows deleted.
28580a6f5c5SLiu Zhe 	 */
28680a6f5c5SLiu Zhe 	@Test
testRecalculateAfterRowDeleted()28780a6f5c5SLiu Zhe 	public void testRecalculateAfterRowDeleted() {
28880a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,45);
28980a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
29080a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
29180a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
29280a6f5c5SLiu Zhe 		sleep(1);
29380a6f5c5SLiu Zhe 
294424494b0SLi Feng Wang 		assertArrayEquals("Subtotal table not equal before deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
29580a6f5c5SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" },
29680a6f5c5SLiu Zhe 				{ "CS Sum", "", "5", "", "" }, { "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" },
29780a6f5c5SLiu Zhe 				{ "Grand Total", "", "21", "", "" } }, SCTool.getCellTexts("A1:E11"));
29880a6f5c5SLiu Zhe 
29980a6f5c5SLiu Zhe 		SCTool.selectRange("A3:E3");
30080a6f5c5SLiu Zhe 		app.dispatch(".uno:DeleteCell");
30180a6f5c5SLiu Zhe 		scDeleteCellsDeleteRowsRadioButton.check();
30280a6f5c5SLiu Zhe 		scDeleteCellsDialog.ok();
30380a6f5c5SLiu Zhe 		sleep(1);
30480a6f5c5SLiu Zhe 
305424494b0SLi Feng Wang 		assertArrayEquals("Subtotal table not equal after deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
30680a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
30780a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "15", "", "" }, { "", "", "", "", "" } },
30880a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
30980a6f5c5SLiu Zhe 
31080a6f5c5SLiu Zhe 	}
31180a6f5c5SLiu Zhe 
31280a6f5c5SLiu Zhe 	/**
31380a6f5c5SLiu Zhe 	 * Verify Recalculates when source data changed with Average function in
31480a6f5c5SLiu Zhe 	 * SubTotals
31580a6f5c5SLiu Zhe 	 */
31680a6f5c5SLiu Zhe 	@Test
testRecalculateWhenDataChanged()31780a6f5c5SLiu Zhe 	public void testRecalculateWhenDataChanged() {
31880a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
31980a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,25);
32080a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
32180a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
32280a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
32380a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
32480a6f5c5SLiu Zhe 		sleep(1);
32580a6f5c5SLiu Zhe 
32680a6f5c5SLiu Zhe 		SCTool.selectRange("B4");
32780a6f5c5SLiu Zhe 		typeKeys("40" + "<enter>");
32880a6f5c5SLiu 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"));
33180a6f5c5SLiu Zhe 
33280a6f5c5SLiu Zhe 		SCTool.selectRange("B7");
33380a6f5c5SLiu Zhe 		typeKeys("50" + "<enter>");
33480a6f5c5SLiu 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"));
33780a6f5c5SLiu Zhe 
33880a6f5c5SLiu Zhe 		SCTool.selectRange("B9");
33980a6f5c5SLiu Zhe 		typeKeys("30" + "<enter>");
34080a6f5c5SLiu 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"));
34380a6f5c5SLiu Zhe 	}
34480a6f5c5SLiu Zhe }
345