104bad30fSLiu Zhe /**************************************************************
204bad30fSLiu Zhe  *
304bad30fSLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
404bad30fSLiu Zhe  * or more contributor license agreements.  See the NOTICE file
504bad30fSLiu Zhe  * distributed with this work for additional information
604bad30fSLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
704bad30fSLiu Zhe  * to you under the Apache License, Version 2.0 (the
804bad30fSLiu Zhe  * "License"); you may not use this file except in compliance
904bad30fSLiu Zhe  * with the License.  You may obtain a copy of the License at
1004bad30fSLiu Zhe  *
1104bad30fSLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1204bad30fSLiu Zhe  *
1304bad30fSLiu Zhe  * Unless required by applicable law or agreed to in writing,
1404bad30fSLiu Zhe  * software distributed under the License is distributed on an
1504bad30fSLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1604bad30fSLiu Zhe  * KIND, either express or implied.  See the License for the
1704bad30fSLiu Zhe  * specific language governing permissions and limitations
1804bad30fSLiu Zhe  * under the License.
1904bad30fSLiu Zhe  *
2004bad30fSLiu Zhe  *************************************************************/
2104bad30fSLiu Zhe 
2280a6f5c5SLiu Zhe package fvt.gui.sc.validity;
2304bad30fSLiu Zhe 
2422a14f28SLiu Zhe import static org.junit.Assert.*;
25b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
2695269d92SLiu Zhe import static testlib.gui.UIMap.*;
2704bad30fSLiu Zhe 
2804bad30fSLiu Zhe import org.junit.After;
2904bad30fSLiu Zhe import org.junit.Before;
3004bad30fSLiu Zhe import org.junit.Ignore;
3122a14f28SLiu Zhe import org.junit.Rule;
3204bad30fSLiu Zhe import org.junit.Test;
3322a14f28SLiu Zhe import org.openoffice.test.common.Logger;
3404bad30fSLiu Zhe 
35b4d2d410SLiu Zhe import testlib.gui.SCTool;
3604bad30fSLiu Zhe 
3704bad30fSLiu Zhe public class ValidityDialogSetting {
3804bad30fSLiu Zhe 
3904bad30fSLiu Zhe 	@Rule
4022a14f28SLiu Zhe 	public Logger log = Logger.getLogger(this);
4104bad30fSLiu Zhe 
4204bad30fSLiu Zhe 	@Before
4304bad30fSLiu Zhe 	public void setUp() throws Exception {
444d3496b1SLiu Zhe 		app.start(true);
4504bad30fSLiu Zhe 
4604bad30fSLiu Zhe 		// New a spreadsheet, select cell range, open Validity dialog
473816404dSLiu Zhe 		app.dispatch("private:factory/scalc");
48d8cae8adSLiu Zhe 		calc.waitForExistence(10, 2);
49b4d2d410SLiu Zhe 		SCTool.selectRange("A1:C5");
503816404dSLiu Zhe 		app.dispatch(".uno:Validation");
5104bad30fSLiu Zhe 	}
5204bad30fSLiu Zhe 
5304bad30fSLiu Zhe 	@After
5404bad30fSLiu Zhe 	public void tearDown() throws Exception {
5522a14f28SLiu Zhe 
5604bad30fSLiu Zhe 	}
5704bad30fSLiu Zhe 
5804bad30fSLiu Zhe 	/**
5904bad30fSLiu Zhe 	 * test Allow not between Date type in Validity.
6004bad30fSLiu Zhe 	 */
6104bad30fSLiu Zhe 	@Test
6204bad30fSLiu Zhe 	public void testAllowDateNotBetween() {
63b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
64b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(3); // "Date"
65b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(7); // "not between"
66b4d2d410SLiu Zhe 		scValiditySourceInput.setText("01/01/08");
67b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("03/01/08");
68b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
69b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
70b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
71b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
72b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
73b4d2d410SLiu Zhe 
74b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
75b4d2d410SLiu Zhe 		scInputBarInput.activate();
7604bad30fSLiu Zhe 		typeKeys("12/31/07");
7704bad30fSLiu Zhe 		typeKeys("<enter>");
78b4d2d410SLiu Zhe 		assertEquals("12/31/07", SCTool.getCellText("A1"));
7904bad30fSLiu Zhe 
80b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
81b4d2d410SLiu Zhe 		scInputBarInput.activate();
8204bad30fSLiu Zhe 		typeKeys("03/02/08");
8304bad30fSLiu Zhe 		typeKeys("<enter>");
84b4d2d410SLiu Zhe 		assertEquals("03/02/08", SCTool.getCellText("A2"));
8504bad30fSLiu Zhe 
86b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
87b4d2d410SLiu Zhe 		scInputBarInput.activate();
8804bad30fSLiu Zhe 		typeKeys("01/01/08");
8904bad30fSLiu Zhe 		typeKeys("<enter>");
90*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
91*57caf934SLiu Zhe 		activeMsgBox.ok();
92b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
9304bad30fSLiu Zhe 
94b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
95b4d2d410SLiu Zhe 		scInputBarInput.activate();
9604bad30fSLiu Zhe 		typeKeys("03/01/08");
9704bad30fSLiu Zhe 		typeKeys("<enter>");
98*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
99*57caf934SLiu Zhe 		activeMsgBox.ok();
100b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
10104bad30fSLiu Zhe 
102b4d2d410SLiu Zhe 		SCTool.selectRange("A5");
103b4d2d410SLiu Zhe 		scInputBarInput.activate();
10404bad30fSLiu Zhe 		typeKeys("01/02/08");
10504bad30fSLiu Zhe 		typeKeys("<enter>");
106*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
107*57caf934SLiu Zhe 		activeMsgBox.ok();
108b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A5"));
10904bad30fSLiu Zhe 
110b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
111b4d2d410SLiu Zhe 		scInputBarInput.activate();
11204bad30fSLiu Zhe 		typeKeys("02/29/08");
11304bad30fSLiu Zhe 		typeKeys("<enter>");
114*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
115*57caf934SLiu Zhe 		activeMsgBox.ok();
116b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
11704bad30fSLiu Zhe 
118b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
119b4d2d410SLiu Zhe 		scInputBarInput.activate();
12004bad30fSLiu Zhe 		typeKeys("test");
12104bad30fSLiu Zhe 		typeKeys("<enter>");
122*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
123*57caf934SLiu Zhe 		activeMsgBox.ok();
124b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
12504bad30fSLiu Zhe 
126b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
127b4d2d410SLiu Zhe 		scInputBarInput.activate();
12804bad30fSLiu Zhe 		typeKeys("39448");
12904bad30fSLiu Zhe 		typeKeys("<enter>");
130*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
131*57caf934SLiu Zhe 		activeMsgBox.ok();
132b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
13304bad30fSLiu Zhe 	}
13404bad30fSLiu Zhe 
13504bad30fSLiu Zhe 	/**
13604bad30fSLiu Zhe 	 * test Allow Decimal equal in Validity.
13704bad30fSLiu Zhe 	 */
13804bad30fSLiu Zhe 	@Test
13904bad30fSLiu Zhe 	public void testAllowDecimalEqual() {
14004bad30fSLiu Zhe 
141b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
142b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
143b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
144b4d2d410SLiu Zhe 		scValiditySourceInput.setText("0.33333333");
145b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
146b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
147b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
148b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
149b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
150b4d2d410SLiu Zhe 
151b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
152b4d2d410SLiu Zhe 		scInputBarInput.activate();
15304bad30fSLiu Zhe 		typeKeys("0.33333333");
15404bad30fSLiu Zhe 		typeKeys("<enter>");
155b4d2d410SLiu Zhe 		assertEquals("0.33333333", SCTool.getCellText("A1"));
15604bad30fSLiu Zhe 
157b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
158b4d2d410SLiu Zhe 		scInputBarInput.activate();
15904bad30fSLiu Zhe 		typeKeys("=1/3");
16004bad30fSLiu Zhe 		typeKeys("<enter>");
161*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
162*57caf934SLiu Zhe 		activeMsgBox.ok();
163b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
16404bad30fSLiu Zhe 
165b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
166b4d2d410SLiu Zhe 		scInputBarInput.activate();
16704bad30fSLiu Zhe 		typeKeys("0.3");
16804bad30fSLiu Zhe 		typeKeys("<enter>");
169*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
170*57caf934SLiu Zhe 		activeMsgBox.ok();
171b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
17204bad30fSLiu Zhe 
173b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
174b4d2d410SLiu Zhe 		scInputBarInput.activate();
17504bad30fSLiu Zhe 		typeKeys("0.333333333");
17604bad30fSLiu Zhe 		typeKeys("<enter>");
177*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
178*57caf934SLiu Zhe 		activeMsgBox.ok();
179b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
18004bad30fSLiu Zhe 
181b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
182b4d2d410SLiu Zhe 		scInputBarInput.activate();
18304bad30fSLiu Zhe 		typeKeys("test");
18404bad30fSLiu Zhe 		typeKeys("<enter>");
185*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
186*57caf934SLiu Zhe 		activeMsgBox.ok();
187b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
18804bad30fSLiu Zhe 	}
18904bad30fSLiu Zhe 
19004bad30fSLiu Zhe 	/**
19122a14f28SLiu Zhe 	 * test Allow Text length, greater than or equal to in Validity.
19204bad30fSLiu Zhe 	 */
19304bad30fSLiu Zhe 	@Test
19404bad30fSLiu Zhe 	public void testAllowGreaterTextLength() {
19504bad30fSLiu Zhe 
196b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
197b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
198b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
199b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
200b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
201b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
202b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
203b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
204b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
205b4d2d410SLiu Zhe 
206b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
207b4d2d410SLiu Zhe 		scInputBarInput.activate();
20804bad30fSLiu Zhe 		typeKeys("testtesttesttest");
20904bad30fSLiu Zhe 		typeKeys("<enter>");
210b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
21104bad30fSLiu Zhe 
212b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
213b4d2d410SLiu Zhe 		scInputBarInput.activate();
21404bad30fSLiu Zhe 		typeKeys("test test ");
21504bad30fSLiu Zhe 		typeKeys("<enter>");
216b4d2d410SLiu Zhe 		assertEquals("test test ", SCTool.getCellText("A2"));
21704bad30fSLiu Zhe 
218b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
219b4d2d410SLiu Zhe 		scInputBarInput.activate();
22004bad30fSLiu Zhe 		typeKeys(" ");
22104bad30fSLiu Zhe 		typeKeys("<enter>");
222*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
223*57caf934SLiu Zhe 		activeMsgBox.ok();
224b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
22504bad30fSLiu Zhe 
226b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
227b4d2d410SLiu Zhe 		scInputBarInput.activate();
22804bad30fSLiu Zhe 		typeKeys("Testatest");
22904bad30fSLiu Zhe 		typeKeys("<enter>");
230*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
231*57caf934SLiu Zhe 		activeMsgBox.ok();
232b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
23304bad30fSLiu Zhe 	}
23404bad30fSLiu Zhe 
23504bad30fSLiu Zhe 	/**
23622a14f28SLiu Zhe 	 * test Allow Text length, less than in Validity.
23704bad30fSLiu Zhe 	 */
23804bad30fSLiu Zhe 	@Ignore("Bug 93128")
23904bad30fSLiu Zhe 	public void testAllowLessThanTextLength() {
24004bad30fSLiu Zhe 
2413816404dSLiu Zhe 		app.dispatch(".uno:Validation");
24204bad30fSLiu Zhe 
243b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
244b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
245b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(1); // "less than"
246b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
247b4d2d410SLiu Zhe 
248b4d2d410SLiu Zhe 		scValidityInputHelpTabPage.select();
249b4d2d410SLiu Zhe 		scValidityInputHelpCheckbox.check();
250b4d2d410SLiu Zhe 		scValidityInputHelpTitle.setText("Help Info Title");
251b4d2d410SLiu Zhe 		scValidityHelpMessage.setText("help info");
252b4d2d410SLiu Zhe 
253b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
254b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
255b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select("Information");
256b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Notes to enter");
257b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
258b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
259b4d2d410SLiu Zhe 
260b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
261b4d2d410SLiu Zhe 		scInputBarInput.activate();
26204bad30fSLiu Zhe 		typeKeys("testtesttesttest<enter>");
263*57caf934SLiu Zhe 		activeMsgBox.ok();
264b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
26504bad30fSLiu Zhe 
266b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
267b4d2d410SLiu Zhe 		scInputBarInput.activate();
26804bad30fSLiu Zhe 		typeKeys("sfsafsddddddd<enter>");
269*57caf934SLiu Zhe 		activeMsgBox.cancel();
270b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
27104bad30fSLiu Zhe 
272b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
273b4d2d410SLiu Zhe 		scInputBarInput.activate();
27404bad30fSLiu Zhe 		typeKeys("10<enter>");
275b4d2d410SLiu Zhe 		assertEquals("10", SCTool.getCellText("A2"));
27604bad30fSLiu Zhe 
277b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
278b4d2d410SLiu Zhe 		scInputBarInput.activate();
27904bad30fSLiu Zhe 		typeKeys("ok<enter>");
280b4d2d410SLiu Zhe 		assertEquals("ok", SCTool.getCellText("A3"));
28104bad30fSLiu Zhe 	}
28204bad30fSLiu Zhe 
28304bad30fSLiu Zhe 	/**
28404bad30fSLiu Zhe 	 * test Allow list.
28504bad30fSLiu Zhe 	 */
28604bad30fSLiu Zhe 	@Test
28704bad30fSLiu Zhe 	public void testAllowListSpecialChar() {
28804bad30fSLiu Zhe 
289b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
290b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(6); // "List"
291b4d2d410SLiu Zhe 		scValidityEntries.focus();
29204bad30fSLiu Zhe 		typeKeys("a");
29304bad30fSLiu Zhe 		typeKeys("<enter>");
29404bad30fSLiu Zhe 		typeKeys("b");
295b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
296b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
297b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
298b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
299b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
300b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
30104bad30fSLiu Zhe 
3024d3496b1SLiu Zhe 		// These codes are not stable: start
30322a14f28SLiu Zhe 		// calc.rightClick(1, 1);
30422a14f28SLiu Zhe 		// typeKeys("<shift s>");
30522a14f28SLiu Zhe 		// typeKeys("<down><enter>"); // Choose a
30622a14f28SLiu Zhe 		// sleep(2); // if no sleep, error occur
3074d3496b1SLiu Zhe 		// These codes are not stable: end
308b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
309b4d2d410SLiu Zhe 		scInputBarInput.activate();
3104d3496b1SLiu Zhe 		typeKeys("a<enter>");
311b4d2d410SLiu Zhe 		assertEquals("a", SCTool.getCellText("A1"));
31204bad30fSLiu Zhe 
313b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
314b4d2d410SLiu Zhe 		scInputBarInput.activate();
31504bad30fSLiu Zhe 		typeKeys("test");
31604bad30fSLiu Zhe 		typeKeys("<enter>");
317*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
318*57caf934SLiu Zhe 		activeMsgBox.ok();
319b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
32004bad30fSLiu Zhe 	}
32104bad30fSLiu Zhe 
32204bad30fSLiu Zhe 	/**
32322a14f28SLiu Zhe 	 * test Allow time between in Validity.
32404bad30fSLiu Zhe 	 */
32504bad30fSLiu Zhe 	@Test
32604bad30fSLiu Zhe 	public void testAllowTimeBetween() {
32704bad30fSLiu Zhe 
328b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
329b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
330b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(6); // "between"
331b4d2d410SLiu Zhe 		scValiditySourceInput.setText("27:00");
332b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("21:00");
333b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
334b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
335b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
336b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
337b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
338b4d2d410SLiu Zhe 
339b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
340b4d2d410SLiu Zhe 		scInputBarInput.activate();
34104bad30fSLiu Zhe 		typeKeys("21:00");
34204bad30fSLiu Zhe 		typeKeys("<enter>");
343b4d2d410SLiu Zhe 		assertEquals("09:00:00 PM", SCTool.getCellText("A1"));
34404bad30fSLiu Zhe 
345b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
346b4d2d410SLiu Zhe 		scInputBarInput.activate();
34704bad30fSLiu Zhe 		typeKeys("27:00");
34804bad30fSLiu Zhe 		typeKeys("<enter>");
349b4d2d410SLiu Zhe 		assertEquals("27:00:00", SCTool.getCellText("A2"));
35004bad30fSLiu Zhe 
351b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
352b4d2d410SLiu Zhe 		scInputBarInput.activate();
35304bad30fSLiu Zhe 		typeKeys("1.125");
35404bad30fSLiu Zhe 		typeKeys("<enter>");
355b4d2d410SLiu Zhe 		assertEquals("1.125", SCTool.getCellText("A3"));
35604bad30fSLiu Zhe 
357b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
358b4d2d410SLiu Zhe 		scInputBarInput.activate();
35904bad30fSLiu Zhe 		typeKeys("0.875");
36004bad30fSLiu Zhe 		typeKeys("<enter>");
361b4d2d410SLiu Zhe 		assertEquals("0.875", SCTool.getCellText("A4"));
36204bad30fSLiu Zhe 
363b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
364b4d2d410SLiu Zhe 		scInputBarInput.activate();
36504bad30fSLiu Zhe 		typeKeys("03:00:01");
36604bad30fSLiu Zhe 		typeKeys("<enter>");
367*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
368*57caf934SLiu Zhe 		activeMsgBox.ok();
369b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
37004bad30fSLiu Zhe 
371b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
372b4d2d410SLiu Zhe 		scInputBarInput.activate();
37304bad30fSLiu Zhe 		typeKeys("20:59:59");
37404bad30fSLiu Zhe 		typeKeys("<enter>");
375*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
376*57caf934SLiu Zhe 		activeMsgBox.ok();
377b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
37804bad30fSLiu Zhe 
379b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
380b4d2d410SLiu Zhe 		scInputBarInput.activate();
38104bad30fSLiu Zhe 		typeKeys("1.126");
38204bad30fSLiu Zhe 		typeKeys("<enter>");
383*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
384*57caf934SLiu Zhe 		activeMsgBox.ok();
385b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
38604bad30fSLiu Zhe 
387b4d2d410SLiu Zhe 		SCTool.selectRange("B4");
388b4d2d410SLiu Zhe 		scInputBarInput.activate();
38904bad30fSLiu Zhe 		typeKeys("0.874");
39004bad30fSLiu Zhe 		typeKeys("<enter>");
391*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
392*57caf934SLiu Zhe 		activeMsgBox.ok();
393b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B4"));
39404bad30fSLiu Zhe 
395b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
396b4d2d410SLiu Zhe 		scInputBarInput.activate();
39704bad30fSLiu Zhe 		typeKeys("test");
39804bad30fSLiu Zhe 		typeKeys("<enter>");
399*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
400*57caf934SLiu Zhe 		activeMsgBox.ok();
401b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
40204bad30fSLiu Zhe 
403b4d2d410SLiu Zhe 		SCTool.selectRange("C2");
404b4d2d410SLiu Zhe 		scInputBarInput.activate();
40504bad30fSLiu Zhe 		typeKeys("24:00");
40604bad30fSLiu Zhe 		typeKeys("<enter>");
407b4d2d410SLiu Zhe 		assertEquals("24:00:00", SCTool.getCellText("C2"));
40804bad30fSLiu Zhe 
409b4d2d410SLiu Zhe 		SCTool.selectRange("C3");
410b4d2d410SLiu Zhe 		scInputBarInput.activate();
41104bad30fSLiu Zhe 		typeKeys("12:00");
41204bad30fSLiu Zhe 		typeKeys("<enter>");
413*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
414*57caf934SLiu Zhe 		activeMsgBox.ok();
415b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C3"));
41604bad30fSLiu Zhe 	}
41704bad30fSLiu Zhe 
41804bad30fSLiu Zhe 	/**
41922a14f28SLiu Zhe 	 * test Allow time Greater than and equal to in Validity.
42004bad30fSLiu Zhe 	 */
42104bad30fSLiu Zhe 	@Test
42204bad30fSLiu Zhe 	public void testAllowTimeGreaterThan() {
42304bad30fSLiu Zhe 
424b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
425b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
426b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
427b4d2d410SLiu Zhe 		scValiditySourceInput.setText("8:00");
42804bad30fSLiu Zhe 
429b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
430b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
431b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(1); // "Warning"
43204bad30fSLiu Zhe 
433b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("warning to enter");
434b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
435b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
43604bad30fSLiu Zhe 
437b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
438b4d2d410SLiu Zhe 		scInputBarInput.activate();
43904bad30fSLiu Zhe 		typeKeys("7:30");
44004bad30fSLiu Zhe 		typeKeys("<enter>");
441*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
442*57caf934SLiu Zhe 		activeMsgBox.ok();
443b4d2d410SLiu Zhe 		assertEquals("07:30:00 AM", SCTool.getCellText("A1"));
44404bad30fSLiu Zhe 
445b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
446b4d2d410SLiu Zhe 		scInputBarInput.activate();
44704bad30fSLiu Zhe 		typeKeys("6:00");
44804bad30fSLiu Zhe 		typeKeys("<enter>");
449*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
450*57caf934SLiu Zhe 		activeMsgBox.cancel();
451b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
45204bad30fSLiu Zhe 
453b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
454b4d2d410SLiu Zhe 		scInputBarInput.activate();
45504bad30fSLiu Zhe 		typeKeys("8:00");
45604bad30fSLiu Zhe 		typeKeys("<enter>");
457b4d2d410SLiu Zhe 		assertEquals("08:00:00 AM", SCTool.getCellText("A3"));
45804bad30fSLiu Zhe 	}
45904bad30fSLiu Zhe 
46004bad30fSLiu Zhe 	/**
46104bad30fSLiu Zhe 	 * test Allow whole number, less than or equal to in Validity.
46204bad30fSLiu Zhe 	 */
46304bad30fSLiu Zhe 	@Test
46404bad30fSLiu Zhe 	public void testAllowWholeNumLessThan() {
46504bad30fSLiu Zhe 
466b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
467b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(1); // "Whole Numbers"
468b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(3); // "less than or equal"
469b4d2d410SLiu Zhe 		scValiditySourceInput.setText("100");
470b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
471b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
472b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
473b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
474b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
475b4d2d410SLiu Zhe 
476b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
477b4d2d410SLiu Zhe 		scInputBarInput.activate();
47804bad30fSLiu Zhe 		typeKeys("99");
47904bad30fSLiu Zhe 		typeKeys("<enter>");
480b4d2d410SLiu Zhe 		assertEquals("99", SCTool.getCellText("A1"));
48104bad30fSLiu Zhe 
482b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
483b4d2d410SLiu Zhe 		scInputBarInput.activate();
48404bad30fSLiu Zhe 		typeKeys("100");
48504bad30fSLiu Zhe 		typeKeys("<enter>");
486b4d2d410SLiu Zhe 		assertEquals("100", SCTool.getCellText("A2"));
48704bad30fSLiu Zhe 
488b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
489b4d2d410SLiu Zhe 		scInputBarInput.activate();
49004bad30fSLiu Zhe 		typeKeys("101");
49104bad30fSLiu Zhe 		typeKeys("<enter>");
492*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
493*57caf934SLiu Zhe 		activeMsgBox.ok();
494b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
49504bad30fSLiu Zhe 
496b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
497b4d2d410SLiu Zhe 		scInputBarInput.activate();
49804bad30fSLiu Zhe 		typeKeys("45.5");
49904bad30fSLiu Zhe 		typeKeys("<enter>");
500*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
501*57caf934SLiu Zhe 		activeMsgBox.ok();
502b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
50304bad30fSLiu Zhe 
504b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
505b4d2d410SLiu Zhe 		scInputBarInput.activate();
50604bad30fSLiu Zhe 		typeKeys("test");
50704bad30fSLiu Zhe 		typeKeys("<enter>");
508*57caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
509*57caf934SLiu Zhe 		activeMsgBox.ok();
510b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
51104bad30fSLiu Zhe 	}
51204bad30fSLiu Zhe 
51304bad30fSLiu Zhe 	/**
51404bad30fSLiu Zhe 	 * test default message of Error Alert in Validity.
51504bad30fSLiu Zhe 	 */
51604bad30fSLiu Zhe 	@Test
51704bad30fSLiu Zhe 	public void testDefaultErrorAlertMessage() {
51804bad30fSLiu Zhe 
519b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
520b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
521b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
522b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
52304bad30fSLiu Zhe 
524b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
525b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
526b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
527b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
52804bad30fSLiu Zhe 
529b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
530b4d2d410SLiu Zhe 		scInputBarInput.activate();
53104bad30fSLiu Zhe 		typeKeys("13");
53204bad30fSLiu Zhe 		typeKeys("<enter>");
533*57caf934SLiu Zhe 		assertEquals("OpenOffice.org Calc", activeMsgBox.getCaption());
53422a14f28SLiu Zhe 		// assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not
53522a14f28SLiu Zhe 		// verify in multi-language
536*57caf934SLiu Zhe 		activeMsgBox.ok();
537b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
53804bad30fSLiu Zhe 	}
53904bad30fSLiu Zhe 
54004bad30fSLiu Zhe 	/**
54104bad30fSLiu Zhe 	 * test uncheck Error Alert in Validity.
54204bad30fSLiu Zhe 	 */
54304bad30fSLiu Zhe 	@Test
54404bad30fSLiu Zhe 	public void testUncheckErrorAlert() {
54504bad30fSLiu Zhe 
546b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
547b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
548b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
549b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
55004bad30fSLiu Zhe 
551b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
552b4d2d410SLiu Zhe 		scValidityShowErrorMessage.uncheck();
553b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
554b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
55504bad30fSLiu Zhe 
556b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
55704bad30fSLiu Zhe 		typeKeys("13");
55804bad30fSLiu Zhe 		typeKeys("<enter>");
559b4d2d410SLiu Zhe 		assertEquals("13", SCTool.getCellText("A1"));
56004bad30fSLiu Zhe 	}
56104bad30fSLiu Zhe 
56204bad30fSLiu Zhe 	/**
56304bad30fSLiu Zhe 	 * test Cell range source picker in Validity. Input from Edit Box.
56404bad30fSLiu Zhe 	 */
56504bad30fSLiu Zhe 	@Test
56604bad30fSLiu Zhe 	public void testValidityCellRangeSourcePicker() {
56704bad30fSLiu Zhe 
568b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
569b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
570b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
571b4d2d410SLiu Zhe 		assertEquals(false, scValidityCriteriaAllowList.exists());
572b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$2:$G$5");
573b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
574b4d2d410SLiu Zhe 		assertEquals(true, scValidityCriteriaAllowList.exists());
575b4d2d410SLiu Zhe 
576b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
577b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
578b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
579b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
580b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value.");
581b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
58204bad30fSLiu Zhe 
58304bad30fSLiu Zhe 		// calc.focus();
584b4d2d410SLiu Zhe 		SCTool.selectRange("E2");
585b4d2d410SLiu Zhe 		scInputBarInput.activate();
58604bad30fSLiu Zhe 		typeKeys("test");
58704bad30fSLiu Zhe 		typeKeys("<enter>");
58804bad30fSLiu Zhe 
589b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
590b4d2d410SLiu Zhe 		scInputBarInput.activate();
59104bad30fSLiu Zhe 		typeKeys("test32");
59204bad30fSLiu Zhe 		typeKeys("<enter>");
593*57caf934SLiu Zhe 		assertEquals("Invalid value.", activeMsgBox.getMessage());
594*57caf934SLiu Zhe 		activeMsgBox.ok();
595b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
59604bad30fSLiu Zhe 
597b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
598b4d2d410SLiu Zhe 		scInputBarInput.activate();
59904bad30fSLiu Zhe 		typeKeys("test");
60004bad30fSLiu Zhe 		typeKeys("<enter>");
601b4d2d410SLiu Zhe 		assertEquals("test", SCTool.getCellText("B1"));
60204bad30fSLiu Zhe 	}
60304bad30fSLiu Zhe 
60404bad30fSLiu Zhe 	/**
60504bad30fSLiu Zhe 	 * test Allow Blank cell Checkbox in Validity.
60604bad30fSLiu Zhe 	 */
60704bad30fSLiu Zhe 	@Test
60804bad30fSLiu Zhe 	public void testAllowBlankCells() {
609b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
610b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
611b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$1:$E$5");
612b4d2d410SLiu Zhe 		scValidityAllowBlankCells.check();
613b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
61404bad30fSLiu Zhe 
615b4d2d410SLiu Zhe 		SCTool.selectRange("E1");
61604bad30fSLiu Zhe 		typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>");
61704bad30fSLiu Zhe 
618b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
61904bad30fSLiu Zhe 		typeKeys("A<enter>");
620b4d2d410SLiu Zhe 		SCTool.selectRange("D1");
621b4d2d410SLiu Zhe 		scInputBarInput.activate();
62204bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
623b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("D1"));
62404bad30fSLiu Zhe 
625b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
6263816404dSLiu Zhe 		app.dispatch(".uno:Validation");
627b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
628b4d2d410SLiu Zhe 		scValidityAllowBlankCells.uncheck();
62904bad30fSLiu Zhe 		typeKeys("<enter>");
63004bad30fSLiu Zhe 
631b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
632b4d2d410SLiu Zhe 		scInputBarInput.activate();
63304bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
63404bad30fSLiu Zhe 		typeKeys("<enter>");
63504bad30fSLiu Zhe 	}
63604bad30fSLiu Zhe }
637