xref: /trunk/test/testgui/source/fvt/gui/sc/validity/ValidityDialogSetting.java (revision 3309286857f19787ae62bd793a98b5af4edd2ad3)
180a6f5c5SLiu Zhe /**************************************************************
280a6f5c5SLiu Zhe  *
380a6f5c5SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
480a6f5c5SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
580a6f5c5SLiu Zhe  * distributed with this work for additional information
680a6f5c5SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
780a6f5c5SLiu Zhe  * to you under the Apache License, Version 2.0 (the
880a6f5c5SLiu Zhe  * "License"); you may not use this file except in compliance
980a6f5c5SLiu Zhe  * with the License.  You may obtain a copy of the License at
1080a6f5c5SLiu Zhe  *
1180a6f5c5SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1280a6f5c5SLiu Zhe  *
1380a6f5c5SLiu Zhe  * Unless required by applicable law or agreed to in writing,
1480a6f5c5SLiu Zhe  * software distributed under the License is distributed on an
1580a6f5c5SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1680a6f5c5SLiu Zhe  * KIND, either express or implied.  See the License for the
1780a6f5c5SLiu Zhe  * specific language governing permissions and limitations
1880a6f5c5SLiu Zhe  * under the License.
1980a6f5c5SLiu Zhe  *
2080a6f5c5SLiu Zhe  *************************************************************/
2180a6f5c5SLiu Zhe 
2280a6f5c5SLiu Zhe package fvt.gui.sc.validity;
2380a6f5c5SLiu Zhe 
2480a6f5c5SLiu Zhe import static org.junit.Assert.*;
2580a6f5c5SLiu Zhe import static testlib.gui.AppTool.*;
2680a6f5c5SLiu Zhe import static testlib.gui.UIMap.*;
2780a6f5c5SLiu Zhe 
2880a6f5c5SLiu Zhe import org.junit.After;
2980a6f5c5SLiu Zhe import org.junit.Before;
3080a6f5c5SLiu Zhe import org.junit.Ignore;
3180a6f5c5SLiu Zhe import org.junit.Rule;
3280a6f5c5SLiu Zhe import org.junit.Test;
3380a6f5c5SLiu Zhe import org.openoffice.test.common.Logger;
3480a6f5c5SLiu Zhe 
35424494b0SLi Feng Wang import testlib.gui.AppTool;
3680a6f5c5SLiu Zhe import testlib.gui.SCTool;
3780a6f5c5SLiu Zhe 
3880a6f5c5SLiu Zhe public class ValidityDialogSetting {
3980a6f5c5SLiu Zhe 
40fd348426SLi Feng Wang     @Rule
41fd348426SLi Feng Wang     public Logger log = Logger.getLogger(this);
42fd348426SLi Feng Wang 
4380a6f5c5SLiu Zhe     @Before
setUp()4480a6f5c5SLiu Zhe     public void setUp() throws Exception {
4580a6f5c5SLiu Zhe         app.start(true);
46424494b0SLi Feng Wang         AppTool.newSpreadsheet();
4780a6f5c5SLiu Zhe         SCTool.selectRange("A1:C5");
4880a6f5c5SLiu Zhe         app.dispatch(".uno:Validation");
4980a6f5c5SLiu Zhe     }
5080a6f5c5SLiu Zhe 
5180a6f5c5SLiu Zhe     @After
tearDown()5280a6f5c5SLiu Zhe     public void tearDown() throws Exception {
534a13b48eSLi Feng Wang         app.stop();
5480a6f5c5SLiu Zhe     }
5580a6f5c5SLiu Zhe 
5680a6f5c5SLiu Zhe     /**
5780a6f5c5SLiu Zhe      * test Allow not between Date type in Validity.
5880a6f5c5SLiu Zhe      */
5980a6f5c5SLiu Zhe     @Test
testAllowDateNotBetween()6080a6f5c5SLiu Zhe     public void testAllowDateNotBetween() {
6180a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
6280a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(3); // "Date"
6380a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(7); // "not between"
6480a6f5c5SLiu Zhe         scValiditySourceInput.setText("01/01/08");
6580a6f5c5SLiu Zhe         scValidityMaxValueInput.setText("03/01/08");
6680a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
6780a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
6880a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
6980a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
7080a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
7180a6f5c5SLiu Zhe 
7280a6f5c5SLiu Zhe         SCTool.selectRange("A1");
7380a6f5c5SLiu Zhe         scInputBarInput.activate();
7480a6f5c5SLiu Zhe         typeKeys("12/31/07");
7580a6f5c5SLiu Zhe         typeKeys("<enter>");
7680a6f5c5SLiu Zhe         assertEquals("12/31/07", SCTool.getCellText("A1"));
7780a6f5c5SLiu Zhe 
7880a6f5c5SLiu Zhe         SCTool.selectRange("A2");
7980a6f5c5SLiu Zhe         scInputBarInput.activate();
8080a6f5c5SLiu Zhe         typeKeys("03/02/08");
8180a6f5c5SLiu Zhe         typeKeys("<enter>");
8280a6f5c5SLiu Zhe         assertEquals("03/02/08", SCTool.getCellText("A2"));
8380a6f5c5SLiu Zhe 
8480a6f5c5SLiu Zhe         SCTool.selectRange("A3");
8580a6f5c5SLiu Zhe         scInputBarInput.activate();
8680a6f5c5SLiu Zhe         typeKeys("01/01/08");
8780a6f5c5SLiu Zhe         typeKeys("<enter>");
8857caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
8957caf934SLiu Zhe         activeMsgBox.ok();
9080a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A3"));
9180a6f5c5SLiu Zhe 
9280a6f5c5SLiu Zhe         SCTool.selectRange("A4");
9380a6f5c5SLiu Zhe         scInputBarInput.activate();
9480a6f5c5SLiu Zhe         typeKeys("03/01/08");
9580a6f5c5SLiu Zhe         typeKeys("<enter>");
9657caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
9757caf934SLiu Zhe         activeMsgBox.ok();
9880a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A4"));
9980a6f5c5SLiu Zhe 
10080a6f5c5SLiu Zhe         SCTool.selectRange("A5");
10180a6f5c5SLiu Zhe         scInputBarInput.activate();
10280a6f5c5SLiu Zhe         typeKeys("01/02/08");
10380a6f5c5SLiu Zhe         typeKeys("<enter>");
10457caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
10557caf934SLiu Zhe         activeMsgBox.ok();
10680a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A5"));
10780a6f5c5SLiu Zhe 
10880a6f5c5SLiu Zhe         SCTool.selectRange("B1");
10980a6f5c5SLiu Zhe         scInputBarInput.activate();
11080a6f5c5SLiu Zhe         typeKeys("02/29/08");
11180a6f5c5SLiu Zhe         typeKeys("<enter>");
11257caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
11357caf934SLiu Zhe         activeMsgBox.ok();
11480a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B1"));
11580a6f5c5SLiu Zhe 
11680a6f5c5SLiu Zhe         SCTool.selectRange("B2");
11780a6f5c5SLiu Zhe         scInputBarInput.activate();
11880a6f5c5SLiu Zhe         typeKeys("test");
11980a6f5c5SLiu Zhe         typeKeys("<enter>");
12057caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
12157caf934SLiu Zhe         activeMsgBox.ok();
12280a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
12380a6f5c5SLiu Zhe 
12480a6f5c5SLiu Zhe         SCTool.selectRange("B3");
12580a6f5c5SLiu Zhe         scInputBarInput.activate();
12680a6f5c5SLiu Zhe         typeKeys("39448");
12780a6f5c5SLiu Zhe         typeKeys("<enter>");
12857caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
12957caf934SLiu Zhe         activeMsgBox.ok();
13080a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B3"));
13180a6f5c5SLiu Zhe     }
13280a6f5c5SLiu Zhe 
13380a6f5c5SLiu Zhe     /**
13480a6f5c5SLiu Zhe      * test Allow Decimal equal in Validity.
13580a6f5c5SLiu Zhe      */
13680a6f5c5SLiu Zhe     @Test
testAllowDecimalEqual()13780a6f5c5SLiu Zhe     public void testAllowDecimalEqual() {
13880a6f5c5SLiu Zhe 
13980a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
14080a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(2); // "Decimal"
14180a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(0); // "equal"
14280a6f5c5SLiu Zhe         scValiditySourceInput.setText("0.33333333");
14380a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
14480a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
14580a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
14680a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
14780a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
14880a6f5c5SLiu Zhe 
14980a6f5c5SLiu Zhe         SCTool.selectRange("A1");
15080a6f5c5SLiu Zhe         scInputBarInput.activate();
15180a6f5c5SLiu Zhe         typeKeys("0.33333333");
15280a6f5c5SLiu Zhe         typeKeys("<enter>");
15380a6f5c5SLiu Zhe         assertEquals("0.33333333", SCTool.getCellText("A1"));
15480a6f5c5SLiu Zhe 
15580a6f5c5SLiu Zhe         SCTool.selectRange("A2");
15680a6f5c5SLiu Zhe         scInputBarInput.activate();
15780a6f5c5SLiu Zhe         typeKeys("=1/3");
15880a6f5c5SLiu Zhe         typeKeys("<enter>");
15957caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
16057caf934SLiu Zhe         activeMsgBox.ok();
16180a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A2"));
16280a6f5c5SLiu Zhe 
16380a6f5c5SLiu Zhe         SCTool.selectRange("A3");
16480a6f5c5SLiu Zhe         scInputBarInput.activate();
16580a6f5c5SLiu Zhe         typeKeys("0.3");
16680a6f5c5SLiu Zhe         typeKeys("<enter>");
16757caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
16857caf934SLiu Zhe         activeMsgBox.ok();
16980a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A3"));
17080a6f5c5SLiu Zhe 
17180a6f5c5SLiu Zhe         SCTool.selectRange("A4");
17280a6f5c5SLiu Zhe         scInputBarInput.activate();
17380a6f5c5SLiu Zhe         typeKeys("0.333333333");
17480a6f5c5SLiu Zhe         typeKeys("<enter>");
17557caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
17657caf934SLiu Zhe         activeMsgBox.ok();
17780a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A4"));
17880a6f5c5SLiu Zhe 
17980a6f5c5SLiu Zhe         SCTool.selectRange("B2");
18080a6f5c5SLiu Zhe         scInputBarInput.activate();
18180a6f5c5SLiu Zhe         typeKeys("test");
18280a6f5c5SLiu Zhe         typeKeys("<enter>");
18357caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
18457caf934SLiu Zhe         activeMsgBox.ok();
18580a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
18680a6f5c5SLiu Zhe     }
18780a6f5c5SLiu Zhe 
18880a6f5c5SLiu Zhe     /**
18980a6f5c5SLiu Zhe      * test Allow Text length, greater than or equal to in Validity.
19080a6f5c5SLiu Zhe      */
19180a6f5c5SLiu Zhe     @Test
testAllowGreaterTextLength()19280a6f5c5SLiu Zhe     public void testAllowGreaterTextLength() {
19380a6f5c5SLiu Zhe 
19480a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
19580a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(7); // "Text length"
19680a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
19780a6f5c5SLiu Zhe         scValiditySourceInput.setText("10");
19880a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
19980a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
20080a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
20180a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
20280a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
20380a6f5c5SLiu Zhe 
20480a6f5c5SLiu Zhe         SCTool.selectRange("A1");
20580a6f5c5SLiu Zhe         scInputBarInput.activate();
20680a6f5c5SLiu Zhe         typeKeys("testtesttesttest");
20780a6f5c5SLiu Zhe         typeKeys("<enter>");
20880a6f5c5SLiu Zhe         assertEquals("testtesttesttest", SCTool.getCellText("A1"));
20980a6f5c5SLiu Zhe 
21080a6f5c5SLiu Zhe         SCTool.selectRange("A2");
21180a6f5c5SLiu Zhe         scInputBarInput.activate();
21280a6f5c5SLiu Zhe         typeKeys("test test ");
21380a6f5c5SLiu Zhe         typeKeys("<enter>");
21480a6f5c5SLiu Zhe         assertEquals("test test ", SCTool.getCellText("A2"));
21580a6f5c5SLiu Zhe 
21680a6f5c5SLiu Zhe         SCTool.selectRange("A4");
21780a6f5c5SLiu Zhe         scInputBarInput.activate();
21880a6f5c5SLiu Zhe         typeKeys(" ");
21980a6f5c5SLiu Zhe         typeKeys("<enter>");
22057caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
22157caf934SLiu Zhe         activeMsgBox.ok();
22280a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A4"));
22380a6f5c5SLiu Zhe 
22480a6f5c5SLiu Zhe         SCTool.selectRange("A3");
22580a6f5c5SLiu Zhe         scInputBarInput.activate();
22680a6f5c5SLiu Zhe         typeKeys("Testatest");
22780a6f5c5SLiu Zhe         typeKeys("<enter>");
22857caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
22957caf934SLiu Zhe         activeMsgBox.ok();
23080a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A3"));
23180a6f5c5SLiu Zhe     }
23280a6f5c5SLiu Zhe 
23380a6f5c5SLiu Zhe     /**
23480a6f5c5SLiu Zhe      * test Allow Text length, less than in Validity.
23580a6f5c5SLiu Zhe      */
236708863fbSHerbert Dürr     @Test
testAllowLessThanTextLength()23780a6f5c5SLiu Zhe     public void testAllowLessThanTextLength() {
23880a6f5c5SLiu Zhe 
23980a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
24080a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(7); // "Text length"
24180a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(1); // "less than"
24280a6f5c5SLiu Zhe         scValiditySourceInput.setText("10");
24380a6f5c5SLiu Zhe 
24480a6f5c5SLiu Zhe         scValidityInputHelpTabPage.select();
24580a6f5c5SLiu Zhe         scValidityInputHelpCheckbox.check();
24680a6f5c5SLiu Zhe         scValidityInputHelpTitle.setText("Help Info Title");
24780a6f5c5SLiu Zhe         scValidityHelpMessage.setText("help info");
24880a6f5c5SLiu Zhe 
24980a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
25080a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
25180a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select("Information");
25280a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Notes to enter");
25380a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
25480a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
25580a6f5c5SLiu Zhe 
25680a6f5c5SLiu Zhe         SCTool.selectRange("A1");
25780a6f5c5SLiu Zhe         scInputBarInput.activate();
25880a6f5c5SLiu Zhe         typeKeys("testtesttesttest<enter>");
25957caf934SLiu Zhe         activeMsgBox.ok();
26080a6f5c5SLiu Zhe         assertEquals("testtesttesttest", SCTool.getCellText("A1"));
26180a6f5c5SLiu Zhe 
26280a6f5c5SLiu Zhe         SCTool.selectRange("A2");
26380a6f5c5SLiu Zhe         scInputBarInput.activate();
26480a6f5c5SLiu Zhe         typeKeys("sfsafsddddddd<enter>");
26557caf934SLiu Zhe         activeMsgBox.cancel();
26680a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A2"));
26780a6f5c5SLiu Zhe 
26880a6f5c5SLiu Zhe         SCTool.selectRange("A2");
26980a6f5c5SLiu Zhe         scInputBarInput.activate();
27080a6f5c5SLiu Zhe         typeKeys("10<enter>");
27180a6f5c5SLiu Zhe         assertEquals("10", SCTool.getCellText("A2"));
27280a6f5c5SLiu Zhe 
27380a6f5c5SLiu Zhe         SCTool.selectRange("A3");
27480a6f5c5SLiu Zhe         scInputBarInput.activate();
27580a6f5c5SLiu Zhe         typeKeys("ok<enter>");
27680a6f5c5SLiu Zhe         assertEquals("ok", SCTool.getCellText("A3"));
27780a6f5c5SLiu Zhe     }
27880a6f5c5SLiu Zhe 
27980a6f5c5SLiu Zhe     /**
28080a6f5c5SLiu Zhe      * test Allow list.
28180a6f5c5SLiu Zhe      */
28280a6f5c5SLiu Zhe     @Test
testAllowListSpecialChar()28380a6f5c5SLiu Zhe     public void testAllowListSpecialChar() {
28480a6f5c5SLiu Zhe 
28580a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
28680a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(6); // "List"
28780a6f5c5SLiu Zhe         scValidityEntries.focus();
28880a6f5c5SLiu Zhe         typeKeys("a");
28980a6f5c5SLiu Zhe         typeKeys("<enter>");
29080a6f5c5SLiu Zhe         typeKeys("b");
29180a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
29280a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
29380a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
29480a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
29580a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
29680a6f5c5SLiu Zhe         scValidityCriteriaTabpage.ok();
29780a6f5c5SLiu Zhe 
29880a6f5c5SLiu Zhe         // These codes are not stable: start
29980a6f5c5SLiu Zhe         // calc.rightClick(1, 1);
30080a6f5c5SLiu Zhe         // typeKeys("<shift s>");
30180a6f5c5SLiu Zhe         // typeKeys("<down><enter>"); // Choose a
30280a6f5c5SLiu Zhe         // sleep(2); // if no sleep, error occur
30380a6f5c5SLiu Zhe         // These codes are not stable: end
30480a6f5c5SLiu Zhe         SCTool.selectRange("A1");
30580a6f5c5SLiu Zhe         scInputBarInput.activate();
30680a6f5c5SLiu Zhe         typeKeys("a<enter>");
30780a6f5c5SLiu Zhe         assertEquals("a", SCTool.getCellText("A1"));
30880a6f5c5SLiu Zhe 
30980a6f5c5SLiu Zhe         SCTool.selectRange("B2");
31080a6f5c5SLiu Zhe         scInputBarInput.activate();
31180a6f5c5SLiu Zhe         typeKeys("test");
31280a6f5c5SLiu Zhe         typeKeys("<enter>");
31357caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
31457caf934SLiu Zhe         activeMsgBox.ok();
31580a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
31680a6f5c5SLiu Zhe     }
31780a6f5c5SLiu Zhe 
31880a6f5c5SLiu Zhe     /**
31980a6f5c5SLiu Zhe      * test Allow time between in Validity.
32080a6f5c5SLiu Zhe      */
32180a6f5c5SLiu Zhe     @Test
testAllowTimeBetween()32280a6f5c5SLiu Zhe     public void testAllowTimeBetween() {
32380a6f5c5SLiu Zhe 
32480a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
32580a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(4); // "Time"
32680a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(6); // "between"
32780a6f5c5SLiu Zhe         scValiditySourceInput.setText("27:00");
32880a6f5c5SLiu Zhe         scValidityMaxValueInput.setText("21:00");
32980a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
33080a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
33180a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
33280a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
33380a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
33480a6f5c5SLiu Zhe 
33580a6f5c5SLiu Zhe         SCTool.selectRange("A1");
33680a6f5c5SLiu Zhe         scInputBarInput.activate();
33780a6f5c5SLiu Zhe         typeKeys("21:00");
33880a6f5c5SLiu Zhe         typeKeys("<enter>");
33980a6f5c5SLiu Zhe         assertEquals("09:00:00 PM", SCTool.getCellText("A1"));
34080a6f5c5SLiu Zhe 
34180a6f5c5SLiu Zhe         SCTool.selectRange("A2");
34280a6f5c5SLiu Zhe         scInputBarInput.activate();
34380a6f5c5SLiu Zhe         typeKeys("27:00");
34480a6f5c5SLiu Zhe         typeKeys("<enter>");
34580a6f5c5SLiu Zhe         assertEquals("27:00:00", SCTool.getCellText("A2"));
34680a6f5c5SLiu Zhe 
34780a6f5c5SLiu Zhe         SCTool.selectRange("A3");
34880a6f5c5SLiu Zhe         scInputBarInput.activate();
34980a6f5c5SLiu Zhe         typeKeys("1.125");
35080a6f5c5SLiu Zhe         typeKeys("<enter>");
35180a6f5c5SLiu Zhe         assertEquals("1.125", SCTool.getCellText("A3"));
35280a6f5c5SLiu Zhe 
35380a6f5c5SLiu Zhe         SCTool.selectRange("A4");
35480a6f5c5SLiu Zhe         scInputBarInput.activate();
35580a6f5c5SLiu Zhe         typeKeys("0.875");
35680a6f5c5SLiu Zhe         typeKeys("<enter>");
35780a6f5c5SLiu Zhe         assertEquals("0.875", SCTool.getCellText("A4"));
35880a6f5c5SLiu Zhe 
35980a6f5c5SLiu Zhe         SCTool.selectRange("B1");
36080a6f5c5SLiu Zhe         scInputBarInput.activate();
36180a6f5c5SLiu Zhe         typeKeys("03:00:01");
36280a6f5c5SLiu Zhe         typeKeys("<enter>");
36357caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
36457caf934SLiu Zhe         activeMsgBox.ok();
36580a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B1"));
36680a6f5c5SLiu Zhe 
36780a6f5c5SLiu Zhe         SCTool.selectRange("B2");
36880a6f5c5SLiu Zhe         scInputBarInput.activate();
36980a6f5c5SLiu Zhe         typeKeys("20:59:59");
37080a6f5c5SLiu Zhe         typeKeys("<enter>");
37157caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
37257caf934SLiu Zhe         activeMsgBox.ok();
37380a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
37480a6f5c5SLiu Zhe 
37580a6f5c5SLiu Zhe         SCTool.selectRange("B3");
37680a6f5c5SLiu Zhe         scInputBarInput.activate();
37780a6f5c5SLiu Zhe         typeKeys("1.126");
37880a6f5c5SLiu Zhe         typeKeys("<enter>");
37957caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
38057caf934SLiu Zhe         activeMsgBox.ok();
38180a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B3"));
38280a6f5c5SLiu Zhe 
38380a6f5c5SLiu Zhe         SCTool.selectRange("B4");
38480a6f5c5SLiu Zhe         scInputBarInput.activate();
38580a6f5c5SLiu Zhe         typeKeys("0.874");
38680a6f5c5SLiu Zhe         typeKeys("<enter>");
38757caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
38857caf934SLiu Zhe         activeMsgBox.ok();
38980a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B4"));
39080a6f5c5SLiu Zhe 
39180a6f5c5SLiu Zhe         SCTool.selectRange("C1");
39280a6f5c5SLiu Zhe         scInputBarInput.activate();
39380a6f5c5SLiu Zhe         typeKeys("test");
39480a6f5c5SLiu Zhe         typeKeys("<enter>");
39557caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
39657caf934SLiu Zhe         activeMsgBox.ok();
39780a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("C1"));
39880a6f5c5SLiu Zhe 
39980a6f5c5SLiu Zhe         SCTool.selectRange("C2");
40080a6f5c5SLiu Zhe         scInputBarInput.activate();
40180a6f5c5SLiu Zhe         typeKeys("24:00");
40280a6f5c5SLiu Zhe         typeKeys("<enter>");
40380a6f5c5SLiu Zhe         assertEquals("24:00:00", SCTool.getCellText("C2"));
40480a6f5c5SLiu Zhe 
40580a6f5c5SLiu Zhe         SCTool.selectRange("C3");
40680a6f5c5SLiu Zhe         scInputBarInput.activate();
40780a6f5c5SLiu Zhe         typeKeys("12:00");
40880a6f5c5SLiu Zhe         typeKeys("<enter>");
40957caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
41057caf934SLiu Zhe         activeMsgBox.ok();
41180a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("C3"));
41280a6f5c5SLiu Zhe     }
41380a6f5c5SLiu Zhe 
41480a6f5c5SLiu Zhe     /**
41580a6f5c5SLiu Zhe      * test Allow time Greater than and equal to in Validity.
41680a6f5c5SLiu Zhe      */
41780a6f5c5SLiu Zhe     @Test
testAllowTimeGreaterThan()41880a6f5c5SLiu Zhe     public void testAllowTimeGreaterThan() {
41980a6f5c5SLiu Zhe 
42080a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
42180a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(4); // "Time"
42280a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
42380a6f5c5SLiu Zhe         scValiditySourceInput.setText("8:00");
42480a6f5c5SLiu Zhe 
42580a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
42680a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
42780a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(1); // "Warning"
42880a6f5c5SLiu Zhe 
42980a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("warning to enter");
43080a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
43180a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
43280a6f5c5SLiu Zhe 
43380a6f5c5SLiu Zhe         SCTool.selectRange("A1");
43480a6f5c5SLiu Zhe         scInputBarInput.activate();
43580a6f5c5SLiu Zhe         typeKeys("7:30");
43680a6f5c5SLiu Zhe         typeKeys("<enter>");
43757caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
43857caf934SLiu Zhe         activeMsgBox.ok();
43980a6f5c5SLiu Zhe         assertEquals("07:30:00 AM", SCTool.getCellText("A1"));
44080a6f5c5SLiu Zhe 
44180a6f5c5SLiu Zhe         SCTool.selectRange("A2");
44280a6f5c5SLiu Zhe         scInputBarInput.activate();
44380a6f5c5SLiu Zhe         typeKeys("6:00");
44480a6f5c5SLiu Zhe         typeKeys("<enter>");
44557caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
44657caf934SLiu Zhe         activeMsgBox.cancel();
44780a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A2"));
44880a6f5c5SLiu Zhe 
44980a6f5c5SLiu Zhe         SCTool.selectRange("A3");
45080a6f5c5SLiu Zhe         scInputBarInput.activate();
45180a6f5c5SLiu Zhe         typeKeys("8:00");
45280a6f5c5SLiu Zhe         typeKeys("<enter>");
45380a6f5c5SLiu Zhe         assertEquals("08:00:00 AM", SCTool.getCellText("A3"));
45480a6f5c5SLiu Zhe     }
45580a6f5c5SLiu Zhe 
45680a6f5c5SLiu Zhe     /**
45780a6f5c5SLiu Zhe      * test Allow whole number, less than or equal to in Validity.
45880a6f5c5SLiu Zhe      */
45980a6f5c5SLiu Zhe     @Test
testAllowWholeNumLessThan()46080a6f5c5SLiu Zhe     public void testAllowWholeNumLessThan() {
46180a6f5c5SLiu Zhe 
46280a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
46380a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(1); // "Whole Numbers"
46480a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(3); // "less than or equal"
46580a6f5c5SLiu Zhe         scValiditySourceInput.setText("100");
46680a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
46780a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
46880a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
46980a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
47080a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
47180a6f5c5SLiu Zhe 
47280a6f5c5SLiu Zhe         SCTool.selectRange("A1");
47380a6f5c5SLiu Zhe         scInputBarInput.activate();
47480a6f5c5SLiu Zhe         typeKeys("99");
47580a6f5c5SLiu Zhe         typeKeys("<enter>");
47680a6f5c5SLiu Zhe         assertEquals("99", SCTool.getCellText("A1"));
47780a6f5c5SLiu Zhe 
47880a6f5c5SLiu Zhe         SCTool.selectRange("A2");
47980a6f5c5SLiu Zhe         scInputBarInput.activate();
48080a6f5c5SLiu Zhe         typeKeys("100");
48180a6f5c5SLiu Zhe         typeKeys("<enter>");
48280a6f5c5SLiu Zhe         assertEquals("100", SCTool.getCellText("A2"));
48380a6f5c5SLiu Zhe 
48480a6f5c5SLiu Zhe         SCTool.selectRange("B1");
48580a6f5c5SLiu Zhe         scInputBarInput.activate();
48680a6f5c5SLiu Zhe         typeKeys("101");
48780a6f5c5SLiu Zhe         typeKeys("<enter>");
48857caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
48957caf934SLiu Zhe         activeMsgBox.ok();
49080a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B1"));
49180a6f5c5SLiu Zhe 
49280a6f5c5SLiu Zhe         SCTool.selectRange("B2");
49380a6f5c5SLiu Zhe         scInputBarInput.activate();
49480a6f5c5SLiu Zhe         typeKeys("45.5");
49580a6f5c5SLiu Zhe         typeKeys("<enter>");
49657caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
49757caf934SLiu Zhe         activeMsgBox.ok();
49880a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
49980a6f5c5SLiu Zhe 
50080a6f5c5SLiu Zhe         SCTool.selectRange("C1");
50180a6f5c5SLiu Zhe         scInputBarInput.activate();
50280a6f5c5SLiu Zhe         typeKeys("test");
50380a6f5c5SLiu Zhe         typeKeys("<enter>");
50457caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
50557caf934SLiu Zhe         activeMsgBox.ok();
50680a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("C1"));
50780a6f5c5SLiu Zhe     }
50880a6f5c5SLiu Zhe 
50980a6f5c5SLiu Zhe     /**
51080a6f5c5SLiu Zhe      * test default message of Error Alert in Validity.
51180a6f5c5SLiu Zhe      */
51280a6f5c5SLiu Zhe     @Test
testDefaultErrorAlertMessage()51380a6f5c5SLiu Zhe     public void testDefaultErrorAlertMessage() {
51480a6f5c5SLiu Zhe 
51580a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
51680a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(2); // "Decimal"
51780a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(0); // "equal"
51880a6f5c5SLiu Zhe         scValiditySourceInput.setText("1");
51980a6f5c5SLiu Zhe 
52080a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
52180a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
52280a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(0); // "Stop"
52380a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
52480a6f5c5SLiu Zhe 
52580a6f5c5SLiu Zhe         SCTool.selectRange("A1");
52680a6f5c5SLiu Zhe         scInputBarInput.activate();
52780a6f5c5SLiu Zhe         typeKeys("13");
52880a6f5c5SLiu Zhe         typeKeys("<enter>");
529*78c4b824SHerbert Dürr         assertEquals("OpenOffice Calc", activeMsgBox.getCaption());
53080a6f5c5SLiu Zhe         // assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not
53180a6f5c5SLiu Zhe         // verify in multi-language
53257caf934SLiu Zhe         activeMsgBox.ok();
53380a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A1"));
53480a6f5c5SLiu Zhe     }
53580a6f5c5SLiu Zhe 
53680a6f5c5SLiu Zhe     /**
53780a6f5c5SLiu Zhe      * test uncheck Error Alert in Validity.
53880a6f5c5SLiu Zhe      */
53980a6f5c5SLiu Zhe     @Test
testUncheckErrorAlert()54080a6f5c5SLiu Zhe     public void testUncheckErrorAlert() {
54180a6f5c5SLiu Zhe 
54280a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
54380a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(2); // "Decimal"
54480a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(0); // "equal"
54580a6f5c5SLiu Zhe         scValiditySourceInput.setText("1");
54680a6f5c5SLiu Zhe 
54780a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
54880a6f5c5SLiu Zhe         scValidityShowErrorMessage.uncheck();
54980a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(0); // "Stop"
55080a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
55180a6f5c5SLiu Zhe 
55280a6f5c5SLiu Zhe         SCTool.selectRange("A1");
55380a6f5c5SLiu Zhe         typeKeys("13");
55480a6f5c5SLiu Zhe         typeKeys("<enter>");
55580a6f5c5SLiu Zhe         assertEquals("13", SCTool.getCellText("A1"));
55680a6f5c5SLiu Zhe     }
55780a6f5c5SLiu Zhe 
55880a6f5c5SLiu Zhe     /**
55980a6f5c5SLiu Zhe      * test Cell range source picker in Validity. Input from Edit Box.
56080a6f5c5SLiu Zhe      */
56180a6f5c5SLiu Zhe     @Test
testValidityCellRangeSourcePicker()56280a6f5c5SLiu Zhe     public void testValidityCellRangeSourcePicker() {
56380a6f5c5SLiu Zhe 
56480a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
56580a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(5); // "Cell range"
56680a6f5c5SLiu Zhe         scValiditySourcePicker.click();
56780a6f5c5SLiu Zhe         assertEquals(false, scValidityCriteriaAllowList.exists());
56880a6f5c5SLiu Zhe         scValiditySourceInput.setText("$E$2:$G$5");
56980a6f5c5SLiu Zhe         scValiditySourcePicker.click();
57080a6f5c5SLiu Zhe         assertEquals(true, scValidityCriteriaAllowList.exists());
57180a6f5c5SLiu Zhe 
57280a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
57380a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
57480a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(0); // "Stop"
57580a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
57680a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value.");
57780a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
57880a6f5c5SLiu Zhe 
57980a6f5c5SLiu Zhe         // calc.focus();
58080a6f5c5SLiu Zhe         SCTool.selectRange("E2");
58180a6f5c5SLiu Zhe         scInputBarInput.activate();
58280a6f5c5SLiu Zhe         typeKeys("test");
58380a6f5c5SLiu Zhe         typeKeys("<enter>");
58480a6f5c5SLiu Zhe 
58580a6f5c5SLiu Zhe         SCTool.selectRange("A1");
58680a6f5c5SLiu Zhe         scInputBarInput.activate();
58780a6f5c5SLiu Zhe         typeKeys("test32");
58880a6f5c5SLiu Zhe         typeKeys("<enter>");
58957caf934SLiu Zhe         assertEquals("Invalid value.", activeMsgBox.getMessage());
59057caf934SLiu Zhe         activeMsgBox.ok();
59180a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A1"));
59280a6f5c5SLiu Zhe 
59380a6f5c5SLiu Zhe         SCTool.selectRange("B1");
59480a6f5c5SLiu Zhe         scInputBarInput.activate();
59580a6f5c5SLiu Zhe         typeKeys("test");
59680a6f5c5SLiu Zhe         typeKeys("<enter>");
59780a6f5c5SLiu Zhe         assertEquals("test", SCTool.getCellText("B1"));
59880a6f5c5SLiu Zhe     }
59980a6f5c5SLiu Zhe 
60080a6f5c5SLiu Zhe     /**
60180a6f5c5SLiu Zhe      * test Allow Blank cell Checkbox in Validity.
60280a6f5c5SLiu Zhe      */
60380a6f5c5SLiu Zhe     @Test
testAllowBlankCells()60480a6f5c5SLiu Zhe     public void testAllowBlankCells() {
60580a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
60680a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(5); // "Cell range"
60780a6f5c5SLiu Zhe         scValiditySourceInput.setText("$E$1:$E$5");
60880a6f5c5SLiu Zhe         scValidityAllowBlankCells.check();
60980a6f5c5SLiu Zhe         scValidityCriteriaTabpage.ok();
61080a6f5c5SLiu Zhe 
61180a6f5c5SLiu Zhe         SCTool.selectRange("E1");
61280a6f5c5SLiu Zhe         typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>");
61380a6f5c5SLiu Zhe 
61480a6f5c5SLiu Zhe         SCTool.selectRange("A1");
61580a6f5c5SLiu Zhe         typeKeys("A<enter>");
61680a6f5c5SLiu Zhe         SCTool.selectRange("D1");
61780a6f5c5SLiu Zhe         scInputBarInput.activate();
61880a6f5c5SLiu Zhe         typeKeys("<backspace><enter>");
61980a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("D1"));
62080a6f5c5SLiu Zhe 
62180a6f5c5SLiu Zhe         SCTool.selectRange("B1");
62280a6f5c5SLiu Zhe         app.dispatch(".uno:Validation");
62380a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
62480a6f5c5SLiu Zhe         scValidityAllowBlankCells.uncheck();
62580a6f5c5SLiu Zhe         typeKeys("<enter>");
62680a6f5c5SLiu Zhe 
62780a6f5c5SLiu Zhe         SCTool.selectRange("B1");
62880a6f5c5SLiu Zhe         scInputBarInput.activate();
62980a6f5c5SLiu Zhe         typeKeys("<backspace><enter>");
63080a6f5c5SLiu Zhe         typeKeys("<enter>");
63180a6f5c5SLiu Zhe     }
63280a6f5c5SLiu Zhe }
633