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 35*424494b0SLi Feng Wang import testlib.gui.AppTool; 3680a6f5c5SLiu Zhe import testlib.gui.SCTool; 3780a6f5c5SLiu Zhe 3880a6f5c5SLiu Zhe public class ValidityDialogSetting { 3980a6f5c5SLiu Zhe 4080a6f5c5SLiu Zhe @Before 4180a6f5c5SLiu Zhe public void setUp() throws Exception { 4280a6f5c5SLiu Zhe app.start(true); 43*424494b0SLi Feng Wang AppTool.newSpreadsheet(); 4480a6f5c5SLiu Zhe SCTool.selectRange("A1:C5"); 4580a6f5c5SLiu Zhe app.dispatch(".uno:Validation"); 4680a6f5c5SLiu Zhe } 4780a6f5c5SLiu Zhe 4880a6f5c5SLiu Zhe @After 4980a6f5c5SLiu Zhe public void tearDown() throws Exception { 504a13b48eSLi Feng Wang app.stop(); 5180a6f5c5SLiu Zhe } 5280a6f5c5SLiu Zhe 5380a6f5c5SLiu Zhe /** 5480a6f5c5SLiu Zhe * test Allow not between Date type in Validity. 5580a6f5c5SLiu Zhe */ 5680a6f5c5SLiu Zhe @Test 5780a6f5c5SLiu Zhe public void testAllowDateNotBetween() { 5880a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 5980a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(3); // "Date" 6080a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(7); // "not between" 6180a6f5c5SLiu Zhe scValiditySourceInput.setText("01/01/08"); 6280a6f5c5SLiu Zhe scValidityMaxValueInput.setText("03/01/08"); 6380a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 6480a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 6580a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 6680a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 6780a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 6880a6f5c5SLiu Zhe 6980a6f5c5SLiu Zhe SCTool.selectRange("A1"); 7080a6f5c5SLiu Zhe scInputBarInput.activate(); 7180a6f5c5SLiu Zhe typeKeys("12/31/07"); 7280a6f5c5SLiu Zhe typeKeys("<enter>"); 7380a6f5c5SLiu Zhe assertEquals("12/31/07", SCTool.getCellText("A1")); 7480a6f5c5SLiu Zhe 7580a6f5c5SLiu Zhe SCTool.selectRange("A2"); 7680a6f5c5SLiu Zhe scInputBarInput.activate(); 7780a6f5c5SLiu Zhe typeKeys("03/02/08"); 7880a6f5c5SLiu Zhe typeKeys("<enter>"); 7980a6f5c5SLiu Zhe assertEquals("03/02/08", SCTool.getCellText("A2")); 8080a6f5c5SLiu Zhe 8180a6f5c5SLiu Zhe SCTool.selectRange("A3"); 8280a6f5c5SLiu Zhe scInputBarInput.activate(); 8380a6f5c5SLiu Zhe typeKeys("01/01/08"); 8480a6f5c5SLiu Zhe typeKeys("<enter>"); 8557caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 8657caf934SLiu Zhe activeMsgBox.ok(); 8780a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A3")); 8880a6f5c5SLiu Zhe 8980a6f5c5SLiu Zhe SCTool.selectRange("A4"); 9080a6f5c5SLiu Zhe scInputBarInput.activate(); 9180a6f5c5SLiu Zhe typeKeys("03/01/08"); 9280a6f5c5SLiu Zhe typeKeys("<enter>"); 9357caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 9457caf934SLiu Zhe activeMsgBox.ok(); 9580a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A4")); 9680a6f5c5SLiu Zhe 9780a6f5c5SLiu Zhe SCTool.selectRange("A5"); 9880a6f5c5SLiu Zhe scInputBarInput.activate(); 9980a6f5c5SLiu Zhe typeKeys("01/02/08"); 10080a6f5c5SLiu Zhe typeKeys("<enter>"); 10157caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 10257caf934SLiu Zhe activeMsgBox.ok(); 10380a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A5")); 10480a6f5c5SLiu Zhe 10580a6f5c5SLiu Zhe SCTool.selectRange("B1"); 10680a6f5c5SLiu Zhe scInputBarInput.activate(); 10780a6f5c5SLiu Zhe typeKeys("02/29/08"); 10880a6f5c5SLiu Zhe typeKeys("<enter>"); 10957caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 11057caf934SLiu Zhe activeMsgBox.ok(); 11180a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B1")); 11280a6f5c5SLiu Zhe 11380a6f5c5SLiu Zhe SCTool.selectRange("B2"); 11480a6f5c5SLiu Zhe scInputBarInput.activate(); 11580a6f5c5SLiu Zhe typeKeys("test"); 11680a6f5c5SLiu Zhe typeKeys("<enter>"); 11757caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 11857caf934SLiu Zhe activeMsgBox.ok(); 11980a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 12080a6f5c5SLiu Zhe 12180a6f5c5SLiu Zhe SCTool.selectRange("B3"); 12280a6f5c5SLiu Zhe scInputBarInput.activate(); 12380a6f5c5SLiu Zhe typeKeys("39448"); 12480a6f5c5SLiu Zhe typeKeys("<enter>"); 12557caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 12657caf934SLiu Zhe activeMsgBox.ok(); 12780a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B3")); 12880a6f5c5SLiu Zhe } 12980a6f5c5SLiu Zhe 13080a6f5c5SLiu Zhe /** 13180a6f5c5SLiu Zhe * test Allow Decimal equal in Validity. 13280a6f5c5SLiu Zhe */ 13380a6f5c5SLiu Zhe @Test 13480a6f5c5SLiu Zhe public void testAllowDecimalEqual() { 13580a6f5c5SLiu Zhe 13680a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 13780a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(2); // "Decimal" 13880a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(0); // "equal" 13980a6f5c5SLiu Zhe scValiditySourceInput.setText("0.33333333"); 14080a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 14180a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 14280a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 14380a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 14480a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 14580a6f5c5SLiu Zhe 14680a6f5c5SLiu Zhe SCTool.selectRange("A1"); 14780a6f5c5SLiu Zhe scInputBarInput.activate(); 14880a6f5c5SLiu Zhe typeKeys("0.33333333"); 14980a6f5c5SLiu Zhe typeKeys("<enter>"); 15080a6f5c5SLiu Zhe assertEquals("0.33333333", SCTool.getCellText("A1")); 15180a6f5c5SLiu Zhe 15280a6f5c5SLiu Zhe SCTool.selectRange("A2"); 15380a6f5c5SLiu Zhe scInputBarInput.activate(); 15480a6f5c5SLiu Zhe typeKeys("=1/3"); 15580a6f5c5SLiu Zhe typeKeys("<enter>"); 15657caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 15757caf934SLiu Zhe activeMsgBox.ok(); 15880a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A2")); 15980a6f5c5SLiu Zhe 16080a6f5c5SLiu Zhe SCTool.selectRange("A3"); 16180a6f5c5SLiu Zhe scInputBarInput.activate(); 16280a6f5c5SLiu Zhe typeKeys("0.3"); 16380a6f5c5SLiu Zhe typeKeys("<enter>"); 16457caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 16557caf934SLiu Zhe activeMsgBox.ok(); 16680a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A3")); 16780a6f5c5SLiu Zhe 16880a6f5c5SLiu Zhe SCTool.selectRange("A4"); 16980a6f5c5SLiu Zhe scInputBarInput.activate(); 17080a6f5c5SLiu Zhe typeKeys("0.333333333"); 17180a6f5c5SLiu Zhe typeKeys("<enter>"); 17257caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 17357caf934SLiu Zhe activeMsgBox.ok(); 17480a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A4")); 17580a6f5c5SLiu Zhe 17680a6f5c5SLiu Zhe SCTool.selectRange("B2"); 17780a6f5c5SLiu Zhe scInputBarInput.activate(); 17880a6f5c5SLiu Zhe typeKeys("test"); 17980a6f5c5SLiu Zhe typeKeys("<enter>"); 18057caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 18157caf934SLiu Zhe activeMsgBox.ok(); 18280a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 18380a6f5c5SLiu Zhe } 18480a6f5c5SLiu Zhe 18580a6f5c5SLiu Zhe /** 18680a6f5c5SLiu Zhe * test Allow Text length, greater than or equal to in Validity. 18780a6f5c5SLiu Zhe */ 18880a6f5c5SLiu Zhe @Test 18980a6f5c5SLiu Zhe public void testAllowGreaterTextLength() { 19080a6f5c5SLiu Zhe 19180a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 19280a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(7); // "Text length" 19380a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(4); // "greater than or equal to" 19480a6f5c5SLiu Zhe scValiditySourceInput.setText("10"); 19580a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 19680a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 19780a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 19880a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 19980a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 20080a6f5c5SLiu Zhe 20180a6f5c5SLiu Zhe SCTool.selectRange("A1"); 20280a6f5c5SLiu Zhe scInputBarInput.activate(); 20380a6f5c5SLiu Zhe typeKeys("testtesttesttest"); 20480a6f5c5SLiu Zhe typeKeys("<enter>"); 20580a6f5c5SLiu Zhe assertEquals("testtesttesttest", SCTool.getCellText("A1")); 20680a6f5c5SLiu Zhe 20780a6f5c5SLiu Zhe SCTool.selectRange("A2"); 20880a6f5c5SLiu Zhe scInputBarInput.activate(); 20980a6f5c5SLiu Zhe typeKeys("test test "); 21080a6f5c5SLiu Zhe typeKeys("<enter>"); 21180a6f5c5SLiu Zhe assertEquals("test test ", SCTool.getCellText("A2")); 21280a6f5c5SLiu Zhe 21380a6f5c5SLiu Zhe SCTool.selectRange("A4"); 21480a6f5c5SLiu Zhe scInputBarInput.activate(); 21580a6f5c5SLiu Zhe typeKeys(" "); 21680a6f5c5SLiu Zhe typeKeys("<enter>"); 21757caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 21857caf934SLiu Zhe activeMsgBox.ok(); 21980a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A4")); 22080a6f5c5SLiu Zhe 22180a6f5c5SLiu Zhe SCTool.selectRange("A3"); 22280a6f5c5SLiu Zhe scInputBarInput.activate(); 22380a6f5c5SLiu Zhe typeKeys("Testatest"); 22480a6f5c5SLiu Zhe typeKeys("<enter>"); 22557caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 22657caf934SLiu Zhe activeMsgBox.ok(); 22780a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A3")); 22880a6f5c5SLiu Zhe } 22980a6f5c5SLiu Zhe 23080a6f5c5SLiu Zhe /** 23180a6f5c5SLiu Zhe * test Allow Text length, less than in Validity. 23280a6f5c5SLiu Zhe */ 233708863fbSHerbert Dürr @Test 23480a6f5c5SLiu Zhe public void testAllowLessThanTextLength() { 23580a6f5c5SLiu Zhe 23680a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 23780a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(7); // "Text length" 23880a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(1); // "less than" 23980a6f5c5SLiu Zhe scValiditySourceInput.setText("10"); 24080a6f5c5SLiu Zhe 24180a6f5c5SLiu Zhe scValidityInputHelpTabPage.select(); 24280a6f5c5SLiu Zhe scValidityInputHelpCheckbox.check(); 24380a6f5c5SLiu Zhe scValidityInputHelpTitle.setText("Help Info Title"); 24480a6f5c5SLiu Zhe scValidityHelpMessage.setText("help info"); 24580a6f5c5SLiu Zhe 24680a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 24780a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 24880a6f5c5SLiu Zhe scValidityErrorAlertActionList.select("Information"); 24980a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Notes to enter"); 25080a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 25180a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 25280a6f5c5SLiu Zhe 25380a6f5c5SLiu Zhe SCTool.selectRange("A1"); 25480a6f5c5SLiu Zhe scInputBarInput.activate(); 25580a6f5c5SLiu Zhe typeKeys("testtesttesttest<enter>"); 25657caf934SLiu Zhe activeMsgBox.ok(); 25780a6f5c5SLiu Zhe assertEquals("testtesttesttest", SCTool.getCellText("A1")); 25880a6f5c5SLiu Zhe 25980a6f5c5SLiu Zhe SCTool.selectRange("A2"); 26080a6f5c5SLiu Zhe scInputBarInput.activate(); 26180a6f5c5SLiu Zhe typeKeys("sfsafsddddddd<enter>"); 26257caf934SLiu Zhe activeMsgBox.cancel(); 26380a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A2")); 26480a6f5c5SLiu Zhe 26580a6f5c5SLiu Zhe SCTool.selectRange("A2"); 26680a6f5c5SLiu Zhe scInputBarInput.activate(); 26780a6f5c5SLiu Zhe typeKeys("10<enter>"); 26880a6f5c5SLiu Zhe assertEquals("10", SCTool.getCellText("A2")); 26980a6f5c5SLiu Zhe 27080a6f5c5SLiu Zhe SCTool.selectRange("A3"); 27180a6f5c5SLiu Zhe scInputBarInput.activate(); 27280a6f5c5SLiu Zhe typeKeys("ok<enter>"); 27380a6f5c5SLiu Zhe assertEquals("ok", SCTool.getCellText("A3")); 27480a6f5c5SLiu Zhe } 27580a6f5c5SLiu Zhe 27680a6f5c5SLiu Zhe /** 27780a6f5c5SLiu Zhe * test Allow list. 27880a6f5c5SLiu Zhe */ 27980a6f5c5SLiu Zhe @Test 28080a6f5c5SLiu Zhe public void testAllowListSpecialChar() { 28180a6f5c5SLiu Zhe 28280a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 28380a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(6); // "List" 28480a6f5c5SLiu Zhe scValidityEntries.focus(); 28580a6f5c5SLiu Zhe typeKeys("a"); 28680a6f5c5SLiu Zhe typeKeys("<enter>"); 28780a6f5c5SLiu Zhe typeKeys("b"); 28880a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 28980a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 29080a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 29180a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 29280a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 29380a6f5c5SLiu Zhe scValidityCriteriaTabpage.ok(); 29480a6f5c5SLiu Zhe 29580a6f5c5SLiu Zhe // These codes are not stable: start 29680a6f5c5SLiu Zhe // calc.rightClick(1, 1); 29780a6f5c5SLiu Zhe // typeKeys("<shift s>"); 29880a6f5c5SLiu Zhe // typeKeys("<down><enter>"); // Choose a 29980a6f5c5SLiu Zhe // sleep(2); // if no sleep, error occur 30080a6f5c5SLiu Zhe // These codes are not stable: end 30180a6f5c5SLiu Zhe SCTool.selectRange("A1"); 30280a6f5c5SLiu Zhe scInputBarInput.activate(); 30380a6f5c5SLiu Zhe typeKeys("a<enter>"); 30480a6f5c5SLiu Zhe assertEquals("a", SCTool.getCellText("A1")); 30580a6f5c5SLiu Zhe 30680a6f5c5SLiu Zhe SCTool.selectRange("B2"); 30780a6f5c5SLiu Zhe scInputBarInput.activate(); 30880a6f5c5SLiu Zhe typeKeys("test"); 30980a6f5c5SLiu Zhe typeKeys("<enter>"); 31057caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 31157caf934SLiu Zhe activeMsgBox.ok(); 31280a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 31380a6f5c5SLiu Zhe } 31480a6f5c5SLiu Zhe 31580a6f5c5SLiu Zhe /** 31680a6f5c5SLiu Zhe * test Allow time between in Validity. 31780a6f5c5SLiu Zhe */ 31880a6f5c5SLiu Zhe @Test 31980a6f5c5SLiu Zhe public void testAllowTimeBetween() { 32080a6f5c5SLiu Zhe 32180a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 32280a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(4); // "Time" 32380a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(6); // "between" 32480a6f5c5SLiu Zhe scValiditySourceInput.setText("27:00"); 32580a6f5c5SLiu Zhe scValidityMaxValueInput.setText("21:00"); 32680a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 32780a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 32880a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 32980a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 33080a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 33180a6f5c5SLiu Zhe 33280a6f5c5SLiu Zhe SCTool.selectRange("A1"); 33380a6f5c5SLiu Zhe scInputBarInput.activate(); 33480a6f5c5SLiu Zhe typeKeys("21:00"); 33580a6f5c5SLiu Zhe typeKeys("<enter>"); 33680a6f5c5SLiu Zhe assertEquals("09:00:00 PM", SCTool.getCellText("A1")); 33780a6f5c5SLiu Zhe 33880a6f5c5SLiu Zhe SCTool.selectRange("A2"); 33980a6f5c5SLiu Zhe scInputBarInput.activate(); 34080a6f5c5SLiu Zhe typeKeys("27:00"); 34180a6f5c5SLiu Zhe typeKeys("<enter>"); 34280a6f5c5SLiu Zhe assertEquals("27:00:00", SCTool.getCellText("A2")); 34380a6f5c5SLiu Zhe 34480a6f5c5SLiu Zhe SCTool.selectRange("A3"); 34580a6f5c5SLiu Zhe scInputBarInput.activate(); 34680a6f5c5SLiu Zhe typeKeys("1.125"); 34780a6f5c5SLiu Zhe typeKeys("<enter>"); 34880a6f5c5SLiu Zhe assertEquals("1.125", SCTool.getCellText("A3")); 34980a6f5c5SLiu Zhe 35080a6f5c5SLiu Zhe SCTool.selectRange("A4"); 35180a6f5c5SLiu Zhe scInputBarInput.activate(); 35280a6f5c5SLiu Zhe typeKeys("0.875"); 35380a6f5c5SLiu Zhe typeKeys("<enter>"); 35480a6f5c5SLiu Zhe assertEquals("0.875", SCTool.getCellText("A4")); 35580a6f5c5SLiu Zhe 35680a6f5c5SLiu Zhe SCTool.selectRange("B1"); 35780a6f5c5SLiu Zhe scInputBarInput.activate(); 35880a6f5c5SLiu Zhe typeKeys("03:00:01"); 35980a6f5c5SLiu Zhe typeKeys("<enter>"); 36057caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 36157caf934SLiu Zhe activeMsgBox.ok(); 36280a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B1")); 36380a6f5c5SLiu Zhe 36480a6f5c5SLiu Zhe SCTool.selectRange("B2"); 36580a6f5c5SLiu Zhe scInputBarInput.activate(); 36680a6f5c5SLiu Zhe typeKeys("20:59:59"); 36780a6f5c5SLiu Zhe typeKeys("<enter>"); 36857caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 36957caf934SLiu Zhe activeMsgBox.ok(); 37080a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 37180a6f5c5SLiu Zhe 37280a6f5c5SLiu Zhe SCTool.selectRange("B3"); 37380a6f5c5SLiu Zhe scInputBarInput.activate(); 37480a6f5c5SLiu Zhe typeKeys("1.126"); 37580a6f5c5SLiu Zhe typeKeys("<enter>"); 37657caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 37757caf934SLiu Zhe activeMsgBox.ok(); 37880a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B3")); 37980a6f5c5SLiu Zhe 38080a6f5c5SLiu Zhe SCTool.selectRange("B4"); 38180a6f5c5SLiu Zhe scInputBarInput.activate(); 38280a6f5c5SLiu Zhe typeKeys("0.874"); 38380a6f5c5SLiu Zhe typeKeys("<enter>"); 38457caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 38557caf934SLiu Zhe activeMsgBox.ok(); 38680a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B4")); 38780a6f5c5SLiu Zhe 38880a6f5c5SLiu Zhe SCTool.selectRange("C1"); 38980a6f5c5SLiu Zhe scInputBarInput.activate(); 39080a6f5c5SLiu Zhe typeKeys("test"); 39180a6f5c5SLiu Zhe typeKeys("<enter>"); 39257caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 39357caf934SLiu Zhe activeMsgBox.ok(); 39480a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("C1")); 39580a6f5c5SLiu Zhe 39680a6f5c5SLiu Zhe SCTool.selectRange("C2"); 39780a6f5c5SLiu Zhe scInputBarInput.activate(); 39880a6f5c5SLiu Zhe typeKeys("24:00"); 39980a6f5c5SLiu Zhe typeKeys("<enter>"); 40080a6f5c5SLiu Zhe assertEquals("24:00:00", SCTool.getCellText("C2")); 40180a6f5c5SLiu Zhe 40280a6f5c5SLiu Zhe SCTool.selectRange("C3"); 40380a6f5c5SLiu Zhe scInputBarInput.activate(); 40480a6f5c5SLiu Zhe typeKeys("12:00"); 40580a6f5c5SLiu Zhe typeKeys("<enter>"); 40657caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 40757caf934SLiu Zhe activeMsgBox.ok(); 40880a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("C3")); 40980a6f5c5SLiu Zhe } 41080a6f5c5SLiu Zhe 41180a6f5c5SLiu Zhe /** 41280a6f5c5SLiu Zhe * test Allow time Greater than and equal to in Validity. 41380a6f5c5SLiu Zhe */ 41480a6f5c5SLiu Zhe @Test 41580a6f5c5SLiu Zhe public void testAllowTimeGreaterThan() { 41680a6f5c5SLiu Zhe 41780a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 41880a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(4); // "Time" 41980a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(4); // "greater than or equal to" 42080a6f5c5SLiu Zhe scValiditySourceInput.setText("8:00"); 42180a6f5c5SLiu Zhe 42280a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 42380a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 42480a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(1); // "Warning" 42580a6f5c5SLiu Zhe 42680a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("warning to enter"); 42780a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 42880a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 42980a6f5c5SLiu Zhe 43080a6f5c5SLiu Zhe SCTool.selectRange("A1"); 43180a6f5c5SLiu Zhe scInputBarInput.activate(); 43280a6f5c5SLiu Zhe typeKeys("7:30"); 43380a6f5c5SLiu Zhe typeKeys("<enter>"); 43457caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 43557caf934SLiu Zhe activeMsgBox.ok(); 43680a6f5c5SLiu Zhe assertEquals("07:30:00 AM", SCTool.getCellText("A1")); 43780a6f5c5SLiu Zhe 43880a6f5c5SLiu Zhe SCTool.selectRange("A2"); 43980a6f5c5SLiu Zhe scInputBarInput.activate(); 44080a6f5c5SLiu Zhe typeKeys("6:00"); 44180a6f5c5SLiu Zhe typeKeys("<enter>"); 44257caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 44357caf934SLiu Zhe activeMsgBox.cancel(); 44480a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A2")); 44580a6f5c5SLiu Zhe 44680a6f5c5SLiu Zhe SCTool.selectRange("A3"); 44780a6f5c5SLiu Zhe scInputBarInput.activate(); 44880a6f5c5SLiu Zhe typeKeys("8:00"); 44980a6f5c5SLiu Zhe typeKeys("<enter>"); 45080a6f5c5SLiu Zhe assertEquals("08:00:00 AM", SCTool.getCellText("A3")); 45180a6f5c5SLiu Zhe } 45280a6f5c5SLiu Zhe 45380a6f5c5SLiu Zhe /** 45480a6f5c5SLiu Zhe * test Allow whole number, less than or equal to in Validity. 45580a6f5c5SLiu Zhe */ 45680a6f5c5SLiu Zhe @Test 45780a6f5c5SLiu Zhe public void testAllowWholeNumLessThan() { 45880a6f5c5SLiu Zhe 45980a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 46080a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(1); // "Whole Numbers" 46180a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(3); // "less than or equal" 46280a6f5c5SLiu Zhe scValiditySourceInput.setText("100"); 46380a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 46480a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 46580a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 46680a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 46780a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 46880a6f5c5SLiu Zhe 46980a6f5c5SLiu Zhe SCTool.selectRange("A1"); 47080a6f5c5SLiu Zhe scInputBarInput.activate(); 47180a6f5c5SLiu Zhe typeKeys("99"); 47280a6f5c5SLiu Zhe typeKeys("<enter>"); 47380a6f5c5SLiu Zhe assertEquals("99", SCTool.getCellText("A1")); 47480a6f5c5SLiu Zhe 47580a6f5c5SLiu Zhe SCTool.selectRange("A2"); 47680a6f5c5SLiu Zhe scInputBarInput.activate(); 47780a6f5c5SLiu Zhe typeKeys("100"); 47880a6f5c5SLiu Zhe typeKeys("<enter>"); 47980a6f5c5SLiu Zhe assertEquals("100", SCTool.getCellText("A2")); 48080a6f5c5SLiu Zhe 48180a6f5c5SLiu Zhe SCTool.selectRange("B1"); 48280a6f5c5SLiu Zhe scInputBarInput.activate(); 48380a6f5c5SLiu Zhe typeKeys("101"); 48480a6f5c5SLiu Zhe typeKeys("<enter>"); 48557caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 48657caf934SLiu Zhe activeMsgBox.ok(); 48780a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B1")); 48880a6f5c5SLiu Zhe 48980a6f5c5SLiu Zhe SCTool.selectRange("B2"); 49080a6f5c5SLiu Zhe scInputBarInput.activate(); 49180a6f5c5SLiu Zhe typeKeys("45.5"); 49280a6f5c5SLiu Zhe typeKeys("<enter>"); 49357caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 49457caf934SLiu Zhe activeMsgBox.ok(); 49580a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 49680a6f5c5SLiu Zhe 49780a6f5c5SLiu Zhe SCTool.selectRange("C1"); 49880a6f5c5SLiu Zhe scInputBarInput.activate(); 49980a6f5c5SLiu Zhe typeKeys("test"); 50080a6f5c5SLiu Zhe typeKeys("<enter>"); 50157caf934SLiu Zhe assertEquals("Invalid value", activeMsgBox.getMessage()); 50257caf934SLiu Zhe activeMsgBox.ok(); 50380a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("C1")); 50480a6f5c5SLiu Zhe } 50580a6f5c5SLiu Zhe 50680a6f5c5SLiu Zhe /** 50780a6f5c5SLiu Zhe * test default message of Error Alert in Validity. 50880a6f5c5SLiu Zhe */ 50980a6f5c5SLiu Zhe @Test 51080a6f5c5SLiu Zhe public void testDefaultErrorAlertMessage() { 51180a6f5c5SLiu Zhe 51280a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 51380a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(2); // "Decimal" 51480a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(0); // "equal" 51580a6f5c5SLiu Zhe scValiditySourceInput.setText("1"); 51680a6f5c5SLiu Zhe 51780a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 51880a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 51980a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(0); // "Stop" 52080a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 52180a6f5c5SLiu Zhe 52280a6f5c5SLiu Zhe SCTool.selectRange("A1"); 52380a6f5c5SLiu Zhe scInputBarInput.activate(); 52480a6f5c5SLiu Zhe typeKeys("13"); 52580a6f5c5SLiu Zhe typeKeys("<enter>"); 52657caf934SLiu Zhe assertEquals("OpenOffice.org Calc", activeMsgBox.getCaption()); 52780a6f5c5SLiu Zhe // assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not 52880a6f5c5SLiu Zhe // verify in multi-language 52957caf934SLiu Zhe activeMsgBox.ok(); 53080a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A1")); 53180a6f5c5SLiu Zhe } 53280a6f5c5SLiu Zhe 53380a6f5c5SLiu Zhe /** 53480a6f5c5SLiu Zhe * test uncheck Error Alert in Validity. 53580a6f5c5SLiu Zhe */ 53680a6f5c5SLiu Zhe @Test 53780a6f5c5SLiu Zhe public void testUncheckErrorAlert() { 53880a6f5c5SLiu Zhe 53980a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 54080a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(2); // "Decimal" 54180a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(0); // "equal" 54280a6f5c5SLiu Zhe scValiditySourceInput.setText("1"); 54380a6f5c5SLiu Zhe 54480a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 54580a6f5c5SLiu Zhe scValidityShowErrorMessage.uncheck(); 54680a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(0); // "Stop" 54780a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 54880a6f5c5SLiu Zhe 54980a6f5c5SLiu Zhe SCTool.selectRange("A1"); 55080a6f5c5SLiu Zhe typeKeys("13"); 55180a6f5c5SLiu Zhe typeKeys("<enter>"); 55280a6f5c5SLiu Zhe assertEquals("13", SCTool.getCellText("A1")); 55380a6f5c5SLiu Zhe } 55480a6f5c5SLiu Zhe 55580a6f5c5SLiu Zhe /** 55680a6f5c5SLiu Zhe * test Cell range source picker in Validity. Input from Edit Box. 55780a6f5c5SLiu Zhe */ 55880a6f5c5SLiu Zhe @Test 55980a6f5c5SLiu Zhe public void testValidityCellRangeSourcePicker() { 56080a6f5c5SLiu Zhe 56180a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 56280a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(5); // "Cell range" 56380a6f5c5SLiu Zhe scValiditySourcePicker.click(); 56480a6f5c5SLiu Zhe assertEquals(false, scValidityCriteriaAllowList.exists()); 56580a6f5c5SLiu Zhe scValiditySourceInput.setText("$E$2:$G$5"); 56680a6f5c5SLiu Zhe scValiditySourcePicker.click(); 56780a6f5c5SLiu Zhe assertEquals(true, scValidityCriteriaAllowList.exists()); 56880a6f5c5SLiu Zhe 56980a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 57080a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 57180a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(0); // "Stop" 57280a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 57380a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value."); 57480a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 57580a6f5c5SLiu Zhe 57680a6f5c5SLiu Zhe // calc.focus(); 57780a6f5c5SLiu Zhe SCTool.selectRange("E2"); 57880a6f5c5SLiu Zhe scInputBarInput.activate(); 57980a6f5c5SLiu Zhe typeKeys("test"); 58080a6f5c5SLiu Zhe typeKeys("<enter>"); 58180a6f5c5SLiu Zhe 58280a6f5c5SLiu Zhe SCTool.selectRange("A1"); 58380a6f5c5SLiu Zhe scInputBarInput.activate(); 58480a6f5c5SLiu Zhe typeKeys("test32"); 58580a6f5c5SLiu Zhe typeKeys("<enter>"); 58657caf934SLiu Zhe assertEquals("Invalid value.", activeMsgBox.getMessage()); 58757caf934SLiu Zhe activeMsgBox.ok(); 58880a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A1")); 58980a6f5c5SLiu Zhe 59080a6f5c5SLiu Zhe SCTool.selectRange("B1"); 59180a6f5c5SLiu Zhe scInputBarInput.activate(); 59280a6f5c5SLiu Zhe typeKeys("test"); 59380a6f5c5SLiu Zhe typeKeys("<enter>"); 59480a6f5c5SLiu Zhe assertEquals("test", SCTool.getCellText("B1")); 59580a6f5c5SLiu Zhe } 59680a6f5c5SLiu Zhe 59780a6f5c5SLiu Zhe /** 59880a6f5c5SLiu Zhe * test Allow Blank cell Checkbox in Validity. 59980a6f5c5SLiu Zhe */ 60080a6f5c5SLiu Zhe @Test 60180a6f5c5SLiu Zhe public void testAllowBlankCells() { 60280a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 60380a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(5); // "Cell range" 60480a6f5c5SLiu Zhe scValiditySourceInput.setText("$E$1:$E$5"); 60580a6f5c5SLiu Zhe scValidityAllowBlankCells.check(); 60680a6f5c5SLiu Zhe scValidityCriteriaTabpage.ok(); 60780a6f5c5SLiu Zhe 60880a6f5c5SLiu Zhe SCTool.selectRange("E1"); 60980a6f5c5SLiu Zhe typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>"); 61080a6f5c5SLiu Zhe 61180a6f5c5SLiu Zhe SCTool.selectRange("A1"); 61280a6f5c5SLiu Zhe typeKeys("A<enter>"); 61380a6f5c5SLiu Zhe SCTool.selectRange("D1"); 61480a6f5c5SLiu Zhe scInputBarInput.activate(); 61580a6f5c5SLiu Zhe typeKeys("<backspace><enter>"); 61680a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("D1")); 61780a6f5c5SLiu Zhe 61880a6f5c5SLiu Zhe SCTool.selectRange("B1"); 61980a6f5c5SLiu Zhe app.dispatch(".uno:Validation"); 62080a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 62180a6f5c5SLiu Zhe scValidityAllowBlankCells.uncheck(); 62280a6f5c5SLiu Zhe typeKeys("<enter>"); 62380a6f5c5SLiu Zhe 62480a6f5c5SLiu Zhe SCTool.selectRange("B1"); 62580a6f5c5SLiu Zhe scInputBarInput.activate(); 62680a6f5c5SLiu Zhe typeKeys("<backspace><enter>"); 62780a6f5c5SLiu Zhe typeKeys("<enter>"); 62880a6f5c5SLiu Zhe } 62980a6f5c5SLiu Zhe } 630