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 
22*80a6f5c5SLiu 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 java.io.File;
2904bad30fSLiu Zhe 
3004bad30fSLiu Zhe import org.junit.After;
3104bad30fSLiu Zhe import org.junit.Before;
3204bad30fSLiu Zhe import org.junit.Ignore;
3322a14f28SLiu Zhe import org.junit.Rule;
3404bad30fSLiu Zhe import org.junit.Test;
3522a14f28SLiu Zhe import org.openoffice.test.common.Logger;
3604bad30fSLiu Zhe import org.openoffice.test.vcl.IDList;
3704bad30fSLiu Zhe import org.openoffice.test.vcl.widgets.VclMessageBox;
3804bad30fSLiu Zhe 
39b4d2d410SLiu Zhe import testlib.gui.SCTool;
4004bad30fSLiu Zhe 
4104bad30fSLiu Zhe public class ValidityDialogSetting {
4204bad30fSLiu Zhe 	private static IDList idList = new IDList(new File("./ids"));
4304bad30fSLiu Zhe 	public static final VclMessageBox ActiveMsgBox = new VclMessageBox(idList.getId("UID_ACTIVE"), "Message on message box.");
4404bad30fSLiu Zhe 
4504bad30fSLiu Zhe 	@Rule
4622a14f28SLiu Zhe 	public Logger log = Logger.getLogger(this);
4704bad30fSLiu Zhe 
4804bad30fSLiu Zhe 	@Before
4904bad30fSLiu Zhe 	public void setUp() throws Exception {
504d3496b1SLiu Zhe 		app.start(true);
5104bad30fSLiu Zhe 
5204bad30fSLiu Zhe 		// New a spreadsheet, select cell range, open Validity dialog
533816404dSLiu Zhe 		app.dispatch("private:factory/scalc");
54d8cae8adSLiu Zhe 		calc.waitForExistence(10, 2);
55b4d2d410SLiu Zhe 		SCTool.selectRange("A1:C5");
563816404dSLiu Zhe 		app.dispatch(".uno:Validation");
5704bad30fSLiu Zhe 	}
5804bad30fSLiu Zhe 
5904bad30fSLiu Zhe 	@After
6004bad30fSLiu Zhe 	public void tearDown() throws Exception {
6122a14f28SLiu Zhe 
6204bad30fSLiu Zhe 	}
6304bad30fSLiu Zhe 
6404bad30fSLiu Zhe 	/**
6504bad30fSLiu Zhe 	 * test Allow not between Date type in Validity.
6604bad30fSLiu Zhe 	 */
6704bad30fSLiu Zhe 	@Test
6804bad30fSLiu Zhe 	public void testAllowDateNotBetween() {
69b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
70b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(3); // "Date"
71b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(7); // "not between"
72b4d2d410SLiu Zhe 		scValiditySourceInput.setText("01/01/08");
73b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("03/01/08");
74b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
75b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
76b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
77b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
78b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
79b4d2d410SLiu Zhe 
80b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
81b4d2d410SLiu Zhe 		scInputBarInput.activate();
8204bad30fSLiu Zhe 		typeKeys("12/31/07");
8304bad30fSLiu Zhe 		typeKeys("<enter>");
84b4d2d410SLiu Zhe 		assertEquals("12/31/07", SCTool.getCellText("A1"));
8504bad30fSLiu Zhe 
86b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
87b4d2d410SLiu Zhe 		scInputBarInput.activate();
8804bad30fSLiu Zhe 		typeKeys("03/02/08");
8904bad30fSLiu Zhe 		typeKeys("<enter>");
90b4d2d410SLiu Zhe 		assertEquals("03/02/08", SCTool.getCellText("A2"));
9104bad30fSLiu Zhe 
92b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
93b4d2d410SLiu Zhe 		scInputBarInput.activate();
9404bad30fSLiu Zhe 		typeKeys("01/01/08");
9504bad30fSLiu Zhe 		typeKeys("<enter>");
9622a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
9704bad30fSLiu Zhe 		ActiveMsgBox.ok();
98b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
9904bad30fSLiu Zhe 
100b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
101b4d2d410SLiu Zhe 		scInputBarInput.activate();
10204bad30fSLiu Zhe 		typeKeys("03/01/08");
10304bad30fSLiu Zhe 		typeKeys("<enter>");
10422a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
10504bad30fSLiu Zhe 		ActiveMsgBox.ok();
106b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
10704bad30fSLiu Zhe 
108b4d2d410SLiu Zhe 		SCTool.selectRange("A5");
109b4d2d410SLiu Zhe 		scInputBarInput.activate();
11004bad30fSLiu Zhe 		typeKeys("01/02/08");
11104bad30fSLiu Zhe 		typeKeys("<enter>");
11222a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
11304bad30fSLiu Zhe 		ActiveMsgBox.ok();
114b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A5"));
11504bad30fSLiu Zhe 
116b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
117b4d2d410SLiu Zhe 		scInputBarInput.activate();
11804bad30fSLiu Zhe 		typeKeys("02/29/08");
11904bad30fSLiu Zhe 		typeKeys("<enter>");
12022a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
12104bad30fSLiu Zhe 		ActiveMsgBox.ok();
122b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
12304bad30fSLiu Zhe 
124b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
125b4d2d410SLiu Zhe 		scInputBarInput.activate();
12604bad30fSLiu Zhe 		typeKeys("test");
12704bad30fSLiu Zhe 		typeKeys("<enter>");
12822a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
12904bad30fSLiu Zhe 		ActiveMsgBox.ok();
130b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
13104bad30fSLiu Zhe 
132b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
133b4d2d410SLiu Zhe 		scInputBarInput.activate();
13404bad30fSLiu Zhe 		typeKeys("39448");
13504bad30fSLiu Zhe 		typeKeys("<enter>");
13622a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
13704bad30fSLiu Zhe 		ActiveMsgBox.ok();
138b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
13904bad30fSLiu Zhe 	}
14004bad30fSLiu Zhe 
14104bad30fSLiu Zhe 	/**
14204bad30fSLiu Zhe 	 * test Allow Decimal equal in Validity.
14304bad30fSLiu Zhe 	 */
14404bad30fSLiu Zhe 	@Test
14504bad30fSLiu Zhe 	public void testAllowDecimalEqual() {
14604bad30fSLiu Zhe 
147b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
148b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
149b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
150b4d2d410SLiu Zhe 		scValiditySourceInput.setText("0.33333333");
151b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
152b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
153b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
154b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
155b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
156b4d2d410SLiu Zhe 
157b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
158b4d2d410SLiu Zhe 		scInputBarInput.activate();
15904bad30fSLiu Zhe 		typeKeys("0.33333333");
16004bad30fSLiu Zhe 		typeKeys("<enter>");
161b4d2d410SLiu Zhe 		assertEquals("0.33333333", SCTool.getCellText("A1"));
16204bad30fSLiu Zhe 
163b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
164b4d2d410SLiu Zhe 		scInputBarInput.activate();
16504bad30fSLiu Zhe 		typeKeys("=1/3");
16604bad30fSLiu Zhe 		typeKeys("<enter>");
16722a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
16804bad30fSLiu Zhe 		ActiveMsgBox.ok();
169b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
17004bad30fSLiu Zhe 
171b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
172b4d2d410SLiu Zhe 		scInputBarInput.activate();
17304bad30fSLiu Zhe 		typeKeys("0.3");
17404bad30fSLiu Zhe 		typeKeys("<enter>");
17522a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
17604bad30fSLiu Zhe 		ActiveMsgBox.ok();
177b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
17804bad30fSLiu Zhe 
179b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
180b4d2d410SLiu Zhe 		scInputBarInput.activate();
18104bad30fSLiu Zhe 		typeKeys("0.333333333");
18204bad30fSLiu Zhe 		typeKeys("<enter>");
18322a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
18404bad30fSLiu Zhe 		ActiveMsgBox.ok();
185b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
18604bad30fSLiu Zhe 
187b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
188b4d2d410SLiu Zhe 		scInputBarInput.activate();
18904bad30fSLiu Zhe 		typeKeys("test");
19004bad30fSLiu Zhe 		typeKeys("<enter>");
19122a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
19204bad30fSLiu Zhe 		ActiveMsgBox.ok();
193b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
19404bad30fSLiu Zhe 	}
19504bad30fSLiu Zhe 
19604bad30fSLiu Zhe 	/**
19722a14f28SLiu Zhe 	 * test Allow Text length, greater than or equal to in Validity.
19804bad30fSLiu Zhe 	 */
19904bad30fSLiu Zhe 	@Test
20004bad30fSLiu Zhe 	public void testAllowGreaterTextLength() {
20104bad30fSLiu Zhe 
202b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
203b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
204b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
205b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
206b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
207b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
208b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
209b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
210b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
211b4d2d410SLiu Zhe 
212b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
213b4d2d410SLiu Zhe 		scInputBarInput.activate();
21404bad30fSLiu Zhe 		typeKeys("testtesttesttest");
21504bad30fSLiu Zhe 		typeKeys("<enter>");
216b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
21704bad30fSLiu Zhe 
218b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
219b4d2d410SLiu Zhe 		scInputBarInput.activate();
22004bad30fSLiu Zhe 		typeKeys("test test ");
22104bad30fSLiu Zhe 		typeKeys("<enter>");
222b4d2d410SLiu Zhe 		assertEquals("test test ", SCTool.getCellText("A2"));
22304bad30fSLiu Zhe 
224b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
225b4d2d410SLiu Zhe 		scInputBarInput.activate();
22604bad30fSLiu Zhe 		typeKeys(" ");
22704bad30fSLiu Zhe 		typeKeys("<enter>");
22822a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
22904bad30fSLiu Zhe 		ActiveMsgBox.ok();
230b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A4"));
23104bad30fSLiu Zhe 
232b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
233b4d2d410SLiu Zhe 		scInputBarInput.activate();
23404bad30fSLiu Zhe 		typeKeys("Testatest");
23504bad30fSLiu Zhe 		typeKeys("<enter>");
23622a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
23704bad30fSLiu Zhe 		ActiveMsgBox.ok();
238b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A3"));
23904bad30fSLiu Zhe 	}
24004bad30fSLiu Zhe 
24104bad30fSLiu Zhe 	/**
24222a14f28SLiu Zhe 	 * test Allow Text length, less than in Validity.
24304bad30fSLiu Zhe 	 */
24404bad30fSLiu Zhe 	@Ignore("Bug 93128")
24504bad30fSLiu Zhe 	public void testAllowLessThanTextLength() {
24604bad30fSLiu Zhe 
2473816404dSLiu Zhe 		app.dispatch(".uno:Validation");
24804bad30fSLiu Zhe 
249b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
250b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(7); // "Text length"
251b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(1); // "less than"
252b4d2d410SLiu Zhe 		scValiditySourceInput.setText("10");
253b4d2d410SLiu Zhe 
254b4d2d410SLiu Zhe 		scValidityInputHelpTabPage.select();
255b4d2d410SLiu Zhe 		scValidityInputHelpCheckbox.check();
256b4d2d410SLiu Zhe 		scValidityInputHelpTitle.setText("Help Info Title");
257b4d2d410SLiu Zhe 		scValidityHelpMessage.setText("help info");
258b4d2d410SLiu Zhe 
259b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
260b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
261b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select("Information");
262b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Notes to enter");
263b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
264b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
265b4d2d410SLiu Zhe 
266b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
267b4d2d410SLiu Zhe 		scInputBarInput.activate();
26804bad30fSLiu Zhe 		typeKeys("testtesttesttest<enter>");
26904bad30fSLiu Zhe 		ActiveMsgBox.ok();
270b4d2d410SLiu Zhe 		assertEquals("testtesttesttest", SCTool.getCellText("A1"));
27104bad30fSLiu Zhe 
272b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
273b4d2d410SLiu Zhe 		scInputBarInput.activate();
27404bad30fSLiu Zhe 		typeKeys("sfsafsddddddd<enter>");
27504bad30fSLiu Zhe 		ActiveMsgBox.cancel();
276b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
27704bad30fSLiu Zhe 
278b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
279b4d2d410SLiu Zhe 		scInputBarInput.activate();
28004bad30fSLiu Zhe 		typeKeys("10<enter>");
281b4d2d410SLiu Zhe 		assertEquals("10", SCTool.getCellText("A2"));
28204bad30fSLiu Zhe 
283b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
284b4d2d410SLiu Zhe 		scInputBarInput.activate();
28504bad30fSLiu Zhe 		typeKeys("ok<enter>");
286b4d2d410SLiu Zhe 		assertEquals("ok", SCTool.getCellText("A3"));
28704bad30fSLiu Zhe 	}
28804bad30fSLiu Zhe 
28904bad30fSLiu Zhe 	/**
29004bad30fSLiu Zhe 	 * test Allow list.
29104bad30fSLiu Zhe 	 */
29204bad30fSLiu Zhe 	@Test
29304bad30fSLiu Zhe 	public void testAllowListSpecialChar() {
29404bad30fSLiu Zhe 
295b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
296b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(6); // "List"
297b4d2d410SLiu Zhe 		scValidityEntries.focus();
29804bad30fSLiu Zhe 		typeKeys("a");
29904bad30fSLiu Zhe 		typeKeys("<enter>");
30004bad30fSLiu Zhe 		typeKeys("b");
301b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
302b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
303b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
304b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
305b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
306b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
30704bad30fSLiu Zhe 
3084d3496b1SLiu Zhe 		// These codes are not stable: start
30922a14f28SLiu Zhe 		// calc.rightClick(1, 1);
31022a14f28SLiu Zhe 		// typeKeys("<shift s>");
31122a14f28SLiu Zhe 		// typeKeys("<down><enter>"); // Choose a
31222a14f28SLiu Zhe 		// sleep(2); // if no sleep, error occur
3134d3496b1SLiu Zhe 		// These codes are not stable: end
314b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
315b4d2d410SLiu Zhe 		scInputBarInput.activate();
3164d3496b1SLiu Zhe 		typeKeys("a<enter>");
317b4d2d410SLiu Zhe 		assertEquals("a", SCTool.getCellText("A1"));
31804bad30fSLiu Zhe 
319b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
320b4d2d410SLiu Zhe 		scInputBarInput.activate();
32104bad30fSLiu Zhe 		typeKeys("test");
32204bad30fSLiu Zhe 		typeKeys("<enter>");
32322a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
32404bad30fSLiu Zhe 		ActiveMsgBox.ok();
325b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
32604bad30fSLiu Zhe 	}
32704bad30fSLiu Zhe 
32804bad30fSLiu Zhe 	/**
32922a14f28SLiu Zhe 	 * test Allow time between in Validity.
33004bad30fSLiu Zhe 	 */
33104bad30fSLiu Zhe 	@Test
33204bad30fSLiu Zhe 	public void testAllowTimeBetween() {
33304bad30fSLiu Zhe 
334b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
335b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
336b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(6); // "between"
337b4d2d410SLiu Zhe 		scValiditySourceInput.setText("27:00");
338b4d2d410SLiu Zhe 		scValidityMaxValueInput.setText("21:00");
339b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
340b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
341b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
342b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
343b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
344b4d2d410SLiu Zhe 
345b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
346b4d2d410SLiu Zhe 		scInputBarInput.activate();
34704bad30fSLiu Zhe 		typeKeys("21:00");
34804bad30fSLiu Zhe 		typeKeys("<enter>");
349b4d2d410SLiu Zhe 		assertEquals("09:00:00 PM", SCTool.getCellText("A1"));
35004bad30fSLiu Zhe 
351b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
352b4d2d410SLiu Zhe 		scInputBarInput.activate();
35304bad30fSLiu Zhe 		typeKeys("27:00");
35404bad30fSLiu Zhe 		typeKeys("<enter>");
355b4d2d410SLiu Zhe 		assertEquals("27:00:00", SCTool.getCellText("A2"));
35604bad30fSLiu Zhe 
357b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
358b4d2d410SLiu Zhe 		scInputBarInput.activate();
35904bad30fSLiu Zhe 		typeKeys("1.125");
36004bad30fSLiu Zhe 		typeKeys("<enter>");
361b4d2d410SLiu Zhe 		assertEquals("1.125", SCTool.getCellText("A3"));
36204bad30fSLiu Zhe 
363b4d2d410SLiu Zhe 		SCTool.selectRange("A4");
364b4d2d410SLiu Zhe 		scInputBarInput.activate();
36504bad30fSLiu Zhe 		typeKeys("0.875");
36604bad30fSLiu Zhe 		typeKeys("<enter>");
367b4d2d410SLiu Zhe 		assertEquals("0.875", SCTool.getCellText("A4"));
36804bad30fSLiu Zhe 
369b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
370b4d2d410SLiu Zhe 		scInputBarInput.activate();
37104bad30fSLiu Zhe 		typeKeys("03:00:01");
37204bad30fSLiu Zhe 		typeKeys("<enter>");
37322a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
37404bad30fSLiu Zhe 		ActiveMsgBox.ok();
375b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
37604bad30fSLiu Zhe 
377b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
378b4d2d410SLiu Zhe 		scInputBarInput.activate();
37904bad30fSLiu Zhe 		typeKeys("20:59:59");
38004bad30fSLiu Zhe 		typeKeys("<enter>");
38122a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
38204bad30fSLiu Zhe 		ActiveMsgBox.ok();
383b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
38404bad30fSLiu Zhe 
385b4d2d410SLiu Zhe 		SCTool.selectRange("B3");
386b4d2d410SLiu Zhe 		scInputBarInput.activate();
38704bad30fSLiu Zhe 		typeKeys("1.126");
38804bad30fSLiu Zhe 		typeKeys("<enter>");
38922a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
39004bad30fSLiu Zhe 		ActiveMsgBox.ok();
391b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B3"));
39204bad30fSLiu Zhe 
393b4d2d410SLiu Zhe 		SCTool.selectRange("B4");
394b4d2d410SLiu Zhe 		scInputBarInput.activate();
39504bad30fSLiu Zhe 		typeKeys("0.874");
39604bad30fSLiu Zhe 		typeKeys("<enter>");
39722a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
39804bad30fSLiu Zhe 		ActiveMsgBox.ok();
399b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B4"));
40004bad30fSLiu Zhe 
401b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
402b4d2d410SLiu Zhe 		scInputBarInput.activate();
40304bad30fSLiu Zhe 		typeKeys("test");
40404bad30fSLiu Zhe 		typeKeys("<enter>");
40522a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
40604bad30fSLiu Zhe 		ActiveMsgBox.ok();
407b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
40804bad30fSLiu Zhe 
409b4d2d410SLiu Zhe 		SCTool.selectRange("C2");
410b4d2d410SLiu Zhe 		scInputBarInput.activate();
41104bad30fSLiu Zhe 		typeKeys("24:00");
41204bad30fSLiu Zhe 		typeKeys("<enter>");
413b4d2d410SLiu Zhe 		assertEquals("24:00:00", SCTool.getCellText("C2"));
41404bad30fSLiu Zhe 
415b4d2d410SLiu Zhe 		SCTool.selectRange("C3");
416b4d2d410SLiu Zhe 		scInputBarInput.activate();
41704bad30fSLiu Zhe 		typeKeys("12:00");
41804bad30fSLiu Zhe 		typeKeys("<enter>");
41922a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
42004bad30fSLiu Zhe 		ActiveMsgBox.ok();
421b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C3"));
42204bad30fSLiu Zhe 	}
42304bad30fSLiu Zhe 
42404bad30fSLiu Zhe 	/**
42522a14f28SLiu Zhe 	 * test Allow time Greater than and equal to in Validity.
42604bad30fSLiu Zhe 	 */
42704bad30fSLiu Zhe 	@Test
42804bad30fSLiu Zhe 	public void testAllowTimeGreaterThan() {
42904bad30fSLiu Zhe 
430b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
431b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(4); // "Time"
432b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
433b4d2d410SLiu Zhe 		scValiditySourceInput.setText("8:00");
43404bad30fSLiu Zhe 
435b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
436b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
437b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(1); // "Warning"
43804bad30fSLiu Zhe 
439b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("warning to enter");
440b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
441b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
44204bad30fSLiu Zhe 
443b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
444b4d2d410SLiu Zhe 		scInputBarInput.activate();
44504bad30fSLiu Zhe 		typeKeys("7:30");
44604bad30fSLiu Zhe 		typeKeys("<enter>");
44722a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
44804bad30fSLiu Zhe 		ActiveMsgBox.ok();
449b4d2d410SLiu Zhe 		assertEquals("07:30:00 AM", SCTool.getCellText("A1"));
45004bad30fSLiu Zhe 
451b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
452b4d2d410SLiu Zhe 		scInputBarInput.activate();
45304bad30fSLiu Zhe 		typeKeys("6:00");
45404bad30fSLiu Zhe 		typeKeys("<enter>");
45522a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
45604bad30fSLiu Zhe 		ActiveMsgBox.cancel();
457b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A2"));
45804bad30fSLiu Zhe 
459b4d2d410SLiu Zhe 		SCTool.selectRange("A3");
460b4d2d410SLiu Zhe 		scInputBarInput.activate();
46104bad30fSLiu Zhe 		typeKeys("8:00");
46204bad30fSLiu Zhe 		typeKeys("<enter>");
463b4d2d410SLiu Zhe 		assertEquals("08:00:00 AM", SCTool.getCellText("A3"));
46404bad30fSLiu Zhe 	}
46504bad30fSLiu Zhe 
46604bad30fSLiu Zhe 	/**
46704bad30fSLiu Zhe 	 * test Allow whole number, less than or equal to in Validity.
46804bad30fSLiu Zhe 	 */
46904bad30fSLiu Zhe 	@Test
47004bad30fSLiu Zhe 	public void testAllowWholeNumLessThan() {
47104bad30fSLiu Zhe 
472b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
473b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(1); // "Whole Numbers"
474b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(3); // "less than or equal"
475b4d2d410SLiu Zhe 		scValiditySourceInput.setText("100");
476b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
477b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
478b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
479b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value");
480b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
481b4d2d410SLiu Zhe 
482b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
483b4d2d410SLiu Zhe 		scInputBarInput.activate();
48404bad30fSLiu Zhe 		typeKeys("99");
48504bad30fSLiu Zhe 		typeKeys("<enter>");
486b4d2d410SLiu Zhe 		assertEquals("99", SCTool.getCellText("A1"));
48704bad30fSLiu Zhe 
488b4d2d410SLiu Zhe 		SCTool.selectRange("A2");
489b4d2d410SLiu Zhe 		scInputBarInput.activate();
49004bad30fSLiu Zhe 		typeKeys("100");
49104bad30fSLiu Zhe 		typeKeys("<enter>");
492b4d2d410SLiu Zhe 		assertEquals("100", SCTool.getCellText("A2"));
49304bad30fSLiu Zhe 
494b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
495b4d2d410SLiu Zhe 		scInputBarInput.activate();
49604bad30fSLiu Zhe 		typeKeys("101");
49704bad30fSLiu Zhe 		typeKeys("<enter>");
49822a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
49904bad30fSLiu Zhe 		ActiveMsgBox.ok();
500b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B1"));
50104bad30fSLiu Zhe 
502b4d2d410SLiu Zhe 		SCTool.selectRange("B2");
503b4d2d410SLiu Zhe 		scInputBarInput.activate();
50404bad30fSLiu Zhe 		typeKeys("45.5");
50504bad30fSLiu Zhe 		typeKeys("<enter>");
50622a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
50704bad30fSLiu Zhe 		ActiveMsgBox.ok();
508b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("B2"));
50904bad30fSLiu Zhe 
510b4d2d410SLiu Zhe 		SCTool.selectRange("C1");
511b4d2d410SLiu Zhe 		scInputBarInput.activate();
51204bad30fSLiu Zhe 		typeKeys("test");
51304bad30fSLiu Zhe 		typeKeys("<enter>");
51422a14f28SLiu Zhe 		assertEquals("Invalid value", ActiveMsgBox.getMessage());
51504bad30fSLiu Zhe 		ActiveMsgBox.ok();
516b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("C1"));
51704bad30fSLiu Zhe 	}
51804bad30fSLiu Zhe 
51904bad30fSLiu Zhe 	/**
52004bad30fSLiu Zhe 	 * test default message of Error Alert in Validity.
52104bad30fSLiu Zhe 	 */
52204bad30fSLiu Zhe 	@Test
52304bad30fSLiu Zhe 	public void testDefaultErrorAlertMessage() {
52404bad30fSLiu Zhe 
525b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
526b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
527b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
528b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
52904bad30fSLiu Zhe 
530b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
531b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
532b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
533b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
53404bad30fSLiu Zhe 
535b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
536b4d2d410SLiu Zhe 		scInputBarInput.activate();
53704bad30fSLiu Zhe 		typeKeys("13");
53804bad30fSLiu Zhe 		typeKeys("<enter>");
53922a14f28SLiu Zhe 		assertEquals("OpenOffice.org Calc", ActiveMsgBox.getCaption());
54022a14f28SLiu Zhe 		// assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not
54122a14f28SLiu Zhe 		// verify in multi-language
54204bad30fSLiu Zhe 		ActiveMsgBox.ok();
543b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
54404bad30fSLiu Zhe 	}
54504bad30fSLiu Zhe 
54604bad30fSLiu Zhe 	/**
54704bad30fSLiu Zhe 	 * test uncheck Error Alert in Validity.
54804bad30fSLiu Zhe 	 */
54904bad30fSLiu Zhe 	@Test
55004bad30fSLiu Zhe 	public void testUncheckErrorAlert() {
55104bad30fSLiu Zhe 
552b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
553b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(2); // "Decimal"
554b4d2d410SLiu Zhe 		scValidityDecimalCompareOperator.select(0); // "equal"
555b4d2d410SLiu Zhe 		scValiditySourceInput.setText("1");
55604bad30fSLiu Zhe 
557b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
558b4d2d410SLiu Zhe 		scValidityShowErrorMessage.uncheck();
559b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
560b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
56104bad30fSLiu Zhe 
562b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
56304bad30fSLiu Zhe 		typeKeys("13");
56404bad30fSLiu Zhe 		typeKeys("<enter>");
565b4d2d410SLiu Zhe 		assertEquals("13", SCTool.getCellText("A1"));
56604bad30fSLiu Zhe 	}
56704bad30fSLiu Zhe 
56804bad30fSLiu Zhe 	/**
56904bad30fSLiu Zhe 	 * test Cell range source picker in Validity. Input from Edit Box.
57004bad30fSLiu Zhe 	 */
57104bad30fSLiu Zhe 	@Test
57204bad30fSLiu Zhe 	public void testValidityCellRangeSourcePicker() {
57304bad30fSLiu Zhe 
574b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
575b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
576b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
577b4d2d410SLiu Zhe 		assertEquals(false, scValidityCriteriaAllowList.exists());
578b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$2:$G$5");
579b4d2d410SLiu Zhe 		scValiditySourcePicker.click();
580b4d2d410SLiu Zhe 		assertEquals(true, scValidityCriteriaAllowList.exists());
581b4d2d410SLiu Zhe 
582b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.select();
583b4d2d410SLiu Zhe 		scValidityShowErrorMessage.check();
584b4d2d410SLiu Zhe 		scValidityErrorAlertActionList.select(0); // "Stop"
585b4d2d410SLiu Zhe 		scValidityErrorMessageTitle.setText("Stop to enter");
586b4d2d410SLiu Zhe 		scValidityErrorMessage.setText("Invalid value.");
587b4d2d410SLiu Zhe 		scValidityErrorAlertTabPage.ok();
58804bad30fSLiu Zhe 
58904bad30fSLiu Zhe 		// calc.focus();
590b4d2d410SLiu Zhe 		SCTool.selectRange("E2");
591b4d2d410SLiu Zhe 		scInputBarInput.activate();
59204bad30fSLiu Zhe 		typeKeys("test");
59304bad30fSLiu Zhe 		typeKeys("<enter>");
59404bad30fSLiu Zhe 
595b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
596b4d2d410SLiu Zhe 		scInputBarInput.activate();
59704bad30fSLiu Zhe 		typeKeys("test32");
59804bad30fSLiu Zhe 		typeKeys("<enter>");
59922a14f28SLiu Zhe 		assertEquals("Invalid value.", ActiveMsgBox.getMessage());
60004bad30fSLiu Zhe 		ActiveMsgBox.ok();
601b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("A1"));
60204bad30fSLiu Zhe 
603b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
604b4d2d410SLiu Zhe 		scInputBarInput.activate();
60504bad30fSLiu Zhe 		typeKeys("test");
60604bad30fSLiu Zhe 		typeKeys("<enter>");
607b4d2d410SLiu Zhe 		assertEquals("test", SCTool.getCellText("B1"));
60804bad30fSLiu Zhe 	}
60904bad30fSLiu Zhe 
61004bad30fSLiu Zhe 	/**
61104bad30fSLiu Zhe 	 * test Allow Blank cell Checkbox in Validity.
61204bad30fSLiu Zhe 	 */
61304bad30fSLiu Zhe 	@Test
61404bad30fSLiu Zhe 	public void testAllowBlankCells() {
615b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
616b4d2d410SLiu Zhe 		scValidityCriteriaAllowList.select(5); // "Cell range"
617b4d2d410SLiu Zhe 		scValiditySourceInput.setText("$E$1:$E$5");
618b4d2d410SLiu Zhe 		scValidityAllowBlankCells.check();
619b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.ok();
62004bad30fSLiu Zhe 
621b4d2d410SLiu Zhe 		SCTool.selectRange("E1");
62204bad30fSLiu Zhe 		typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>");
62304bad30fSLiu Zhe 
624b4d2d410SLiu Zhe 		SCTool.selectRange("A1");
62504bad30fSLiu Zhe 		typeKeys("A<enter>");
626b4d2d410SLiu Zhe 		SCTool.selectRange("D1");
627b4d2d410SLiu Zhe 		scInputBarInput.activate();
62804bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
629b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("D1"));
63004bad30fSLiu Zhe 
631b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
6323816404dSLiu Zhe 		app.dispatch(".uno:Validation");
633b4d2d410SLiu Zhe 		scValidityCriteriaTabpage.select();
634b4d2d410SLiu Zhe 		scValidityAllowBlankCells.uncheck();
63504bad30fSLiu Zhe 		typeKeys("<enter>");
63604bad30fSLiu Zhe 
637b4d2d410SLiu Zhe 		SCTool.selectRange("B1");
638b4d2d410SLiu Zhe 		scInputBarInput.activate();
63904bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
64004bad30fSLiu Zhe 		typeKeys("<enter>");
64104bad30fSLiu Zhe 	}
64204bad30fSLiu Zhe }
643