xref: /trunk/test/testgui/source/fvt/gui/sc/validity/ValidityDialogSetting.java (revision 708863fbcd77a4e55abebda0cb2ef74e496d8da7)
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 
3580a6f5c5SLiu Zhe import testlib.gui.SCTool;
3680a6f5c5SLiu Zhe 
3780a6f5c5SLiu Zhe public class ValidityDialogSetting {
3880a6f5c5SLiu Zhe 
3980a6f5c5SLiu Zhe     @Rule
4080a6f5c5SLiu Zhe     public Logger log = Logger.getLogger(this);
4180a6f5c5SLiu Zhe 
4280a6f5c5SLiu Zhe     @Before
4380a6f5c5SLiu Zhe     public void setUp() throws Exception {
4480a6f5c5SLiu Zhe         app.start(true);
4580a6f5c5SLiu Zhe 
4680a6f5c5SLiu Zhe         // New a spreadsheet, select cell range, open Validity dialog
4780a6f5c5SLiu Zhe         app.dispatch("private:factory/scalc");
4880a6f5c5SLiu Zhe         calc.waitForExistence(10, 2);
4980a6f5c5SLiu Zhe         SCTool.selectRange("A1:C5");
5080a6f5c5SLiu Zhe         app.dispatch(".uno:Validation");
5180a6f5c5SLiu Zhe     }
5280a6f5c5SLiu Zhe 
5380a6f5c5SLiu Zhe     @After
5480a6f5c5SLiu Zhe     public void tearDown() throws Exception {
5580a6f5c5SLiu Zhe 
5680a6f5c5SLiu Zhe     }
5780a6f5c5SLiu Zhe 
5880a6f5c5SLiu Zhe     /**
5980a6f5c5SLiu Zhe      * test Allow not between Date type in Validity.
6080a6f5c5SLiu Zhe      */
6180a6f5c5SLiu Zhe     @Test
6280a6f5c5SLiu Zhe     public void testAllowDateNotBetween() {
6380a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
6480a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(3); // "Date"
6580a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(7); // "not between"
6680a6f5c5SLiu Zhe         scValiditySourceInput.setText("01/01/08");
6780a6f5c5SLiu Zhe         scValidityMaxValueInput.setText("03/01/08");
6880a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
6980a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
7080a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
7180a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
7280a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
7380a6f5c5SLiu Zhe 
7480a6f5c5SLiu Zhe         SCTool.selectRange("A1");
7580a6f5c5SLiu Zhe         scInputBarInput.activate();
7680a6f5c5SLiu Zhe         typeKeys("12/31/07");
7780a6f5c5SLiu Zhe         typeKeys("<enter>");
7880a6f5c5SLiu Zhe         assertEquals("12/31/07", SCTool.getCellText("A1"));
7980a6f5c5SLiu Zhe 
8080a6f5c5SLiu Zhe         SCTool.selectRange("A2");
8180a6f5c5SLiu Zhe         scInputBarInput.activate();
8280a6f5c5SLiu Zhe         typeKeys("03/02/08");
8380a6f5c5SLiu Zhe         typeKeys("<enter>");
8480a6f5c5SLiu Zhe         assertEquals("03/02/08", SCTool.getCellText("A2"));
8580a6f5c5SLiu Zhe 
8680a6f5c5SLiu Zhe         SCTool.selectRange("A3");
8780a6f5c5SLiu Zhe         scInputBarInput.activate();
8880a6f5c5SLiu Zhe         typeKeys("01/01/08");
8980a6f5c5SLiu Zhe         typeKeys("<enter>");
9057caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
9157caf934SLiu Zhe         activeMsgBox.ok();
9280a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A3"));
9380a6f5c5SLiu Zhe 
9480a6f5c5SLiu Zhe         SCTool.selectRange("A4");
9580a6f5c5SLiu Zhe         scInputBarInput.activate();
9680a6f5c5SLiu Zhe         typeKeys("03/01/08");
9780a6f5c5SLiu Zhe         typeKeys("<enter>");
9857caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
9957caf934SLiu Zhe         activeMsgBox.ok();
10080a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A4"));
10180a6f5c5SLiu Zhe 
10280a6f5c5SLiu Zhe         SCTool.selectRange("A5");
10380a6f5c5SLiu Zhe         scInputBarInput.activate();
10480a6f5c5SLiu Zhe         typeKeys("01/02/08");
10580a6f5c5SLiu Zhe         typeKeys("<enter>");
10657caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
10757caf934SLiu Zhe         activeMsgBox.ok();
10880a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A5"));
10980a6f5c5SLiu Zhe 
11080a6f5c5SLiu Zhe         SCTool.selectRange("B1");
11180a6f5c5SLiu Zhe         scInputBarInput.activate();
11280a6f5c5SLiu Zhe         typeKeys("02/29/08");
11380a6f5c5SLiu Zhe         typeKeys("<enter>");
11457caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
11557caf934SLiu Zhe         activeMsgBox.ok();
11680a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B1"));
11780a6f5c5SLiu Zhe 
11880a6f5c5SLiu Zhe         SCTool.selectRange("B2");
11980a6f5c5SLiu Zhe         scInputBarInput.activate();
12080a6f5c5SLiu Zhe         typeKeys("test");
12180a6f5c5SLiu Zhe         typeKeys("<enter>");
12257caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
12357caf934SLiu Zhe         activeMsgBox.ok();
12480a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
12580a6f5c5SLiu Zhe 
12680a6f5c5SLiu Zhe         SCTool.selectRange("B3");
12780a6f5c5SLiu Zhe         scInputBarInput.activate();
12880a6f5c5SLiu Zhe         typeKeys("39448");
12980a6f5c5SLiu Zhe         typeKeys("<enter>");
13057caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
13157caf934SLiu Zhe         activeMsgBox.ok();
13280a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B3"));
13380a6f5c5SLiu Zhe     }
13480a6f5c5SLiu Zhe 
13580a6f5c5SLiu Zhe     /**
13680a6f5c5SLiu Zhe      * test Allow Decimal equal in Validity.
13780a6f5c5SLiu Zhe      */
13880a6f5c5SLiu Zhe     @Test
13980a6f5c5SLiu Zhe     public void testAllowDecimalEqual() {
14080a6f5c5SLiu Zhe 
14180a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
14280a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(2); // "Decimal"
14380a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(0); // "equal"
14480a6f5c5SLiu Zhe         scValiditySourceInput.setText("0.33333333");
14580a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
14680a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
14780a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
14880a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
14980a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
15080a6f5c5SLiu Zhe 
15180a6f5c5SLiu Zhe         SCTool.selectRange("A1");
15280a6f5c5SLiu Zhe         scInputBarInput.activate();
15380a6f5c5SLiu Zhe         typeKeys("0.33333333");
15480a6f5c5SLiu Zhe         typeKeys("<enter>");
15580a6f5c5SLiu Zhe         assertEquals("0.33333333", SCTool.getCellText("A1"));
15680a6f5c5SLiu Zhe 
15780a6f5c5SLiu Zhe         SCTool.selectRange("A2");
15880a6f5c5SLiu Zhe         scInputBarInput.activate();
15980a6f5c5SLiu Zhe         typeKeys("=1/3");
16080a6f5c5SLiu Zhe         typeKeys("<enter>");
16157caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
16257caf934SLiu Zhe         activeMsgBox.ok();
16380a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A2"));
16480a6f5c5SLiu Zhe 
16580a6f5c5SLiu Zhe         SCTool.selectRange("A3");
16680a6f5c5SLiu Zhe         scInputBarInput.activate();
16780a6f5c5SLiu Zhe         typeKeys("0.3");
16880a6f5c5SLiu Zhe         typeKeys("<enter>");
16957caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
17057caf934SLiu Zhe         activeMsgBox.ok();
17180a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A3"));
17280a6f5c5SLiu Zhe 
17380a6f5c5SLiu Zhe         SCTool.selectRange("A4");
17480a6f5c5SLiu Zhe         scInputBarInput.activate();
17580a6f5c5SLiu Zhe         typeKeys("0.333333333");
17680a6f5c5SLiu Zhe         typeKeys("<enter>");
17757caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
17857caf934SLiu Zhe         activeMsgBox.ok();
17980a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A4"));
18080a6f5c5SLiu Zhe 
18180a6f5c5SLiu Zhe         SCTool.selectRange("B2");
18280a6f5c5SLiu Zhe         scInputBarInput.activate();
18380a6f5c5SLiu Zhe         typeKeys("test");
18480a6f5c5SLiu Zhe         typeKeys("<enter>");
18557caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
18657caf934SLiu Zhe         activeMsgBox.ok();
18780a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
18880a6f5c5SLiu Zhe     }
18980a6f5c5SLiu Zhe 
19080a6f5c5SLiu Zhe     /**
19180a6f5c5SLiu Zhe      * test Allow Text length, greater than or equal to in Validity.
19280a6f5c5SLiu Zhe      */
19380a6f5c5SLiu Zhe     @Test
19480a6f5c5SLiu Zhe     public void testAllowGreaterTextLength() {
19580a6f5c5SLiu Zhe 
19680a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
19780a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(7); // "Text length"
19880a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
19980a6f5c5SLiu Zhe         scValiditySourceInput.setText("10");
20080a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
20180a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
20280a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
20380a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
20480a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
20580a6f5c5SLiu Zhe 
20680a6f5c5SLiu Zhe         SCTool.selectRange("A1");
20780a6f5c5SLiu Zhe         scInputBarInput.activate();
20880a6f5c5SLiu Zhe         typeKeys("testtesttesttest");
20980a6f5c5SLiu Zhe         typeKeys("<enter>");
21080a6f5c5SLiu Zhe         assertEquals("testtesttesttest", SCTool.getCellText("A1"));
21180a6f5c5SLiu Zhe 
21280a6f5c5SLiu Zhe         SCTool.selectRange("A2");
21380a6f5c5SLiu Zhe         scInputBarInput.activate();
21480a6f5c5SLiu Zhe         typeKeys("test test ");
21580a6f5c5SLiu Zhe         typeKeys("<enter>");
21680a6f5c5SLiu Zhe         assertEquals("test test ", SCTool.getCellText("A2"));
21780a6f5c5SLiu Zhe 
21880a6f5c5SLiu Zhe         SCTool.selectRange("A4");
21980a6f5c5SLiu Zhe         scInputBarInput.activate();
22080a6f5c5SLiu Zhe         typeKeys(" ");
22180a6f5c5SLiu Zhe         typeKeys("<enter>");
22257caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
22357caf934SLiu Zhe         activeMsgBox.ok();
22480a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A4"));
22580a6f5c5SLiu Zhe 
22680a6f5c5SLiu Zhe         SCTool.selectRange("A3");
22780a6f5c5SLiu Zhe         scInputBarInput.activate();
22880a6f5c5SLiu Zhe         typeKeys("Testatest");
22980a6f5c5SLiu Zhe         typeKeys("<enter>");
23057caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
23157caf934SLiu Zhe         activeMsgBox.ok();
23280a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A3"));
23380a6f5c5SLiu Zhe     }
23480a6f5c5SLiu Zhe 
23580a6f5c5SLiu Zhe     /**
23680a6f5c5SLiu Zhe      * test Allow Text length, less than in Validity.
23780a6f5c5SLiu Zhe      */
238*708863fbSHerbert Dürr     @Test
23980a6f5c5SLiu Zhe     public void testAllowLessThanTextLength() {
24080a6f5c5SLiu Zhe 
24180a6f5c5SLiu Zhe         app.dispatch(".uno:Validation");
24280a6f5c5SLiu Zhe 
24380a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
24480a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(7); // "Text length"
24580a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(1); // "less than"
24680a6f5c5SLiu Zhe         scValiditySourceInput.setText("10");
24780a6f5c5SLiu Zhe 
24880a6f5c5SLiu Zhe         scValidityInputHelpTabPage.select();
24980a6f5c5SLiu Zhe         scValidityInputHelpCheckbox.check();
25080a6f5c5SLiu Zhe         scValidityInputHelpTitle.setText("Help Info Title");
25180a6f5c5SLiu Zhe         scValidityHelpMessage.setText("help info");
25280a6f5c5SLiu Zhe 
25380a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
25480a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
25580a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select("Information");
25680a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Notes to enter");
25780a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
25880a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
25980a6f5c5SLiu Zhe 
26080a6f5c5SLiu Zhe         SCTool.selectRange("A1");
26180a6f5c5SLiu Zhe         scInputBarInput.activate();
26280a6f5c5SLiu Zhe         typeKeys("testtesttesttest<enter>");
26357caf934SLiu Zhe         activeMsgBox.ok();
26480a6f5c5SLiu Zhe         assertEquals("testtesttesttest", SCTool.getCellText("A1"));
26580a6f5c5SLiu Zhe 
26680a6f5c5SLiu Zhe         SCTool.selectRange("A2");
26780a6f5c5SLiu Zhe         scInputBarInput.activate();
26880a6f5c5SLiu Zhe         typeKeys("sfsafsddddddd<enter>");
26957caf934SLiu Zhe         activeMsgBox.cancel();
27080a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A2"));
27180a6f5c5SLiu Zhe 
27280a6f5c5SLiu Zhe         SCTool.selectRange("A2");
27380a6f5c5SLiu Zhe         scInputBarInput.activate();
27480a6f5c5SLiu Zhe         typeKeys("10<enter>");
27580a6f5c5SLiu Zhe         assertEquals("10", SCTool.getCellText("A2"));
27680a6f5c5SLiu Zhe 
27780a6f5c5SLiu Zhe         SCTool.selectRange("A3");
27880a6f5c5SLiu Zhe         scInputBarInput.activate();
27980a6f5c5SLiu Zhe         typeKeys("ok<enter>");
28080a6f5c5SLiu Zhe         assertEquals("ok", SCTool.getCellText("A3"));
28180a6f5c5SLiu Zhe     }
28280a6f5c5SLiu Zhe 
28380a6f5c5SLiu Zhe     /**
28480a6f5c5SLiu Zhe      * test Allow list.
28580a6f5c5SLiu Zhe      */
28680a6f5c5SLiu Zhe     @Test
28780a6f5c5SLiu Zhe     public void testAllowListSpecialChar() {
28880a6f5c5SLiu Zhe 
28980a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
29080a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(6); // "List"
29180a6f5c5SLiu Zhe         scValidityEntries.focus();
29280a6f5c5SLiu Zhe         typeKeys("a");
29380a6f5c5SLiu Zhe         typeKeys("<enter>");
29480a6f5c5SLiu Zhe         typeKeys("b");
29580a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
29680a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
29780a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
29880a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
29980a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
30080a6f5c5SLiu Zhe         scValidityCriteriaTabpage.ok();
30180a6f5c5SLiu Zhe 
30280a6f5c5SLiu Zhe         // These codes are not stable: start
30380a6f5c5SLiu Zhe         // calc.rightClick(1, 1);
30480a6f5c5SLiu Zhe         // typeKeys("<shift s>");
30580a6f5c5SLiu Zhe         // typeKeys("<down><enter>"); // Choose a
30680a6f5c5SLiu Zhe         // sleep(2); // if no sleep, error occur
30780a6f5c5SLiu Zhe         // These codes are not stable: end
30880a6f5c5SLiu Zhe         SCTool.selectRange("A1");
30980a6f5c5SLiu Zhe         scInputBarInput.activate();
31080a6f5c5SLiu Zhe         typeKeys("a<enter>");
31180a6f5c5SLiu Zhe         assertEquals("a", SCTool.getCellText("A1"));
31280a6f5c5SLiu Zhe 
31380a6f5c5SLiu Zhe         SCTool.selectRange("B2");
31480a6f5c5SLiu Zhe         scInputBarInput.activate();
31580a6f5c5SLiu Zhe         typeKeys("test");
31680a6f5c5SLiu Zhe         typeKeys("<enter>");
31757caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
31857caf934SLiu Zhe         activeMsgBox.ok();
31980a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
32080a6f5c5SLiu Zhe     }
32180a6f5c5SLiu Zhe 
32280a6f5c5SLiu Zhe     /**
32380a6f5c5SLiu Zhe      * test Allow time between in Validity.
32480a6f5c5SLiu Zhe      */
32580a6f5c5SLiu Zhe     @Test
32680a6f5c5SLiu Zhe     public void testAllowTimeBetween() {
32780a6f5c5SLiu Zhe 
32880a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
32980a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(4); // "Time"
33080a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(6); // "between"
33180a6f5c5SLiu Zhe         scValiditySourceInput.setText("27:00");
33280a6f5c5SLiu Zhe         scValidityMaxValueInput.setText("21:00");
33380a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
33480a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
33580a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
33680a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
33780a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
33880a6f5c5SLiu Zhe 
33980a6f5c5SLiu Zhe         SCTool.selectRange("A1");
34080a6f5c5SLiu Zhe         scInputBarInput.activate();
34180a6f5c5SLiu Zhe         typeKeys("21:00");
34280a6f5c5SLiu Zhe         typeKeys("<enter>");
34380a6f5c5SLiu Zhe         assertEquals("09:00:00 PM", SCTool.getCellText("A1"));
34480a6f5c5SLiu Zhe 
34580a6f5c5SLiu Zhe         SCTool.selectRange("A2");
34680a6f5c5SLiu Zhe         scInputBarInput.activate();
34780a6f5c5SLiu Zhe         typeKeys("27:00");
34880a6f5c5SLiu Zhe         typeKeys("<enter>");
34980a6f5c5SLiu Zhe         assertEquals("27:00:00", SCTool.getCellText("A2"));
35080a6f5c5SLiu Zhe 
35180a6f5c5SLiu Zhe         SCTool.selectRange("A3");
35280a6f5c5SLiu Zhe         scInputBarInput.activate();
35380a6f5c5SLiu Zhe         typeKeys("1.125");
35480a6f5c5SLiu Zhe         typeKeys("<enter>");
35580a6f5c5SLiu Zhe         assertEquals("1.125", SCTool.getCellText("A3"));
35680a6f5c5SLiu Zhe 
35780a6f5c5SLiu Zhe         SCTool.selectRange("A4");
35880a6f5c5SLiu Zhe         scInputBarInput.activate();
35980a6f5c5SLiu Zhe         typeKeys("0.875");
36080a6f5c5SLiu Zhe         typeKeys("<enter>");
36180a6f5c5SLiu Zhe         assertEquals("0.875", SCTool.getCellText("A4"));
36280a6f5c5SLiu Zhe 
36380a6f5c5SLiu Zhe         SCTool.selectRange("B1");
36480a6f5c5SLiu Zhe         scInputBarInput.activate();
36580a6f5c5SLiu Zhe         typeKeys("03:00:01");
36680a6f5c5SLiu Zhe         typeKeys("<enter>");
36757caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
36857caf934SLiu Zhe         activeMsgBox.ok();
36980a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B1"));
37080a6f5c5SLiu Zhe 
37180a6f5c5SLiu Zhe         SCTool.selectRange("B2");
37280a6f5c5SLiu Zhe         scInputBarInput.activate();
37380a6f5c5SLiu Zhe         typeKeys("20:59:59");
37480a6f5c5SLiu Zhe         typeKeys("<enter>");
37557caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
37657caf934SLiu Zhe         activeMsgBox.ok();
37780a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
37880a6f5c5SLiu Zhe 
37980a6f5c5SLiu Zhe         SCTool.selectRange("B3");
38080a6f5c5SLiu Zhe         scInputBarInput.activate();
38180a6f5c5SLiu Zhe         typeKeys("1.126");
38280a6f5c5SLiu Zhe         typeKeys("<enter>");
38357caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
38457caf934SLiu Zhe         activeMsgBox.ok();
38580a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B3"));
38680a6f5c5SLiu Zhe 
38780a6f5c5SLiu Zhe         SCTool.selectRange("B4");
38880a6f5c5SLiu Zhe         scInputBarInput.activate();
38980a6f5c5SLiu Zhe         typeKeys("0.874");
39080a6f5c5SLiu Zhe         typeKeys("<enter>");
39157caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
39257caf934SLiu Zhe         activeMsgBox.ok();
39380a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B4"));
39480a6f5c5SLiu Zhe 
39580a6f5c5SLiu Zhe         SCTool.selectRange("C1");
39680a6f5c5SLiu Zhe         scInputBarInput.activate();
39780a6f5c5SLiu Zhe         typeKeys("test");
39880a6f5c5SLiu Zhe         typeKeys("<enter>");
39957caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
40057caf934SLiu Zhe         activeMsgBox.ok();
40180a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("C1"));
40280a6f5c5SLiu Zhe 
40380a6f5c5SLiu Zhe         SCTool.selectRange("C2");
40480a6f5c5SLiu Zhe         scInputBarInput.activate();
40580a6f5c5SLiu Zhe         typeKeys("24:00");
40680a6f5c5SLiu Zhe         typeKeys("<enter>");
40780a6f5c5SLiu Zhe         assertEquals("24:00:00", SCTool.getCellText("C2"));
40880a6f5c5SLiu Zhe 
40980a6f5c5SLiu Zhe         SCTool.selectRange("C3");
41080a6f5c5SLiu Zhe         scInputBarInput.activate();
41180a6f5c5SLiu Zhe         typeKeys("12:00");
41280a6f5c5SLiu Zhe         typeKeys("<enter>");
41357caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
41457caf934SLiu Zhe         activeMsgBox.ok();
41580a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("C3"));
41680a6f5c5SLiu Zhe     }
41780a6f5c5SLiu Zhe 
41880a6f5c5SLiu Zhe     /**
41980a6f5c5SLiu Zhe      * test Allow time Greater than and equal to in Validity.
42080a6f5c5SLiu Zhe      */
42180a6f5c5SLiu Zhe     @Test
42280a6f5c5SLiu Zhe     public void testAllowTimeGreaterThan() {
42380a6f5c5SLiu Zhe 
42480a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
42580a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(4); // "Time"
42680a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(4); // "greater than or equal to"
42780a6f5c5SLiu Zhe         scValiditySourceInput.setText("8:00");
42880a6f5c5SLiu Zhe 
42980a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
43080a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
43180a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(1); // "Warning"
43280a6f5c5SLiu Zhe 
43380a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("warning to enter");
43480a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
43580a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
43680a6f5c5SLiu Zhe 
43780a6f5c5SLiu Zhe         SCTool.selectRange("A1");
43880a6f5c5SLiu Zhe         scInputBarInput.activate();
43980a6f5c5SLiu Zhe         typeKeys("7:30");
44080a6f5c5SLiu Zhe         typeKeys("<enter>");
44157caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
44257caf934SLiu Zhe         activeMsgBox.ok();
44380a6f5c5SLiu Zhe         assertEquals("07:30:00 AM", SCTool.getCellText("A1"));
44480a6f5c5SLiu Zhe 
44580a6f5c5SLiu Zhe         SCTool.selectRange("A2");
44680a6f5c5SLiu Zhe         scInputBarInput.activate();
44780a6f5c5SLiu Zhe         typeKeys("6:00");
44880a6f5c5SLiu Zhe         typeKeys("<enter>");
44957caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
45057caf934SLiu Zhe         activeMsgBox.cancel();
45180a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A2"));
45280a6f5c5SLiu Zhe 
45380a6f5c5SLiu Zhe         SCTool.selectRange("A3");
45480a6f5c5SLiu Zhe         scInputBarInput.activate();
45580a6f5c5SLiu Zhe         typeKeys("8:00");
45680a6f5c5SLiu Zhe         typeKeys("<enter>");
45780a6f5c5SLiu Zhe         assertEquals("08:00:00 AM", SCTool.getCellText("A3"));
45880a6f5c5SLiu Zhe     }
45980a6f5c5SLiu Zhe 
46080a6f5c5SLiu Zhe     /**
46180a6f5c5SLiu Zhe      * test Allow whole number, less than or equal to in Validity.
46280a6f5c5SLiu Zhe      */
46380a6f5c5SLiu Zhe     @Test
46480a6f5c5SLiu Zhe     public void testAllowWholeNumLessThan() {
46580a6f5c5SLiu Zhe 
46680a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
46780a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(1); // "Whole Numbers"
46880a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(3); // "less than or equal"
46980a6f5c5SLiu Zhe         scValiditySourceInput.setText("100");
47080a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
47180a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
47280a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
47380a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value");
47480a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
47580a6f5c5SLiu Zhe 
47680a6f5c5SLiu Zhe         SCTool.selectRange("A1");
47780a6f5c5SLiu Zhe         scInputBarInput.activate();
47880a6f5c5SLiu Zhe         typeKeys("99");
47980a6f5c5SLiu Zhe         typeKeys("<enter>");
48080a6f5c5SLiu Zhe         assertEquals("99", SCTool.getCellText("A1"));
48180a6f5c5SLiu Zhe 
48280a6f5c5SLiu Zhe         SCTool.selectRange("A2");
48380a6f5c5SLiu Zhe         scInputBarInput.activate();
48480a6f5c5SLiu Zhe         typeKeys("100");
48580a6f5c5SLiu Zhe         typeKeys("<enter>");
48680a6f5c5SLiu Zhe         assertEquals("100", SCTool.getCellText("A2"));
48780a6f5c5SLiu Zhe 
48880a6f5c5SLiu Zhe         SCTool.selectRange("B1");
48980a6f5c5SLiu Zhe         scInputBarInput.activate();
49080a6f5c5SLiu Zhe         typeKeys("101");
49180a6f5c5SLiu Zhe         typeKeys("<enter>");
49257caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
49357caf934SLiu Zhe         activeMsgBox.ok();
49480a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B1"));
49580a6f5c5SLiu Zhe 
49680a6f5c5SLiu Zhe         SCTool.selectRange("B2");
49780a6f5c5SLiu Zhe         scInputBarInput.activate();
49880a6f5c5SLiu Zhe         typeKeys("45.5");
49980a6f5c5SLiu Zhe         typeKeys("<enter>");
50057caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
50157caf934SLiu Zhe         activeMsgBox.ok();
50280a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("B2"));
50380a6f5c5SLiu Zhe 
50480a6f5c5SLiu Zhe         SCTool.selectRange("C1");
50580a6f5c5SLiu Zhe         scInputBarInput.activate();
50680a6f5c5SLiu Zhe         typeKeys("test");
50780a6f5c5SLiu Zhe         typeKeys("<enter>");
50857caf934SLiu Zhe         assertEquals("Invalid value", activeMsgBox.getMessage());
50957caf934SLiu Zhe         activeMsgBox.ok();
51080a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("C1"));
51180a6f5c5SLiu Zhe     }
51280a6f5c5SLiu Zhe 
51380a6f5c5SLiu Zhe     /**
51480a6f5c5SLiu Zhe      * test default message of Error Alert in Validity.
51580a6f5c5SLiu Zhe      */
51680a6f5c5SLiu Zhe     @Test
51780a6f5c5SLiu Zhe     public void testDefaultErrorAlertMessage() {
51880a6f5c5SLiu Zhe 
51980a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
52080a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(2); // "Decimal"
52180a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(0); // "equal"
52280a6f5c5SLiu Zhe         scValiditySourceInput.setText("1");
52380a6f5c5SLiu Zhe 
52480a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
52580a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
52680a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(0); // "Stop"
52780a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
52880a6f5c5SLiu Zhe 
52980a6f5c5SLiu Zhe         SCTool.selectRange("A1");
53080a6f5c5SLiu Zhe         scInputBarInput.activate();
53180a6f5c5SLiu Zhe         typeKeys("13");
53280a6f5c5SLiu Zhe         typeKeys("<enter>");
53357caf934SLiu Zhe         assertEquals("OpenOffice.org Calc", activeMsgBox.getCaption());
53480a6f5c5SLiu Zhe         // assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not
53580a6f5c5SLiu Zhe         // verify in multi-language
53657caf934SLiu Zhe         activeMsgBox.ok();
53780a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A1"));
53880a6f5c5SLiu Zhe     }
53980a6f5c5SLiu Zhe 
54080a6f5c5SLiu Zhe     /**
54180a6f5c5SLiu Zhe      * test uncheck Error Alert in Validity.
54280a6f5c5SLiu Zhe      */
54380a6f5c5SLiu Zhe     @Test
54480a6f5c5SLiu Zhe     public void testUncheckErrorAlert() {
54580a6f5c5SLiu Zhe 
54680a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
54780a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(2); // "Decimal"
54880a6f5c5SLiu Zhe         scValidityDecimalCompareOperator.select(0); // "equal"
54980a6f5c5SLiu Zhe         scValiditySourceInput.setText("1");
55080a6f5c5SLiu Zhe 
55180a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
55280a6f5c5SLiu Zhe         scValidityShowErrorMessage.uncheck();
55380a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(0); // "Stop"
55480a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
55580a6f5c5SLiu Zhe 
55680a6f5c5SLiu Zhe         SCTool.selectRange("A1");
55780a6f5c5SLiu Zhe         typeKeys("13");
55880a6f5c5SLiu Zhe         typeKeys("<enter>");
55980a6f5c5SLiu Zhe         assertEquals("13", SCTool.getCellText("A1"));
56080a6f5c5SLiu Zhe     }
56180a6f5c5SLiu Zhe 
56280a6f5c5SLiu Zhe     /**
56380a6f5c5SLiu Zhe      * test Cell range source picker in Validity. Input from Edit Box.
56480a6f5c5SLiu Zhe      */
56580a6f5c5SLiu Zhe     @Test
56680a6f5c5SLiu Zhe     public void testValidityCellRangeSourcePicker() {
56780a6f5c5SLiu Zhe 
56880a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
56980a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(5); // "Cell range"
57080a6f5c5SLiu Zhe         scValiditySourcePicker.click();
57180a6f5c5SLiu Zhe         assertEquals(false, scValidityCriteriaAllowList.exists());
57280a6f5c5SLiu Zhe         scValiditySourceInput.setText("$E$2:$G$5");
57380a6f5c5SLiu Zhe         scValiditySourcePicker.click();
57480a6f5c5SLiu Zhe         assertEquals(true, scValidityCriteriaAllowList.exists());
57580a6f5c5SLiu Zhe 
57680a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.select();
57780a6f5c5SLiu Zhe         scValidityShowErrorMessage.check();
57880a6f5c5SLiu Zhe         scValidityErrorAlertActionList.select(0); // "Stop"
57980a6f5c5SLiu Zhe         scValidityErrorMessageTitle.setText("Stop to enter");
58080a6f5c5SLiu Zhe         scValidityErrorMessage.setText("Invalid value.");
58180a6f5c5SLiu Zhe         scValidityErrorAlertTabPage.ok();
58280a6f5c5SLiu Zhe 
58380a6f5c5SLiu Zhe         // calc.focus();
58480a6f5c5SLiu Zhe         SCTool.selectRange("E2");
58580a6f5c5SLiu Zhe         scInputBarInput.activate();
58680a6f5c5SLiu Zhe         typeKeys("test");
58780a6f5c5SLiu Zhe         typeKeys("<enter>");
58880a6f5c5SLiu Zhe 
58980a6f5c5SLiu Zhe         SCTool.selectRange("A1");
59080a6f5c5SLiu Zhe         scInputBarInput.activate();
59180a6f5c5SLiu Zhe         typeKeys("test32");
59280a6f5c5SLiu Zhe         typeKeys("<enter>");
59357caf934SLiu Zhe         assertEquals("Invalid value.", activeMsgBox.getMessage());
59457caf934SLiu Zhe         activeMsgBox.ok();
59580a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("A1"));
59680a6f5c5SLiu Zhe 
59780a6f5c5SLiu Zhe         SCTool.selectRange("B1");
59880a6f5c5SLiu Zhe         scInputBarInput.activate();
59980a6f5c5SLiu Zhe         typeKeys("test");
60080a6f5c5SLiu Zhe         typeKeys("<enter>");
60180a6f5c5SLiu Zhe         assertEquals("test", SCTool.getCellText("B1"));
60280a6f5c5SLiu Zhe     }
60380a6f5c5SLiu Zhe 
60480a6f5c5SLiu Zhe     /**
60580a6f5c5SLiu Zhe      * test Allow Blank cell Checkbox in Validity.
60680a6f5c5SLiu Zhe      */
60780a6f5c5SLiu Zhe     @Test
60880a6f5c5SLiu Zhe     public void testAllowBlankCells() {
60980a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
61080a6f5c5SLiu Zhe         scValidityCriteriaAllowList.select(5); // "Cell range"
61180a6f5c5SLiu Zhe         scValiditySourceInput.setText("$E$1:$E$5");
61280a6f5c5SLiu Zhe         scValidityAllowBlankCells.check();
61380a6f5c5SLiu Zhe         scValidityCriteriaTabpage.ok();
61480a6f5c5SLiu Zhe 
61580a6f5c5SLiu Zhe         SCTool.selectRange("E1");
61680a6f5c5SLiu Zhe         typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>");
61780a6f5c5SLiu Zhe 
61880a6f5c5SLiu Zhe         SCTool.selectRange("A1");
61980a6f5c5SLiu Zhe         typeKeys("A<enter>");
62080a6f5c5SLiu Zhe         SCTool.selectRange("D1");
62180a6f5c5SLiu Zhe         scInputBarInput.activate();
62280a6f5c5SLiu Zhe         typeKeys("<backspace><enter>");
62380a6f5c5SLiu Zhe         assertEquals("", SCTool.getCellText("D1"));
62480a6f5c5SLiu Zhe 
62580a6f5c5SLiu Zhe         SCTool.selectRange("B1");
62680a6f5c5SLiu Zhe         app.dispatch(".uno:Validation");
62780a6f5c5SLiu Zhe         scValidityCriteriaTabpage.select();
62880a6f5c5SLiu Zhe         scValidityAllowBlankCells.uncheck();
62980a6f5c5SLiu Zhe         typeKeys("<enter>");
63080a6f5c5SLiu Zhe 
63180a6f5c5SLiu Zhe         SCTool.selectRange("B1");
63280a6f5c5SLiu Zhe         scInputBarInput.activate();
63380a6f5c5SLiu Zhe         typeKeys("<backspace><enter>");
63480a6f5c5SLiu Zhe         typeKeys("<enter>");
63580a6f5c5SLiu Zhe     }
63680a6f5c5SLiu Zhe }
637