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 
35*424494b0SLi Feng Wang import testlib.gui.AppTool;
36b4d2d410SLiu Zhe import testlib.gui.SCTool;
3704bad30fSLiu Zhe 
3804bad30fSLiu Zhe public class ValidityDialogSetting {
39*424494b0SLi Feng Wang 
4004bad30fSLiu Zhe 	@Before
4104bad30fSLiu Zhe 	public void setUp() throws Exception {
424d3496b1SLiu Zhe 		app.start(true);
43*424494b0SLi Feng Wang 		AppTool.newSpreadsheet();
44b4d2d410SLiu Zhe 		SCTool.selectRange("A1:C5");
453816404dSLiu Zhe 		app.dispatch(".uno:Validation");
4604bad30fSLiu Zhe 	}
4704bad30fSLiu Zhe 
4804bad30fSLiu Zhe 	@After
4904bad30fSLiu Zhe 	public void tearDown() throws Exception {
504a13b48eSLi Feng Wang 		app.stop();
5104bad30fSLiu Zhe 	}
5204bad30fSLiu Zhe 
5304bad30fSLiu Zhe 	/**
5404bad30fSLiu Zhe 	 * test Allow not between Date type in Validity.
5504bad30fSLiu Zhe 	 */
5604bad30fSLiu Zhe 	@Test
5704bad30fSLiu Zhe 	public void testAllowDateNotBetween() {
58b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
59b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(3); // "Date"
60b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(7); // "not between"
61b4d2d410SLiu Zhe 		scValiditySourceInput.setText("01/01/08");
62b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("03/01/08");
63b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
64b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
65b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
66b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
67b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
68b4d2d410SLiu Zhe 
69b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
70b4d2d410SLiu Zhe 		scInputBarInput.activate();
7104bad30fSLiu Zhe 		typeKeys("12/31/07");
7204bad30fSLiu Zhe 		typeKeys("<enter>");
73b4d2d410SLiu Zhe 		assertEquals("12/31/07", SCTool.getCellText("A1"));
7404bad30fSLiu Zhe 
75b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
76b4d2d410SLiu Zhe 		scInputBarInput.activate();
7704bad30fSLiu Zhe 		typeKeys("03/02/08");
7804bad30fSLiu Zhe 		typeKeys("<enter>");
79b4d2d410SLiu Zhe 		assertEquals("03/02/08", SCTool.getCellText("A2"));
8004bad30fSLiu Zhe 
81b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
82b4d2d410SLiu Zhe 		scInputBarInput.activate();
8304bad30fSLiu Zhe 		typeKeys("01/01/08");
8404bad30fSLiu Zhe 		typeKeys("<enter>");
8557caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
8657caf934SLiu Zhe 		activeMsgBox.ok();
87b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
8804bad30fSLiu Zhe 
89b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
90b4d2d410SLiu Zhe 		scInputBarInput.activate();
9104bad30fSLiu Zhe 		typeKeys("03/01/08");
9204bad30fSLiu Zhe 		typeKeys("<enter>");
9357caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
9457caf934SLiu Zhe 		activeMsgBox.ok();
95b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
9604bad30fSLiu Zhe 
97b4d2d410SLiu Zhe 		SCTool.selectRange("A5");
98b4d2d410SLiu Zhe 		scInputBarInput.activate();
9904bad30fSLiu Zhe 		typeKeys("01/02/08");
10004bad30fSLiu Zhe 		typeKeys("<enter>");
10157caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
10257caf934SLiu Zhe 		activeMsgBox.ok();
103b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A5"));
10404bad30fSLiu Zhe 
105b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
106b4d2d410SLiu Zhe 		scInputBarInput.activate();
10704bad30fSLiu Zhe 		typeKeys("02/29/08");
10804bad30fSLiu Zhe 		typeKeys("<enter>");
10957caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
11057caf934SLiu Zhe 		activeMsgBox.ok();
111b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
11204bad30fSLiu Zhe 
113b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
114b4d2d410SLiu Zhe 		scInputBarInput.activate();
11504bad30fSLiu Zhe 		typeKeys("test");
11604bad30fSLiu Zhe 		typeKeys("<enter>");
11757caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
11857caf934SLiu Zhe 		activeMsgBox.ok();
119b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
12004bad30fSLiu Zhe 
121b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
122b4d2d410SLiu Zhe 		scInputBarInput.activate();
12304bad30fSLiu Zhe 		typeKeys("39448");
12404bad30fSLiu Zhe 		typeKeys("<enter>");
12557caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
12657caf934SLiu Zhe 		activeMsgBox.ok();
127b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
12804bad30fSLiu Zhe 	}
12904bad30fSLiu Zhe 
13004bad30fSLiu Zhe 	/**
13104bad30fSLiu Zhe 	 * test Allow Decimal equal in Validity.
13204bad30fSLiu Zhe 	 */
13304bad30fSLiu Zhe 	@Test
13404bad30fSLiu Zhe 	public void testAllowDecimalEqual() {
13504bad30fSLiu Zhe 
136b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
137b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
138b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
139b4d2d410SLiu Zhe 		scValiditySourceInput.setText("0.33333333");
140b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
141b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
142b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
143b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
144b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
145b4d2d410SLiu Zhe 
146b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
147b4d2d410SLiu Zhe 		scInputBarInput.activate();
14804bad30fSLiu Zhe 		typeKeys("0.33333333");
14904bad30fSLiu Zhe 		typeKeys("<enter>");
150b4d2d410SLiu Zhe 		assertEquals("0.33333333", SCTool.getCellText("A1"));
15104bad30fSLiu Zhe 
152b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
153b4d2d410SLiu Zhe 		scInputBarInput.activate();
15404bad30fSLiu Zhe 		typeKeys("=1/3");
15504bad30fSLiu Zhe 		typeKeys("<enter>");
15657caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
15757caf934SLiu Zhe 		activeMsgBox.ok();
158b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
15904bad30fSLiu Zhe 
160b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
161b4d2d410SLiu Zhe 		scInputBarInput.activate();
16204bad30fSLiu Zhe 		typeKeys("0.3");
16304bad30fSLiu Zhe 		typeKeys("<enter>");
16457caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
16557caf934SLiu Zhe 		activeMsgBox.ok();
166b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
16704bad30fSLiu Zhe 
168b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
169b4d2d410SLiu Zhe 		scInputBarInput.activate();
17004bad30fSLiu Zhe 		typeKeys("0.333333333");
17104bad30fSLiu Zhe 		typeKeys("<enter>");
17257caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
17357caf934SLiu Zhe 		activeMsgBox.ok();
174b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
17504bad30fSLiu Zhe 
176b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
177b4d2d410SLiu Zhe 		scInputBarInput.activate();
17804bad30fSLiu Zhe 		typeKeys("test");
17904bad30fSLiu Zhe 		typeKeys("<enter>");
18057caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
18157caf934SLiu Zhe 		activeMsgBox.ok();
182b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
18304bad30fSLiu Zhe 	}
18404bad30fSLiu Zhe 
18504bad30fSLiu Zhe 	/**
18622a14f28SLiu Zhe 	 * test Allow Text length, greater than or equal to in Validity.
18704bad30fSLiu Zhe 	 */
18804bad30fSLiu Zhe 	@Test
18904bad30fSLiu Zhe 	public void testAllowGreaterTextLength() {
19004bad30fSLiu Zhe 
191b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
192b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
193b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
194b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
195b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
196b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
197b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
198b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
199b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
200b4d2d410SLiu Zhe 
201b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
202b4d2d410SLiu Zhe 		scInputBarInput.activate();
20304bad30fSLiu Zhe 		typeKeys("testtesttesttest");
20404bad30fSLiu Zhe 		typeKeys("<enter>");
205b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
20604bad30fSLiu Zhe 
207b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
208b4d2d410SLiu Zhe 		scInputBarInput.activate();
20904bad30fSLiu Zhe 		typeKeys("test test ");
21004bad30fSLiu Zhe 		typeKeys("<enter>");
211b4d2d410SLiu Zhe 		assertEquals("test test ", SCTool.getCellText("A2"));
21204bad30fSLiu Zhe 
213b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
214b4d2d410SLiu Zhe 		scInputBarInput.activate();
21504bad30fSLiu Zhe 		typeKeys(" ");
21604bad30fSLiu Zhe 		typeKeys("<enter>");
21757caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
21857caf934SLiu Zhe 		activeMsgBox.ok();
219b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
22004bad30fSLiu Zhe 
221b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
222b4d2d410SLiu Zhe 		scInputBarInput.activate();
22304bad30fSLiu Zhe 		typeKeys("Testatest");
22404bad30fSLiu Zhe 		typeKeys("<enter>");
22557caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
22657caf934SLiu Zhe 		activeMsgBox.ok();
227b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
22804bad30fSLiu Zhe 	}
22904bad30fSLiu Zhe 
23004bad30fSLiu Zhe 	/**
23122a14f28SLiu Zhe 	 * test Allow Text length, less than in Validity.
23204bad30fSLiu Zhe 	 */
233708863fbSHerbert Dürr 	@Test
23404bad30fSLiu Zhe 	public void testAllowLessThanTextLength() {
23504bad30fSLiu Zhe 
236b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
237b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
238b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(1); // "less than"
239b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
240b4d2d410SLiu Zhe 
241b4d2d410SLiu Zhe 		scValidityInputHelpTabPage.select();
242b4d2d410SLiu Zhe 		scValidityInputHelpCheckbox.check();
243b4d2d410SLiu Zhe 		scValidityInputHelpTitle.setText("Help Info Title");
244b4d2d410SLiu Zhe 		scValidityHelpMessage.setText("help info");
245b4d2d410SLiu Zhe 
246b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
247b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
248b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select("Information");
249b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Notes to enter");
250b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
251b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
252b4d2d410SLiu Zhe 
253b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
254b4d2d410SLiu Zhe 		scInputBarInput.activate();
25504bad30fSLiu Zhe 		typeKeys("testtesttesttest<enter>");
25657caf934SLiu Zhe 		activeMsgBox.ok();
257b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
25804bad30fSLiu Zhe 
259b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
260b4d2d410SLiu Zhe 		scInputBarInput.activate();
26104bad30fSLiu Zhe 		typeKeys("sfsafsddddddd<enter>");
26257caf934SLiu Zhe 		activeMsgBox.cancel();
263b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
26404bad30fSLiu Zhe 
265b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
266b4d2d410SLiu Zhe 		scInputBarInput.activate();
26704bad30fSLiu Zhe 		typeKeys("10<enter>");
268b4d2d410SLiu Zhe 		assertEquals("10", SCTool.getCellText("A2"));
26904bad30fSLiu Zhe 
270b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
271b4d2d410SLiu Zhe 		scInputBarInput.activate();
27204bad30fSLiu Zhe 		typeKeys("ok<enter>");
273b4d2d410SLiu Zhe 		assertEquals("ok", SCTool.getCellText("A3"));
27404bad30fSLiu Zhe 	}
27504bad30fSLiu Zhe 
27604bad30fSLiu Zhe 	/**
27704bad30fSLiu Zhe 	 * test Allow list.
27804bad30fSLiu Zhe 	 */
27904bad30fSLiu Zhe 	@Test
28004bad30fSLiu Zhe 	public void testAllowListSpecialChar() {
28104bad30fSLiu Zhe 
282b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
283b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(6); // "List"
284b4d2d410SLiu Zhe 		scValidityEntries.focus();
28504bad30fSLiu Zhe 		typeKeys("a");
28604bad30fSLiu Zhe 		typeKeys("<enter>");
28704bad30fSLiu Zhe 		typeKeys("b");
288b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
289b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
290b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
291b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
292b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
293b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
29404bad30fSLiu Zhe 
2954d3496b1SLiu Zhe 		// These codes are not stable: start
29622a14f28SLiu Zhe 		// calc.rightClick(1, 1);
29722a14f28SLiu Zhe 		// typeKeys("<shift s>");
29822a14f28SLiu Zhe 		// typeKeys("<down><enter>"); // Choose a
29922a14f28SLiu Zhe 		// sleep(2); // if no sleep, error occur
3004d3496b1SLiu Zhe 		// These codes are not stable: end
301b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
302b4d2d410SLiu Zhe 		scInputBarInput.activate();
3034d3496b1SLiu Zhe 		typeKeys("a<enter>");
304b4d2d410SLiu Zhe 		assertEquals("a", SCTool.getCellText("A1"));
30504bad30fSLiu Zhe 
306b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
307b4d2d410SLiu Zhe 		scInputBarInput.activate();
30804bad30fSLiu Zhe 		typeKeys("test");
30904bad30fSLiu Zhe 		typeKeys("<enter>");
31057caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
31157caf934SLiu Zhe 		activeMsgBox.ok();
312b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
31304bad30fSLiu Zhe 	}
31404bad30fSLiu Zhe 
31504bad30fSLiu Zhe 	/**
31622a14f28SLiu Zhe 	 * test Allow time between in Validity.
31704bad30fSLiu Zhe 	 */
31804bad30fSLiu Zhe 	@Test
31904bad30fSLiu Zhe 	public void testAllowTimeBetween() {
32004bad30fSLiu Zhe 
321b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
322b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
323b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(6); // "between"
324b4d2d410SLiu Zhe 		scValiditySourceInput.setText("27:00");
325b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("21:00");
326b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
327b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
328b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
329b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
330b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
331b4d2d410SLiu Zhe 
332b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
333b4d2d410SLiu Zhe 		scInputBarInput.activate();
33404bad30fSLiu Zhe 		typeKeys("21:00");
33504bad30fSLiu Zhe 		typeKeys("<enter>");
336b4d2d410SLiu Zhe 		assertEquals("09:00:00 PM", SCTool.getCellText("A1"));
33704bad30fSLiu Zhe 
338b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
339b4d2d410SLiu Zhe 		scInputBarInput.activate();
34004bad30fSLiu Zhe 		typeKeys("27:00");
34104bad30fSLiu Zhe 		typeKeys("<enter>");
342b4d2d410SLiu Zhe 		assertEquals("27:00:00", SCTool.getCellText("A2"));
34304bad30fSLiu Zhe 
344b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
345b4d2d410SLiu Zhe 		scInputBarInput.activate();
34604bad30fSLiu Zhe 		typeKeys("1.125");
34704bad30fSLiu Zhe 		typeKeys("<enter>");
348b4d2d410SLiu Zhe 		assertEquals("1.125", SCTool.getCellText("A3"));
34904bad30fSLiu Zhe 
350b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
351b4d2d410SLiu Zhe 		scInputBarInput.activate();
35204bad30fSLiu Zhe 		typeKeys("0.875");
35304bad30fSLiu Zhe 		typeKeys("<enter>");
354b4d2d410SLiu Zhe 		assertEquals("0.875", SCTool.getCellText("A4"));
35504bad30fSLiu Zhe 
356b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
357b4d2d410SLiu Zhe 		scInputBarInput.activate();
35804bad30fSLiu Zhe 		typeKeys("03:00:01");
35904bad30fSLiu Zhe 		typeKeys("<enter>");
36057caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
36157caf934SLiu Zhe 		activeMsgBox.ok();
362b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
36304bad30fSLiu Zhe 
364b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
365b4d2d410SLiu Zhe 		scInputBarInput.activate();
36604bad30fSLiu Zhe 		typeKeys("20:59:59");
36704bad30fSLiu Zhe 		typeKeys("<enter>");
36857caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
36957caf934SLiu Zhe 		activeMsgBox.ok();
370b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
37104bad30fSLiu Zhe 
372b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
373b4d2d410SLiu Zhe 		scInputBarInput.activate();
37404bad30fSLiu Zhe 		typeKeys("1.126");
37504bad30fSLiu Zhe 		typeKeys("<enter>");
37657caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
37757caf934SLiu Zhe 		activeMsgBox.ok();
378b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
37904bad30fSLiu Zhe 
380b4d2d410SLiu Zhe 		SCTool.selectRange("B4");
381b4d2d410SLiu Zhe 		scInputBarInput.activate();
38204bad30fSLiu Zhe 		typeKeys("0.874");
38304bad30fSLiu Zhe 		typeKeys("<enter>");
38457caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
38557caf934SLiu Zhe 		activeMsgBox.ok();
386b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B4"));
38704bad30fSLiu Zhe 
388b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
389b4d2d410SLiu Zhe 		scInputBarInput.activate();
39004bad30fSLiu Zhe 		typeKeys("test");
39104bad30fSLiu Zhe 		typeKeys("<enter>");
39257caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
39357caf934SLiu Zhe 		activeMsgBox.ok();
394b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
39504bad30fSLiu Zhe 
396b4d2d410SLiu Zhe 		SCTool.selectRange("C2");
397b4d2d410SLiu Zhe 		scInputBarInput.activate();
39804bad30fSLiu Zhe 		typeKeys("24:00");
39904bad30fSLiu Zhe 		typeKeys("<enter>");
400b4d2d410SLiu Zhe 		assertEquals("24:00:00", SCTool.getCellText("C2"));
40104bad30fSLiu Zhe 
402b4d2d410SLiu Zhe 		SCTool.selectRange("C3");
403b4d2d410SLiu Zhe 		scInputBarInput.activate();
40404bad30fSLiu Zhe 		typeKeys("12:00");
40504bad30fSLiu Zhe 		typeKeys("<enter>");
40657caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
40757caf934SLiu Zhe 		activeMsgBox.ok();
408b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C3"));
40904bad30fSLiu Zhe 	}
41004bad30fSLiu Zhe 
41104bad30fSLiu Zhe 	/**
41222a14f28SLiu Zhe 	 * test Allow time Greater than and equal to in Validity.
41304bad30fSLiu Zhe 	 */
41404bad30fSLiu Zhe 	@Test
41504bad30fSLiu Zhe 	public void testAllowTimeGreaterThan() {
41604bad30fSLiu Zhe 
417b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
418b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
419b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
420b4d2d410SLiu Zhe 		scValiditySourceInput.setText("8:00");
42104bad30fSLiu Zhe 
422b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
423b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
424b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(1); // "Warning"
42504bad30fSLiu Zhe 
426b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("warning to enter");
427b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
428b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
42904bad30fSLiu Zhe 
430b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
431b4d2d410SLiu Zhe 		scInputBarInput.activate();
43204bad30fSLiu Zhe 		typeKeys("7:30");
43304bad30fSLiu Zhe 		typeKeys("<enter>");
43457caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
43557caf934SLiu Zhe 		activeMsgBox.ok();
436b4d2d410SLiu Zhe 		assertEquals("07:30:00 AM", SCTool.getCellText("A1"));
43704bad30fSLiu Zhe 
438b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
439b4d2d410SLiu Zhe 		scInputBarInput.activate();
44004bad30fSLiu Zhe 		typeKeys("6:00");
44104bad30fSLiu Zhe 		typeKeys("<enter>");
44257caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
44357caf934SLiu Zhe 		activeMsgBox.cancel();
444b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
44504bad30fSLiu Zhe 
446b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
447b4d2d410SLiu Zhe 		scInputBarInput.activate();
44804bad30fSLiu Zhe 		typeKeys("8:00");
44904bad30fSLiu Zhe 		typeKeys("<enter>");
450b4d2d410SLiu Zhe 		assertEquals("08:00:00 AM", SCTool.getCellText("A3"));
45104bad30fSLiu Zhe 	}
45204bad30fSLiu Zhe 
45304bad30fSLiu Zhe 	/**
45404bad30fSLiu Zhe 	 * test Allow whole number, less than or equal to in Validity.
45504bad30fSLiu Zhe 	 */
45604bad30fSLiu Zhe 	@Test
45704bad30fSLiu Zhe 	public void testAllowWholeNumLessThan() {
45804bad30fSLiu Zhe 
459b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
460b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(1); // "Whole Numbers"
461b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(3); // "less than or equal"
462b4d2d410SLiu Zhe 		scValiditySourceInput.setText("100");
463b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
464b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
465b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
466b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
467b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
468b4d2d410SLiu Zhe 
469b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
470b4d2d410SLiu Zhe 		scInputBarInput.activate();
47104bad30fSLiu Zhe 		typeKeys("99");
47204bad30fSLiu Zhe 		typeKeys("<enter>");
473b4d2d410SLiu Zhe 		assertEquals("99", SCTool.getCellText("A1"));
47404bad30fSLiu Zhe 
475b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
476b4d2d410SLiu Zhe 		scInputBarInput.activate();
47704bad30fSLiu Zhe 		typeKeys("100");
47804bad30fSLiu Zhe 		typeKeys("<enter>");
479b4d2d410SLiu Zhe 		assertEquals("100", SCTool.getCellText("A2"));
48004bad30fSLiu Zhe 
481b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
482b4d2d410SLiu Zhe 		scInputBarInput.activate();
48304bad30fSLiu Zhe 		typeKeys("101");
48404bad30fSLiu Zhe 		typeKeys("<enter>");
48557caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
48657caf934SLiu Zhe 		activeMsgBox.ok();
487b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
48804bad30fSLiu Zhe 
489b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
490b4d2d410SLiu Zhe 		scInputBarInput.activate();
49104bad30fSLiu Zhe 		typeKeys("45.5");
49204bad30fSLiu Zhe 		typeKeys("<enter>");
49357caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
49457caf934SLiu Zhe 		activeMsgBox.ok();
495b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
49604bad30fSLiu Zhe 
497b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
498b4d2d410SLiu Zhe 		scInputBarInput.activate();
49904bad30fSLiu Zhe 		typeKeys("test");
50004bad30fSLiu Zhe 		typeKeys("<enter>");
50157caf934SLiu Zhe 		assertEquals("Invalid value", activeMsgBox.getMessage());
50257caf934SLiu Zhe 		activeMsgBox.ok();
503b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
50404bad30fSLiu Zhe 	}
50504bad30fSLiu Zhe 
50604bad30fSLiu Zhe 	/**
50704bad30fSLiu Zhe 	 * test default message of Error Alert in Validity.
50804bad30fSLiu Zhe 	 */
50904bad30fSLiu Zhe 	@Test
51004bad30fSLiu Zhe 	public void testDefaultErrorAlertMessage() {
51104bad30fSLiu Zhe 
512b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
513b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
514b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
515b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
51604bad30fSLiu Zhe 
517b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
518b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
519b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
520b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
52104bad30fSLiu Zhe 
522b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
523b4d2d410SLiu Zhe 		scInputBarInput.activate();
52404bad30fSLiu Zhe 		typeKeys("13");
52504bad30fSLiu Zhe 		typeKeys("<enter>");
52657caf934SLiu Zhe 		assertEquals("OpenOffice.org Calc", activeMsgBox.getCaption());
52722a14f28SLiu Zhe 		// assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not
52822a14f28SLiu Zhe 		// verify in multi-language
52957caf934SLiu Zhe 		activeMsgBox.ok();
530b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
53104bad30fSLiu Zhe 	}
53204bad30fSLiu Zhe 
53304bad30fSLiu Zhe 	/**
53404bad30fSLiu Zhe 	 * test uncheck Error Alert in Validity.
53504bad30fSLiu Zhe 	 */
53604bad30fSLiu Zhe 	@Test
53704bad30fSLiu Zhe 	public void testUncheckErrorAlert() {
53804bad30fSLiu Zhe 
539b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
540b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
541b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
542b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
54304bad30fSLiu Zhe 
544b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
545b4d2d410SLiu Zhe 		scValidityShowErrorMessage.uncheck();
546b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
547b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
54804bad30fSLiu Zhe 
549b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
55004bad30fSLiu Zhe 		typeKeys("13");
55104bad30fSLiu Zhe 		typeKeys("<enter>");
552b4d2d410SLiu Zhe 		assertEquals("13", SCTool.getCellText("A1"));
55304bad30fSLiu Zhe 	}
55404bad30fSLiu Zhe 
55504bad30fSLiu Zhe 	/**
55604bad30fSLiu Zhe 	 * test Cell range source picker in Validity. Input from Edit Box.
55704bad30fSLiu Zhe 	 */
55804bad30fSLiu Zhe 	@Test
55904bad30fSLiu Zhe 	public void testValidityCellRangeSourcePicker() {
56004bad30fSLiu Zhe 
561b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
562b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
563b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
564b4d2d410SLiu Zhe 		assertEquals(false, scValidityCriteriaAllowList.exists());
565b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$2:$G$5");
566b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
567b4d2d410SLiu Zhe 		assertEquals(true, scValidityCriteriaAllowList.exists());
568b4d2d410SLiu Zhe 
569b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
570b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
571b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
572b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
573b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value.");
574b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
57504bad30fSLiu Zhe 
57604bad30fSLiu Zhe 		// calc.focus();
577b4d2d410SLiu Zhe 		SCTool.selectRange("E2");
578b4d2d410SLiu Zhe 		scInputBarInput.activate();
57904bad30fSLiu Zhe 		typeKeys("test");
58004bad30fSLiu Zhe 		typeKeys("<enter>");
58104bad30fSLiu Zhe 
582b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
583b4d2d410SLiu Zhe 		scInputBarInput.activate();
58404bad30fSLiu Zhe 		typeKeys("test32");
58504bad30fSLiu Zhe 		typeKeys("<enter>");
58657caf934SLiu Zhe 		assertEquals("Invalid value.", activeMsgBox.getMessage());
58757caf934SLiu Zhe 		activeMsgBox.ok();
588b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
58904bad30fSLiu Zhe 
590b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
591b4d2d410SLiu Zhe 		scInputBarInput.activate();
59204bad30fSLiu Zhe 		typeKeys("test");
59304bad30fSLiu Zhe 		typeKeys("<enter>");
594b4d2d410SLiu Zhe 		assertEquals("test", SCTool.getCellText("B1"));
59504bad30fSLiu Zhe 	}
59604bad30fSLiu Zhe 
59704bad30fSLiu Zhe 	/**
59804bad30fSLiu Zhe 	 * test Allow Blank cell Checkbox in Validity.
59904bad30fSLiu Zhe 	 */
60004bad30fSLiu Zhe 	@Test
60104bad30fSLiu Zhe 	public void testAllowBlankCells() {
602b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
603b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
604b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$1:$E$5");
605b4d2d410SLiu Zhe 		scValidityAllowBlankCells.check();
606b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
60704bad30fSLiu Zhe 
608b4d2d410SLiu Zhe 		SCTool.selectRange("E1");
60904bad30fSLiu Zhe 		typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>");
61004bad30fSLiu Zhe 
611b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
61204bad30fSLiu Zhe 		typeKeys("A<enter>");
613b4d2d410SLiu Zhe 		SCTool.selectRange("D1");
614b4d2d410SLiu Zhe 		scInputBarInput.activate();
61504bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
616b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("D1"));
61704bad30fSLiu Zhe 
618b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
6193816404dSLiu Zhe 		app.dispatch(".uno:Validation");
620b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
621b4d2d410SLiu Zhe 		scValidityAllowBlankCells.uncheck();
62204bad30fSLiu Zhe 		typeKeys("<enter>");
62304bad30fSLiu Zhe 
624b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
625b4d2d410SLiu Zhe 		scInputBarInput.activate();
62604bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
62704bad30fSLiu Zhe 		typeKeys("<enter>");
62804bad30fSLiu Zhe 	}
62904bad30fSLiu Zhe }
630