xref: /AOO41X/test/testgui/source/fvt/gui/sc/subtotals/SubtotalsFunctions.java (revision 80a6f5c575dba650469ea4eacf1c8652e4eec583)
1*80a6f5c5SLiu Zhe /**************************************************************
2*80a6f5c5SLiu Zhe  *
3*80a6f5c5SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
4*80a6f5c5SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
5*80a6f5c5SLiu Zhe  * distributed with this work for additional information
6*80a6f5c5SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
7*80a6f5c5SLiu Zhe  * to you under the Apache License, Version 2.0 (the
8*80a6f5c5SLiu Zhe  * "License"); you may not use this file except in compliance
9*80a6f5c5SLiu Zhe  * with the License.  You may obtain a copy of the License at
10*80a6f5c5SLiu Zhe  *
11*80a6f5c5SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
12*80a6f5c5SLiu Zhe  *
13*80a6f5c5SLiu Zhe  * Unless required by applicable law or agreed to in writing,
14*80a6f5c5SLiu Zhe  * software distributed under the License is distributed on an
15*80a6f5c5SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*80a6f5c5SLiu Zhe  * KIND, either express or implied.  See the License for the
17*80a6f5c5SLiu Zhe  * specific language governing permissions and limitations
18*80a6f5c5SLiu Zhe  * under the License.
19*80a6f5c5SLiu Zhe  *
20*80a6f5c5SLiu Zhe  *************************************************************/
21*80a6f5c5SLiu Zhe 
22*80a6f5c5SLiu Zhe /**
23*80a6f5c5SLiu Zhe  *
24*80a6f5c5SLiu Zhe  */
25*80a6f5c5SLiu Zhe package fvt.gui.sc.subtotals;
26*80a6f5c5SLiu Zhe 
27*80a6f5c5SLiu Zhe import static org.junit.Assert.*;
28*80a6f5c5SLiu Zhe import static org.openoffice.test.common.Testspace.*;
29*80a6f5c5SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
30*80a6f5c5SLiu Zhe import static testlib.gui.AppTool.*;
31*80a6f5c5SLiu Zhe import static testlib.gui.UIMap.*;
32*80a6f5c5SLiu Zhe 
33*80a6f5c5SLiu Zhe import org.junit.After;
34*80a6f5c5SLiu Zhe import org.junit.Before;
35*80a6f5c5SLiu Zhe import org.junit.Rule;
36*80a6f5c5SLiu Zhe import org.junit.Test;
37*80a6f5c5SLiu Zhe import org.openoffice.test.common.Logger;
38*80a6f5c5SLiu Zhe 
39*80a6f5c5SLiu Zhe import testlib.gui.SCTool;
40*80a6f5c5SLiu Zhe 
41*80a6f5c5SLiu Zhe /**
42*80a6f5c5SLiu Zhe  *
43*80a6f5c5SLiu Zhe  *
44*80a6f5c5SLiu Zhe  */
45*80a6f5c5SLiu Zhe public class SubtotalsFunctions {
46*80a6f5c5SLiu Zhe 
47*80a6f5c5SLiu Zhe 	@Rule
48*80a6f5c5SLiu Zhe 	public Logger log = Logger.getLogger(this);
49*80a6f5c5SLiu Zhe 
50*80a6f5c5SLiu Zhe 	@Before
51*80a6f5c5SLiu Zhe 	public void setUp() throws Exception {
52*80a6f5c5SLiu Zhe 		app.start(true);
53*80a6f5c5SLiu Zhe 		String file = prepareData("sc/SubtotalsSampleFile.ods");
54*80a6f5c5SLiu Zhe 		app.dispatch(".uno:Open");
55*80a6f5c5SLiu Zhe 		submitOpenDlg(file);
56*80a6f5c5SLiu Zhe 		calc.waitForExistence(10, 2);
57*80a6f5c5SLiu Zhe 		SCTool.selectRange("A1:E7");
58*80a6f5c5SLiu Zhe 		app.dispatch(".uno:DataSubTotals");
59*80a6f5c5SLiu Zhe 	}
60*80a6f5c5SLiu Zhe 
61*80a6f5c5SLiu Zhe 	@After
62*80a6f5c5SLiu Zhe 	public void tearDown() throws Exception {
63*80a6f5c5SLiu Zhe 
64*80a6f5c5SLiu Zhe 	}
65*80a6f5c5SLiu Zhe 
66*80a6f5c5SLiu Zhe 	/**
67*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Average function in SubTotals
68*80a6f5c5SLiu Zhe 	 */
69*80a6f5c5SLiu Zhe 	@Test
70*80a6f5c5SLiu Zhe 	public void testAverage() {
71*80a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
72*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25); // In different platform, can
73*80a6f5c5SLiu Zhe 		// not focus on same checkbox
74*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
75*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
76*80a6f5c5SLiu Zhe 		sleep(1);
77*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
78*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
79*80a6f5c5SLiu Zhe 		sleep(1);
80*80a6f5c5SLiu Zhe 
81*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
82*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "20", "", "A Average", "" }, { "BS", "20", "4", "B", "Elle" }, { "MS", "10", "3", "B", "Kevin" },
83*80a6f5c5SLiu Zhe 				{ "", "15", "", "B Average", "" }, { "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Average", "" }, { "", "18.33333333", "", "Grand Total", "" } },
84*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
85*80a6f5c5SLiu Zhe 	}
86*80a6f5c5SLiu Zhe 
87*80a6f5c5SLiu Zhe 	/**
88*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Count Numbers only function in
89*80a6f5c5SLiu Zhe 	 * SubTotals
90*80a6f5c5SLiu Zhe 	 */
91*80a6f5c5SLiu Zhe 	@Test
92*80a6f5c5SLiu Zhe 	public void testCountNumbersOnly() {
93*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
94*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
95*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
96*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(6); // "Count (numbers only)"
97*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
98*80a6f5c5SLiu Zhe 		sleep(1);
99*80a6f5c5SLiu Zhe 
100*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
101*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Count", "", "3", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Count", "", "1", "", "" },
102*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Count", "", "2", "", "" }, { "Grand Total", "", "6", "", "" } },
103*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
104*80a6f5c5SLiu Zhe 	}
105*80a6f5c5SLiu Zhe 
106*80a6f5c5SLiu Zhe 	/**
107*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Max Numbers function in SubTotals
108*80a6f5c5SLiu Zhe 	 */
109*80a6f5c5SLiu Zhe 	@Test
110*80a6f5c5SLiu Zhe 	public void testMax() {
111*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
112*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
113*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
114*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
115*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
116*80a6f5c5SLiu Zhe 		sleep(1);
117*80a6f5c5SLiu Zhe 
118*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
119*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Max", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Max", "", "5", "", "" },
120*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Max", "", "3", "", "" }, { "Grand Total", "", "6", "", "" } },
121*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
122*80a6f5c5SLiu Zhe 	}
123*80a6f5c5SLiu Zhe 
124*80a6f5c5SLiu Zhe 	/**
125*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Min Numbers function in SubTotals
126*80a6f5c5SLiu Zhe 	 */
127*80a6f5c5SLiu Zhe 	@Test
128*80a6f5c5SLiu Zhe 	public void testMin() {
129*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
130*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
131*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
132*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(4); // "Min"
133*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
134*80a6f5c5SLiu Zhe 		sleep(1);
135*80a6f5c5SLiu Zhe 
136*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
137*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Min", "", "2", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Min", "", "5", "", "" },
138*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Min", "", "1", "", "" }, { "Grand Total", "", "1", "", "" } },
139*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
140*80a6f5c5SLiu Zhe 	}
141*80a6f5c5SLiu Zhe 
142*80a6f5c5SLiu Zhe 	/**
143*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Product function in SubTotals
144*80a6f5c5SLiu Zhe 	 */
145*80a6f5c5SLiu Zhe 	@Test
146*80a6f5c5SLiu Zhe 	public void testProduct() {
147*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
148*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
149*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
150*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(5); // "Product"
151*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
152*80a6f5c5SLiu Zhe 		sleep(1);
153*80a6f5c5SLiu Zhe 
154*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
155*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Product", "", "48", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Product", "", "5", "", "" },
156*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Product", "", "3", "", "" }, { "Grand Total", "", "720", "", "" } },
157*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
158*80a6f5c5SLiu Zhe 	}
159*80a6f5c5SLiu Zhe 
160*80a6f5c5SLiu Zhe 	/**
161*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify StDevP (Population) function in
162*80a6f5c5SLiu Zhe 	 * SubTotals
163*80a6f5c5SLiu Zhe 	 */
164*80a6f5c5SLiu Zhe 	@Test
165*80a6f5c5SLiu Zhe 	public void testStDevPPopulation() {
166*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
167*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
168*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
169*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(8); // "StDevP (Population)"
170*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
171*80a6f5c5SLiu Zhe 		sleep(1);
172*80a6f5c5SLiu Zhe 
173*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
174*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS StDev", "", "1.63299316", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS StDev", "", "0", "", "" },
175*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS StDev", "", "1", "", "" }, { "Grand Total", "", "1.70782513", "", "" } },
176*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
177*80a6f5c5SLiu Zhe 	}
178*80a6f5c5SLiu Zhe 
179*80a6f5c5SLiu Zhe 	/**
180*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify sum function in SubTotals
181*80a6f5c5SLiu Zhe 	 */
182*80a6f5c5SLiu Zhe 	@Test
183*80a6f5c5SLiu Zhe 	public void testSum() {
184*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
185*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
186*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
187*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(0); // "Sum"
188*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
189*80a6f5c5SLiu Zhe 		sleep(1);
190*80a6f5c5SLiu Zhe 
191*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
192*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
193*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
194*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
195*80a6f5c5SLiu Zhe 	}
196*80a6f5c5SLiu Zhe 
197*80a6f5c5SLiu Zhe 	/**
198*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Var Sample function in SubTotals
199*80a6f5c5SLiu Zhe 	 */
200*80a6f5c5SLiu Zhe 	@Test
201*80a6f5c5SLiu Zhe 	public void testVarSample() {
202*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
203*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
204*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
205*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(9); // "Var (Sample)"
206*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
207*80a6f5c5SLiu Zhe 		sleep(1);
208*80a6f5c5SLiu Zhe 
209*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "BS", "20", "6", "C", "Sweet" },
210*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Var", "", "4", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Var", "", "#DIV/0!", "", "" },
211*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Var", "", "2", "", "" }, { "Grand Total", "", "3.5", "", "" } },
212*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
213*80a6f5c5SLiu Zhe 	}
214*80a6f5c5SLiu Zhe 
215*80a6f5c5SLiu Zhe 	/**
216*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Don't sort in Sub totals
217*80a6f5c5SLiu Zhe 	 */
218*80a6f5c5SLiu Zhe 	@Test
219*80a6f5c5SLiu Zhe 	public void testDoNotSortOption() {
220*80a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
221*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
222*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
223*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
224*80a6f5c5SLiu Zhe 		scSubTotalsOptionsTabPage.select();
225*80a6f5c5SLiu Zhe 		scSubtotalsPreSortToGroupCheckBox.uncheck();
226*80a6f5c5SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
227*80a6f5c5SLiu Zhe 		sleep(1);
228*80a6f5c5SLiu Zhe 
229*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "B Sum", "" },
230*80a6f5c5SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "C Sum", "" }, { "BS", "20", "2", "A", "Chcomic" }, { "CS", "30", "5", "A", "Ally" },
231*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "60", "", "A Sum", "" }, { "MS", "10", "3", "B", "Kevin" }, { "", "10", "", "B Sum", "" },
232*80a6f5c5SLiu Zhe 				{ "", "110", "", "Grand Total", "" } }, SCTool.getCellTexts("A1:E12"));
233*80a6f5c5SLiu Zhe 	}
234*80a6f5c5SLiu Zhe 
235*80a6f5c5SLiu Zhe 	/**
236*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify SubTotals Options default UI
237*80a6f5c5SLiu Zhe 	 */
238*80a6f5c5SLiu Zhe 	@Test
239*80a6f5c5SLiu Zhe 	public void testDefaultUI() {
240*80a6f5c5SLiu Zhe 		assertArrayEquals("Group List: ", new String[] { "- none -", "Level", "Code", "No.", "Team", "Name" }, scSubTotalsGroupByListBox.getItemsText());
241*80a6f5c5SLiu Zhe 
242*80a6f5c5SLiu Zhe 		scSubTotalsOptionsTabPage.select();
243*80a6f5c5SLiu Zhe 		assertFalse(scSubtotalsInsertPageBreakCheckBox.isChecked());
244*80a6f5c5SLiu Zhe 		assertFalse(scSubtotalsCaseSensitiveCheckBox.isChecked());
245*80a6f5c5SLiu Zhe 		assertTrue(scSubtotalsPreSortToGroupCheckBox.isChecked());
246*80a6f5c5SLiu Zhe 		assertTrue(scSubtotalSortAscendingRadioButton.isChecked());
247*80a6f5c5SLiu Zhe 		assertFalse(scSubtotalSortDescendingRadioButton.isChecked());
248*80a6f5c5SLiu Zhe 		assertFalse(scSubtotalsIncludeFormatsCheckBox.isChecked());
249*80a6f5c5SLiu Zhe 		assertFalse(scSubtotalsCustomSortOrderCheckBox.isChecked());
250*80a6f5c5SLiu Zhe 		assertFalse(scSubtotalsCustomSortListBox.isEnabled());
251*80a6f5c5SLiu Zhe 		scSubTotalsOptionsTabPage.ok();
252*80a6f5c5SLiu Zhe 	}
253*80a6f5c5SLiu Zhe 
254*80a6f5c5SLiu Zhe 	/**
255*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Subtotals using all group
256*80a6f5c5SLiu Zhe 	 */
257*80a6f5c5SLiu Zhe 	@Test
258*80a6f5c5SLiu Zhe 	public void testUsingAllGroup() {
259*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.select();
260*80a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(1); // "Level"
261*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 45);
262*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
263*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
264*80a6f5c5SLiu Zhe 		scSubTotalsGroup2Dialog.select();
265*80a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
266*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
267*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
268*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
269*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(3); // "Max"
270*80a6f5c5SLiu Zhe 		scSubTotalsGroup3Dialog.select();
271*80a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(5); // "Name"
272*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10, 25);
273*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
274*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
275*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.select();
276*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
277*80a6f5c5SLiu Zhe 		sleep(1);
278*80a6f5c5SLiu Zhe 
279*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "2", "A", "Chcomic" }, { "", "20", "", "", "Chcomic Sum" },
280*80a6f5c5SLiu Zhe 				{ "", "20", "", "A Max", "" }, { "BS", "20", "4", "B", "Elle" }, { "", "20", "", "", "Elle Sum" }, { "", "20", "", "B Max", "" },
281*80a6f5c5SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "", "20", "", "", "Sweet Sum" }, { "", "20", "", "C Max", "" }, { "BS Sum", "", "12", "", "" },
282*80a6f5c5SLiu Zhe 				{ "CS", "30", "5", "A", "Ally" }, { "", "30", "", "", "Ally Sum" }, { "", "30", "", "A Max", "" }, { "CS Sum", "", "5", "", "" },
283*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "", "10", "", "", "Joker Sum" }, { "", "10", "", "A Max", "" }, { "MS", "10", "3", "B", "Kevin" },
284*80a6f5c5SLiu Zhe 				{ "", "10", "", "", "Kevin Sum" }, { "", "10", "", "B Max", "" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "21", "", "" } },
285*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E23"));
286*80a6f5c5SLiu Zhe 	}
287*80a6f5c5SLiu Zhe 
288*80a6f5c5SLiu Zhe 	/**
289*80a6f5c5SLiu Zhe 	 * Just support en-US language Verify Subtotals_Recalculate and refresh
290*80a6f5c5SLiu Zhe 	 * results when data rows deleted.
291*80a6f5c5SLiu Zhe 	 */
292*80a6f5c5SLiu Zhe 	@Test
293*80a6f5c5SLiu Zhe 	public void testRecalculateAfterRowDeleted() {
294*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,45);
295*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(2);
296*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(2); // "No."
297*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
298*80a6f5c5SLiu Zhe 		sleep(1);
299*80a6f5c5SLiu Zhe 
300*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table before deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
301*80a6f5c5SLiu Zhe 				{ "BS", "20", "6", "C", "Sweet" }, { "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "12", "", "" }, { "CS", "30", "5", "A", "Ally" },
302*80a6f5c5SLiu Zhe 				{ "CS Sum", "", "5", "", "" }, { "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" },
303*80a6f5c5SLiu Zhe 				{ "Grand Total", "", "21", "", "" } }, SCTool.getCellTexts("A1:E11"));
304*80a6f5c5SLiu Zhe 
305*80a6f5c5SLiu Zhe 		SCTool.selectRange("A3:E3");
306*80a6f5c5SLiu Zhe 		app.dispatch(".uno:DeleteCell");
307*80a6f5c5SLiu Zhe 		scDeleteCellsDeleteRowsRadioButton.check();
308*80a6f5c5SLiu Zhe 		scDeleteCellsDialog.ok();
309*80a6f5c5SLiu Zhe 		sleep(1);
310*80a6f5c5SLiu Zhe 
311*80a6f5c5SLiu Zhe 		assertArrayEquals("Subtotal table after deleting row", new String[][] { { "Level", "Code", "No.", "Team", "Name" }, { "BS", "20", "4", "B", "Elle" },
312*80a6f5c5SLiu Zhe 				{ "BS", "20", "2", "A", "Chcomic" }, { "BS Sum", "", "6", "", "" }, { "CS", "30", "5", "A", "Ally" }, { "CS Sum", "", "5", "", "" },
313*80a6f5c5SLiu Zhe 				{ "MS", "10", "1", "A", "Joker" }, { "MS", "10", "3", "B", "Kevin" }, { "MS Sum", "", "4", "", "" }, { "Grand Total", "", "15", "", "" }, { "", "", "", "", "" } },
314*80a6f5c5SLiu Zhe 				SCTool.getCellTexts("A1:E11"));
315*80a6f5c5SLiu Zhe 
316*80a6f5c5SLiu Zhe 	}
317*80a6f5c5SLiu Zhe 
318*80a6f5c5SLiu Zhe 	/**
319*80a6f5c5SLiu Zhe 	 * Verify Recalculates when source data changed with Average function in
320*80a6f5c5SLiu Zhe 	 * SubTotals
321*80a6f5c5SLiu Zhe 	 */
322*80a6f5c5SLiu Zhe 	@Test
323*80a6f5c5SLiu Zhe 	public void testRecalculateWhenDataChanged() {
324*80a6f5c5SLiu Zhe 		scSubTotalsGroupByListBox.select(4); // "Team"
325*80a6f5c5SLiu Zhe 		// SCCalcSubTotalForColumns.click(10,25);
326*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.select(1);
327*80a6f5c5SLiu Zhe 		scCalcSubTotalForColumns.check(1); // "Code"
328*80a6f5c5SLiu Zhe 		scCalcSubTotolsFuncionList.select(2); // "Average"
329*80a6f5c5SLiu Zhe 		scSubTotalsGroup1Dialog.ok();
330*80a6f5c5SLiu Zhe 		sleep(1);
331*80a6f5c5SLiu Zhe 
332*80a6f5c5SLiu Zhe 		SCTool.selectRange("B4");
333*80a6f5c5SLiu Zhe 		typeKeys("40" + "<enter>");
334*80a6f5c5SLiu Zhe 		sleep(1);
335*80a6f5c5SLiu Zhe 		assertEquals("30", SCTool.getCellText("B5"));
336*80a6f5c5SLiu Zhe 		assertEquals("23.33333333", SCTool.getCellText("B11"));
337*80a6f5c5SLiu Zhe 
338*80a6f5c5SLiu Zhe 		SCTool.selectRange("B7");
339*80a6f5c5SLiu Zhe 		typeKeys("50" + "<enter>");
340*80a6f5c5SLiu Zhe 		sleep(1);
341*80a6f5c5SLiu Zhe 		assertEquals("35", SCTool.getCellText("B8"));
342*80a6f5c5SLiu Zhe 		assertEquals("30", SCTool.getCellText("B11"));
343*80a6f5c5SLiu Zhe 
344*80a6f5c5SLiu Zhe 		SCTool.selectRange("B9");
345*80a6f5c5SLiu Zhe 		typeKeys("30" + "<enter>");
346*80a6f5c5SLiu Zhe 		sleep(1);
347*80a6f5c5SLiu Zhe 		assertEquals("30", SCTool.getCellText("B10"));
348*80a6f5c5SLiu Zhe 		assertEquals("31.66666667", SCTool.getCellText("B11"));
349*80a6f5c5SLiu Zhe 	}
350*80a6f5c5SLiu Zhe }
351