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 
35424494b0SLi Feng Wang import testlib.gui.AppTool;
36b4d2d410SLiu Zhe import testlib.gui.SCTool;
3704bad30fSLiu Zhe 
3804bad30fSLiu Zhe public class ValidityDialogSetting {
39424494b0SLi Feng Wang 
40*fd348426SLi Feng Wang 	@Rule
41*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
42*fd348426SLi Feng Wang 
4304bad30fSLiu Zhe 	@Before
4404bad30fSLiu Zhe 	public void setUp() throws Exception {
454d3496b1SLiu Zhe 		app.start(true);
46424494b0SLi Feng Wang 		AppTool.newSpreadsheet();
47b4d2d410SLiu Zhe 		SCTool.selectRange("A1:C5");
483816404dSLiu Zhe 		app.dispatch(".uno:Validation");
4904bad30fSLiu Zhe 	}
5004bad30fSLiu Zhe 
5104bad30fSLiu Zhe 	@After
5204bad30fSLiu Zhe 	public void tearDown() throws Exception {
534a13b48eSLi Feng Wang 		app.stop();
5404bad30fSLiu Zhe 	}
5504bad30fSLiu Zhe 
5604bad30fSLiu Zhe 	/**
5704bad30fSLiu Zhe 	 * test Allow not between Date type in Validity.
5804bad30fSLiu Zhe 	 */
5904bad30fSLiu Zhe 	@Test
6004bad30fSLiu Zhe 	public void testAllowDateNotBetween() {
61b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
62b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(3); // "Date"
63b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(7); // "not between"
64b4d2d410SLiu Zhe 		scValiditySourceInput.setText("01/01/08");
65b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("03/01/08");
66b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
67b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
68b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
69b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
70b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
71b4d2d410SLiu Zhe 
72b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
73b4d2d410SLiu Zhe 		scInputBarInput.activate();
7404bad30fSLiu Zhe 		typeKeys("12/31/07");
7504bad30fSLiu Zhe 		typeKeys("<enter>");
76b4d2d410SLiu Zhe 		assertEquals("12/31/07", SCTool.getCellText("A1"));
7704bad30fSLiu Zhe 
78b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
79b4d2d410SLiu Zhe 		scInputBarInput.activate();
8004bad30fSLiu Zhe 		typeKeys("03/02/08");
8104bad30fSLiu Zhe 		typeKeys("<enter>");
82b4d2d410SLiu Zhe 		assertEquals("03/02/08", SCTool.getCellText("A2"));
8304bad30fSLiu Zhe 
84b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
85b4d2d410SLiu Zhe 		scInputBarInput.activate();
8604bad30fSLiu Zhe 		typeKeys("01/01/08");
8704bad30fSLiu Zhe 		typeKeys("<enter>");
8857caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
8957caf934SLiu Zhe 		activeMsgBox.ok();
90b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
9104bad30fSLiu Zhe 
92b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
93b4d2d410SLiu Zhe 		scInputBarInput.activate();
9404bad30fSLiu Zhe 		typeKeys("03/01/08");
9504bad30fSLiu Zhe 		typeKeys("<enter>");
9657caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
9757caf934SLiu Zhe 		activeMsgBox.ok();
98b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
9904bad30fSLiu Zhe 
100b4d2d410SLiu Zhe 		SCTool.selectRange("A5");
101b4d2d410SLiu Zhe 		scInputBarInput.activate();
10204bad30fSLiu Zhe 		typeKeys("01/02/08");
10304bad30fSLiu Zhe 		typeKeys("<enter>");
10457caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
10557caf934SLiu Zhe 		activeMsgBox.ok();
106b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A5"));
10704bad30fSLiu Zhe 
108b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
109b4d2d410SLiu Zhe 		scInputBarInput.activate();
11004bad30fSLiu Zhe 		typeKeys("02/29/08");
11104bad30fSLiu Zhe 		typeKeys("<enter>");
11257caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
11357caf934SLiu Zhe 		activeMsgBox.ok();
114b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
11504bad30fSLiu Zhe 
116b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
117b4d2d410SLiu Zhe 		scInputBarInput.activate();
11804bad30fSLiu Zhe 		typeKeys("test");
11904bad30fSLiu Zhe 		typeKeys("<enter>");
12057caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
12157caf934SLiu Zhe 		activeMsgBox.ok();
122b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
12304bad30fSLiu Zhe 
124b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
125b4d2d410SLiu Zhe 		scInputBarInput.activate();
12604bad30fSLiu Zhe 		typeKeys("39448");
12704bad30fSLiu Zhe 		typeKeys("<enter>");
12857caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
12957caf934SLiu Zhe 		activeMsgBox.ok();
130b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
13104bad30fSLiu Zhe 	}
13204bad30fSLiu Zhe 
13304bad30fSLiu Zhe 	/**
13404bad30fSLiu Zhe 	 * test Allow Decimal equal in Validity.
13504bad30fSLiu Zhe 	 */
13604bad30fSLiu Zhe 	@Test
13704bad30fSLiu Zhe 	public void testAllowDecimalEqual() {
13804bad30fSLiu Zhe 
139b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
140b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
141b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
142b4d2d410SLiu Zhe 		scValiditySourceInput.setText("0.33333333");
143b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
144b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
145b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
146b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
147b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
148b4d2d410SLiu Zhe 
149b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
150b4d2d410SLiu Zhe 		scInputBarInput.activate();
15104bad30fSLiu Zhe 		typeKeys("0.33333333");
15204bad30fSLiu Zhe 		typeKeys("<enter>");
153b4d2d410SLiu Zhe 		assertEquals("0.33333333", SCTool.getCellText("A1"));
15404bad30fSLiu Zhe 
155b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
156b4d2d410SLiu Zhe 		scInputBarInput.activate();
15704bad30fSLiu Zhe 		typeKeys("=1/3");
15804bad30fSLiu Zhe 		typeKeys("<enter>");
15957caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
16057caf934SLiu Zhe 		activeMsgBox.ok();
161b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
16204bad30fSLiu Zhe 
163b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
164b4d2d410SLiu Zhe 		scInputBarInput.activate();
16504bad30fSLiu Zhe 		typeKeys("0.3");
16604bad30fSLiu Zhe 		typeKeys("<enter>");
16757caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
16857caf934SLiu Zhe 		activeMsgBox.ok();
169b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
17004bad30fSLiu Zhe 
171b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
172b4d2d410SLiu Zhe 		scInputBarInput.activate();
17304bad30fSLiu Zhe 		typeKeys("0.333333333");
17404bad30fSLiu Zhe 		typeKeys("<enter>");
17557caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
17657caf934SLiu Zhe 		activeMsgBox.ok();
177b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
17804bad30fSLiu Zhe 
179b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
180b4d2d410SLiu Zhe 		scInputBarInput.activate();
18104bad30fSLiu Zhe 		typeKeys("test");
18204bad30fSLiu Zhe 		typeKeys("<enter>");
18357caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
18457caf934SLiu Zhe 		activeMsgBox.ok();
185b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
18604bad30fSLiu Zhe 	}
18704bad30fSLiu Zhe 
18804bad30fSLiu Zhe 	/**
18922a14f28SLiu Zhe 	 * test Allow Text length, greater than or equal to in Validity.
19004bad30fSLiu Zhe 	 */
19104bad30fSLiu Zhe 	@Test
19204bad30fSLiu Zhe 	public void testAllowGreaterTextLength() {
19304bad30fSLiu Zhe 
194b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
195b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
196b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
197b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
198b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
199b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
200b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
201b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
202b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
203b4d2d410SLiu Zhe 
204b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
205b4d2d410SLiu Zhe 		scInputBarInput.activate();
20604bad30fSLiu Zhe 		typeKeys("testtesttesttest");
20704bad30fSLiu Zhe 		typeKeys("<enter>");
208b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
20904bad30fSLiu Zhe 
210b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
211b4d2d410SLiu Zhe 		scInputBarInput.activate();
21204bad30fSLiu Zhe 		typeKeys("test test ");
21304bad30fSLiu Zhe 		typeKeys("<enter>");
214b4d2d410SLiu Zhe 		assertEquals("test test ", SCTool.getCellText("A2"));
21504bad30fSLiu Zhe 
216b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
217b4d2d410SLiu Zhe 		scInputBarInput.activate();
21804bad30fSLiu Zhe 		typeKeys(" ");
21904bad30fSLiu Zhe 		typeKeys("<enter>");
22057caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
22157caf934SLiu Zhe 		activeMsgBox.ok();
222b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
22304bad30fSLiu Zhe 
224b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
225b4d2d410SLiu Zhe 		scInputBarInput.activate();
22604bad30fSLiu Zhe 		typeKeys("Testatest");
22704bad30fSLiu Zhe 		typeKeys("<enter>");
22857caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
22957caf934SLiu Zhe 		activeMsgBox.ok();
230b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
23104bad30fSLiu Zhe 	}
23204bad30fSLiu Zhe 
23304bad30fSLiu Zhe 	/**
23422a14f28SLiu Zhe 	 * test Allow Text length, less than in Validity.
23504bad30fSLiu Zhe 	 */
236708863fbSHerbert Dürr 	@Test
23704bad30fSLiu Zhe 	public void testAllowLessThanTextLength() {
23804bad30fSLiu Zhe 
239b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
240b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
241b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(1); // "less than"
242b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
243b4d2d410SLiu Zhe 
244b4d2d410SLiu Zhe 		scValidityInputHelpTabPage.select();
245b4d2d410SLiu Zhe 		scValidityInputHelpCheckbox.check();
246b4d2d410SLiu Zhe 		scValidityInputHelpTitle.setText("Help Info Title");
247b4d2d410SLiu Zhe 		scValidityHelpMessage.setText("help info");
248b4d2d410SLiu Zhe 
249b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
250b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
251b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select("Information");
252b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Notes to enter");
253b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
254b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
255b4d2d410SLiu Zhe 
256b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
257b4d2d410SLiu Zhe 		scInputBarInput.activate();
25804bad30fSLiu Zhe 		typeKeys("testtesttesttest<enter>");
25957caf934SLiu Zhe 		activeMsgBox.ok();
260b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
26104bad30fSLiu Zhe 
262b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
263b4d2d410SLiu Zhe 		scInputBarInput.activate();
26404bad30fSLiu Zhe 		typeKeys("sfsafsddddddd<enter>");
26557caf934SLiu Zhe 		activeMsgBox.cancel();
266b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
26704bad30fSLiu Zhe 
268b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
269b4d2d410SLiu Zhe 		scInputBarInput.activate();
27004bad30fSLiu Zhe 		typeKeys("10<enter>");
271b4d2d410SLiu Zhe 		assertEquals("10", SCTool.getCellText("A2"));
27204bad30fSLiu Zhe 
273b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
274b4d2d410SLiu Zhe 		scInputBarInput.activate();
27504bad30fSLiu Zhe 		typeKeys("ok<enter>");
276b4d2d410SLiu Zhe 		assertEquals("ok", SCTool.getCellText("A3"));
27704bad30fSLiu Zhe 	}
27804bad30fSLiu Zhe 
27904bad30fSLiu Zhe 	/**
28004bad30fSLiu Zhe 	 * test Allow list.
28104bad30fSLiu Zhe 	 */
28204bad30fSLiu Zhe 	@Test
28304bad30fSLiu Zhe 	public void testAllowListSpecialChar() {
28404bad30fSLiu Zhe 
285b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
286b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(6); // "List"
287b4d2d410SLiu Zhe 		scValidityEntries.focus();
28804bad30fSLiu Zhe 		typeKeys("a");
28904bad30fSLiu Zhe 		typeKeys("<enter>");
29004bad30fSLiu Zhe 		typeKeys("b");
291b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
292b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
293b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
294b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
295b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
296b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
29704bad30fSLiu Zhe 
2984d3496b1SLiu Zhe 		// These codes are not stable: start
29922a14f28SLiu Zhe 		// calc.rightClick(1, 1);
30022a14f28SLiu Zhe 		// typeKeys("<shift s>");
30122a14f28SLiu Zhe 		// typeKeys("<down><enter>"); // Choose a
30222a14f28SLiu Zhe 		// sleep(2); // if no sleep, error occur
3034d3496b1SLiu Zhe 		// These codes are not stable: end
304b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
305b4d2d410SLiu Zhe 		scInputBarInput.activate();
3064d3496b1SLiu Zhe 		typeKeys("a<enter>");
307b4d2d410SLiu Zhe 		assertEquals("a", SCTool.getCellText("A1"));
30804bad30fSLiu Zhe 
309b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
310b4d2d410SLiu Zhe 		scInputBarInput.activate();
31104bad30fSLiu Zhe 		typeKeys("test");
31204bad30fSLiu Zhe 		typeKeys("<enter>");
31357caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
31457caf934SLiu Zhe 		activeMsgBox.ok();
315b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
31604bad30fSLiu Zhe 	}
31704bad30fSLiu Zhe 
31804bad30fSLiu Zhe 	/**
31922a14f28SLiu Zhe 	 * test Allow time between in Validity.
32004bad30fSLiu Zhe 	 */
32104bad30fSLiu Zhe 	@Test
32204bad30fSLiu Zhe 	public void testAllowTimeBetween() {
32304bad30fSLiu Zhe 
324b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
325b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
326b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(6); // "between"
327b4d2d410SLiu Zhe 		scValiditySourceInput.setText("27:00");
328b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("21:00");
329b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
330b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
331b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
332b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
333b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
334b4d2d410SLiu Zhe 
335b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
336b4d2d410SLiu Zhe 		scInputBarInput.activate();
33704bad30fSLiu Zhe 		typeKeys("21:00");
33804bad30fSLiu Zhe 		typeKeys("<enter>");
339b4d2d410SLiu Zhe 		assertEquals("09:00:00 PM", SCTool.getCellText("A1"));
34004bad30fSLiu Zhe 
341b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
342b4d2d410SLiu Zhe 		scInputBarInput.activate();
34304bad30fSLiu Zhe 		typeKeys("27:00");
34404bad30fSLiu Zhe 		typeKeys("<enter>");
345b4d2d410SLiu Zhe 		assertEquals("27:00:00", SCTool.getCellText("A2"));
34604bad30fSLiu Zhe 
347b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
348b4d2d410SLiu Zhe 		scInputBarInput.activate();
34904bad30fSLiu Zhe 		typeKeys("1.125");
35004bad30fSLiu Zhe 		typeKeys("<enter>");
351b4d2d410SLiu Zhe 		assertEquals("1.125", SCTool.getCellText("A3"));
35204bad30fSLiu Zhe 
353b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
354b4d2d410SLiu Zhe 		scInputBarInput.activate();
35504bad30fSLiu Zhe 		typeKeys("0.875");
35604bad30fSLiu Zhe 		typeKeys("<enter>");
357b4d2d410SLiu Zhe 		assertEquals("0.875", SCTool.getCellText("A4"));
35804bad30fSLiu Zhe 
359b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
360b4d2d410SLiu Zhe 		scInputBarInput.activate();
36104bad30fSLiu Zhe 		typeKeys("03:00:01");
36204bad30fSLiu Zhe 		typeKeys("<enter>");
36357caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
36457caf934SLiu Zhe 		activeMsgBox.ok();
365b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
36604bad30fSLiu Zhe 
367b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
368b4d2d410SLiu Zhe 		scInputBarInput.activate();
36904bad30fSLiu Zhe 		typeKeys("20:59:59");
37004bad30fSLiu Zhe 		typeKeys("<enter>");
37157caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
37257caf934SLiu Zhe 		activeMsgBox.ok();
373b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
37404bad30fSLiu Zhe 
375b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
376b4d2d410SLiu Zhe 		scInputBarInput.activate();
37704bad30fSLiu Zhe 		typeKeys("1.126");
37804bad30fSLiu Zhe 		typeKeys("<enter>");
37957caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
38057caf934SLiu Zhe 		activeMsgBox.ok();
381b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
38204bad30fSLiu Zhe 
383b4d2d410SLiu Zhe 		SCTool.selectRange("B4");
384b4d2d410SLiu Zhe 		scInputBarInput.activate();
38504bad30fSLiu Zhe 		typeKeys("0.874");
38604bad30fSLiu Zhe 		typeKeys("<enter>");
38757caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
38857caf934SLiu Zhe 		activeMsgBox.ok();
389b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B4"));
39004bad30fSLiu Zhe 
391b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
392b4d2d410SLiu Zhe 		scInputBarInput.activate();
39304bad30fSLiu Zhe 		typeKeys("test");
39404bad30fSLiu Zhe 		typeKeys("<enter>");
39557caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
39657caf934SLiu Zhe 		activeMsgBox.ok();
397b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
39804bad30fSLiu Zhe 
399b4d2d410SLiu Zhe 		SCTool.selectRange("C2");
400b4d2d410SLiu Zhe 		scInputBarInput.activate();
40104bad30fSLiu Zhe 		typeKeys("24:00");
40204bad30fSLiu Zhe 		typeKeys("<enter>");
403b4d2d410SLiu Zhe 		assertEquals("24:00:00", SCTool.getCellText("C2"));
40404bad30fSLiu Zhe 
405b4d2d410SLiu Zhe 		SCTool.selectRange("C3");
406b4d2d410SLiu Zhe 		scInputBarInput.activate();
40704bad30fSLiu Zhe 		typeKeys("12:00");
40804bad30fSLiu Zhe 		typeKeys("<enter>");
40957caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
41057caf934SLiu Zhe 		activeMsgBox.ok();
411b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C3"));
41204bad30fSLiu Zhe 	}
41304bad30fSLiu Zhe 
41404bad30fSLiu Zhe 	/**
41522a14f28SLiu Zhe 	 * test Allow time Greater than and equal to in Validity.
41604bad30fSLiu Zhe 	 */
41704bad30fSLiu Zhe 	@Test
41804bad30fSLiu Zhe 	public void testAllowTimeGreaterThan() {
41904bad30fSLiu Zhe 
420b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
421b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
422b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
423b4d2d410SLiu Zhe 		scValiditySourceInput.setText("8:00");
42404bad30fSLiu Zhe 
425b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
426b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
427b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(1); // "Warning"
42804bad30fSLiu Zhe 
429b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("warning to enter");
430b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
431b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
43204bad30fSLiu Zhe 
433b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
434b4d2d410SLiu Zhe 		scInputBarInput.activate();
43504bad30fSLiu Zhe 		typeKeys("7:30");
43604bad30fSLiu Zhe 		typeKeys("<enter>");
43757caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
43857caf934SLiu Zhe 		activeMsgBox.ok();
439b4d2d410SLiu Zhe 		assertEquals("07:30:00 AM", SCTool.getCellText("A1"));
44004bad30fSLiu Zhe 
441b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
442b4d2d410SLiu Zhe 		scInputBarInput.activate();
44304bad30fSLiu Zhe 		typeKeys("6:00");
44404bad30fSLiu Zhe 		typeKeys("<enter>");
44557caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
44657caf934SLiu Zhe 		activeMsgBox.cancel();
447b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
44804bad30fSLiu Zhe 
449b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
450b4d2d410SLiu Zhe 		scInputBarInput.activate();
45104bad30fSLiu Zhe 		typeKeys("8:00");
45204bad30fSLiu Zhe 		typeKeys("<enter>");
453b4d2d410SLiu Zhe 		assertEquals("08:00:00 AM", SCTool.getCellText("A3"));
45404bad30fSLiu Zhe 	}
45504bad30fSLiu Zhe 
45604bad30fSLiu Zhe 	/**
45704bad30fSLiu Zhe 	 * test Allow whole number, less than or equal to in Validity.
45804bad30fSLiu Zhe 	 */
45904bad30fSLiu Zhe 	@Test
46004bad30fSLiu Zhe 	public void testAllowWholeNumLessThan() {
46104bad30fSLiu Zhe 
462b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
463b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(1); // "Whole Numbers"
464b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(3); // "less than or equal"
465b4d2d410SLiu Zhe 		scValiditySourceInput.setText("100");
466b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
467b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
468b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
469b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
470b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
471b4d2d410SLiu Zhe 
472b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
473b4d2d410SLiu Zhe 		scInputBarInput.activate();
47404bad30fSLiu Zhe 		typeKeys("99");
47504bad30fSLiu Zhe 		typeKeys("<enter>");
476b4d2d410SLiu Zhe 		assertEquals("99", SCTool.getCellText("A1"));
47704bad30fSLiu Zhe 
478b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
479b4d2d410SLiu Zhe 		scInputBarInput.activate();
48004bad30fSLiu Zhe 		typeKeys("100");
48104bad30fSLiu Zhe 		typeKeys("<enter>");
482b4d2d410SLiu Zhe 		assertEquals("100", SCTool.getCellText("A2"));
48304bad30fSLiu Zhe 
484b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
485b4d2d410SLiu Zhe 		scInputBarInput.activate();
48604bad30fSLiu Zhe 		typeKeys("101");
48704bad30fSLiu Zhe 		typeKeys("<enter>");
48857caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
48957caf934SLiu Zhe 		activeMsgBox.ok();
490b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
49104bad30fSLiu Zhe 
492b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
493b4d2d410SLiu Zhe 		scInputBarInput.activate();
49404bad30fSLiu Zhe 		typeKeys("45.5");
49504bad30fSLiu Zhe 		typeKeys("<enter>");
49657caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
49757caf934SLiu Zhe 		activeMsgBox.ok();
498b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
49904bad30fSLiu Zhe 
500b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
501b4d2d410SLiu Zhe 		scInputBarInput.activate();
50204bad30fSLiu Zhe 		typeKeys("test");
50304bad30fSLiu Zhe 		typeKeys("<enter>");
50457caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
50557caf934SLiu Zhe 		activeMsgBox.ok();
506b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
50704bad30fSLiu Zhe 	}
50804bad30fSLiu Zhe 
50904bad30fSLiu Zhe 	/**
51004bad30fSLiu Zhe 	 * test default message of Error Alert in Validity.
51104bad30fSLiu Zhe 	 */
51204bad30fSLiu Zhe 	@Test
51304bad30fSLiu Zhe 	public void testDefaultErrorAlertMessage() {
51404bad30fSLiu Zhe 
515b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
516b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
517b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
518b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
51904bad30fSLiu Zhe 
520b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
521b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
522b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
523b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
52404bad30fSLiu Zhe 
525b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
526b4d2d410SLiu Zhe 		scInputBarInput.activate();
52704bad30fSLiu Zhe 		typeKeys("13");
52804bad30fSLiu Zhe 		typeKeys("<enter>");
52957caf934SLiu Zhe 		assertEquals("OpenOffice.org Calc", activeMsgBox.getCaption());
53022a14f28SLiu Zhe 		// assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not
53122a14f28SLiu Zhe 		// verify in multi-language
53257caf934SLiu Zhe 		activeMsgBox.ok();
533b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
53404bad30fSLiu Zhe 	}
53504bad30fSLiu Zhe 
53604bad30fSLiu Zhe 	/**
53704bad30fSLiu Zhe 	 * test uncheck Error Alert in Validity.
53804bad30fSLiu Zhe 	 */
53904bad30fSLiu Zhe 	@Test
54004bad30fSLiu Zhe 	public void testUncheckErrorAlert() {
54104bad30fSLiu Zhe 
542b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
543b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
544b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
545b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
54604bad30fSLiu Zhe 
547b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
548b4d2d410SLiu Zhe 		scValidityShowErrorMessage.uncheck();
549b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
550b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
55104bad30fSLiu Zhe 
552b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
55304bad30fSLiu Zhe 		typeKeys("13");
55404bad30fSLiu Zhe 		typeKeys("<enter>");
555b4d2d410SLiu Zhe 		assertEquals("13", SCTool.getCellText("A1"));
55604bad30fSLiu Zhe 	}
55704bad30fSLiu Zhe 
55804bad30fSLiu Zhe 	/**
55904bad30fSLiu Zhe 	 * test Cell range source picker in Validity. Input from Edit Box.
56004bad30fSLiu Zhe 	 */
56104bad30fSLiu Zhe 	@Test
56204bad30fSLiu Zhe 	public void testValidityCellRangeSourcePicker() {
56304bad30fSLiu Zhe 
564b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
565b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
566b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
567b4d2d410SLiu Zhe 		assertEquals(false, scValidityCriteriaAllowList.exists());
568b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$2:$G$5");
569b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
570b4d2d410SLiu Zhe 		assertEquals(true, scValidityCriteriaAllowList.exists());
571b4d2d410SLiu Zhe 
572b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
573b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
574b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
575b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
576b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value.");
577b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
57804bad30fSLiu Zhe 
57904bad30fSLiu Zhe 		// calc.focus();
580b4d2d410SLiu Zhe 		SCTool.selectRange("E2");
581b4d2d410SLiu Zhe 		scInputBarInput.activate();
58204bad30fSLiu Zhe 		typeKeys("test");
58304bad30fSLiu Zhe 		typeKeys("<enter>");
58404bad30fSLiu Zhe 
585b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
586b4d2d410SLiu Zhe 		scInputBarInput.activate();
58704bad30fSLiu Zhe 		typeKeys("test32");
58804bad30fSLiu Zhe 		typeKeys("<enter>");
58957caf934SLiu Zhe 		assertEquals("Invalid value.", activeMsgBox.getMessage());
59057caf934SLiu Zhe 		activeMsgBox.ok();
591b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
59204bad30fSLiu Zhe 
593b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
594b4d2d410SLiu Zhe 		scInputBarInput.activate();
59504bad30fSLiu Zhe 		typeKeys("test");
59604bad30fSLiu Zhe 		typeKeys("<enter>");
597b4d2d410SLiu Zhe 		assertEquals("test", SCTool.getCellText("B1"));
59804bad30fSLiu Zhe 	}
59904bad30fSLiu Zhe 
60004bad30fSLiu Zhe 	/**
60104bad30fSLiu Zhe 	 * test Allow Blank cell Checkbox in Validity.
60204bad30fSLiu Zhe 	 */
60304bad30fSLiu Zhe 	@Test
60404bad30fSLiu Zhe 	public void testAllowBlankCells() {
605b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
606b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
607b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$1:$E$5");
608b4d2d410SLiu Zhe 		scValidityAllowBlankCells.check();
609b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
61004bad30fSLiu Zhe 
611b4d2d410SLiu Zhe 		SCTool.selectRange("E1");
61204bad30fSLiu Zhe 		typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>");
61304bad30fSLiu Zhe 
614b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
61504bad30fSLiu Zhe 		typeKeys("A<enter>");
616b4d2d410SLiu Zhe 		SCTool.selectRange("D1");
617b4d2d410SLiu Zhe 		scInputBarInput.activate();
61804bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
619b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("D1"));
62004bad30fSLiu Zhe 
621b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
6223816404dSLiu Zhe 		app.dispatch(".uno:Validation");
623b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
624b4d2d410SLiu Zhe 		scValidityAllowBlankCells.uncheck();
62504bad30fSLiu Zhe 		typeKeys("<enter>");
62604bad30fSLiu Zhe 
627b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
628b4d2d410SLiu Zhe 		scInputBarInput.activate();
62904bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
63004bad30fSLiu Zhe 		typeKeys("<enter>");
63104bad30fSLiu Zhe 	}
63204bad30fSLiu Zhe }
633