1*80a6f5c5SLiu Zhe /************************************************************** 2*80a6f5c5SLiu Zhe * 3*80a6f5c5SLiu Zhe * Licensed to the Apache Software Foundation (ASF) under one 4*80a6f5c5SLiu Zhe * or more contributor license agreements. See the NOTICE file 5*80a6f5c5SLiu Zhe * distributed with this work for additional information 6*80a6f5c5SLiu Zhe * regarding copyright ownership. The ASF licenses this file 7*80a6f5c5SLiu Zhe * to you under the Apache License, Version 2.0 (the 8*80a6f5c5SLiu Zhe * "License"); you may not use this file except in compliance 9*80a6f5c5SLiu Zhe * with the License. You may obtain a copy of the License at 10*80a6f5c5SLiu Zhe * 11*80a6f5c5SLiu Zhe * http://www.apache.org/licenses/LICENSE-2.0 12*80a6f5c5SLiu Zhe * 13*80a6f5c5SLiu Zhe * Unless required by applicable law or agreed to in writing, 14*80a6f5c5SLiu Zhe * software distributed under the License is distributed on an 15*80a6f5c5SLiu Zhe * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*80a6f5c5SLiu Zhe * KIND, either express or implied. See the License for the 17*80a6f5c5SLiu Zhe * specific language governing permissions and limitations 18*80a6f5c5SLiu Zhe * under the License. 19*80a6f5c5SLiu Zhe * 20*80a6f5c5SLiu Zhe *************************************************************/ 21*80a6f5c5SLiu Zhe 22*80a6f5c5SLiu Zhe package fvt.gui.sc.validity; 23*80a6f5c5SLiu Zhe 24*80a6f5c5SLiu Zhe import static org.junit.Assert.*; 25*80a6f5c5SLiu Zhe import static testlib.gui.AppTool.*; 26*80a6f5c5SLiu Zhe import static testlib.gui.UIMap.*; 27*80a6f5c5SLiu Zhe 28*80a6f5c5SLiu Zhe import java.io.File; 29*80a6f5c5SLiu Zhe 30*80a6f5c5SLiu Zhe import org.junit.After; 31*80a6f5c5SLiu Zhe import org.junit.Before; 32*80a6f5c5SLiu Zhe import org.junit.Ignore; 33*80a6f5c5SLiu Zhe import org.junit.Rule; 34*80a6f5c5SLiu Zhe import org.junit.Test; 35*80a6f5c5SLiu Zhe import org.openoffice.test.common.Logger; 36*80a6f5c5SLiu Zhe import org.openoffice.test.vcl.IDList; 37*80a6f5c5SLiu Zhe import org.openoffice.test.vcl.widgets.VclMessageBox; 38*80a6f5c5SLiu Zhe 39*80a6f5c5SLiu Zhe import testlib.gui.SCTool; 40*80a6f5c5SLiu Zhe 41*80a6f5c5SLiu Zhe public class ValidityDialogSetting { 42*80a6f5c5SLiu Zhe private static IDList idList = new IDList(new File("./ids")); 43*80a6f5c5SLiu Zhe public static final VclMessageBox ActiveMsgBox = new VclMessageBox(idList.getId("UID_ACTIVE"), "Message on message box."); 44*80a6f5c5SLiu Zhe 45*80a6f5c5SLiu Zhe @Rule 46*80a6f5c5SLiu Zhe public Logger log = Logger.getLogger(this); 47*80a6f5c5SLiu Zhe 48*80a6f5c5SLiu Zhe @Before 49*80a6f5c5SLiu Zhe public void setUp() throws Exception { 50*80a6f5c5SLiu Zhe app.start(true); 51*80a6f5c5SLiu Zhe 52*80a6f5c5SLiu Zhe // New a spreadsheet, select cell range, open Validity dialog 53*80a6f5c5SLiu Zhe app.dispatch("private:factory/scalc"); 54*80a6f5c5SLiu Zhe calc.waitForExistence(10, 2); 55*80a6f5c5SLiu Zhe SCTool.selectRange("A1:C5"); 56*80a6f5c5SLiu Zhe app.dispatch(".uno:Validation"); 57*80a6f5c5SLiu Zhe } 58*80a6f5c5SLiu Zhe 59*80a6f5c5SLiu Zhe @After 60*80a6f5c5SLiu Zhe public void tearDown() throws Exception { 61*80a6f5c5SLiu Zhe 62*80a6f5c5SLiu Zhe } 63*80a6f5c5SLiu Zhe 64*80a6f5c5SLiu Zhe /** 65*80a6f5c5SLiu Zhe * test Allow not between Date type in Validity. 66*80a6f5c5SLiu Zhe */ 67*80a6f5c5SLiu Zhe @Test 68*80a6f5c5SLiu Zhe public void testAllowDateNotBetween() { 69*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 70*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(3); // "Date" 71*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(7); // "not between" 72*80a6f5c5SLiu Zhe scValiditySourceInput.setText("01/01/08"); 73*80a6f5c5SLiu Zhe scValidityMaxValueInput.setText("03/01/08"); 74*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 75*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 76*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 77*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 78*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 79*80a6f5c5SLiu Zhe 80*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 81*80a6f5c5SLiu Zhe scInputBarInput.activate(); 82*80a6f5c5SLiu Zhe typeKeys("12/31/07"); 83*80a6f5c5SLiu Zhe typeKeys("<enter>"); 84*80a6f5c5SLiu Zhe assertEquals("12/31/07", SCTool.getCellText("A1")); 85*80a6f5c5SLiu Zhe 86*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 87*80a6f5c5SLiu Zhe scInputBarInput.activate(); 88*80a6f5c5SLiu Zhe typeKeys("03/02/08"); 89*80a6f5c5SLiu Zhe typeKeys("<enter>"); 90*80a6f5c5SLiu Zhe assertEquals("03/02/08", SCTool.getCellText("A2")); 91*80a6f5c5SLiu Zhe 92*80a6f5c5SLiu Zhe SCTool.selectRange("A3"); 93*80a6f5c5SLiu Zhe scInputBarInput.activate(); 94*80a6f5c5SLiu Zhe typeKeys("01/01/08"); 95*80a6f5c5SLiu Zhe typeKeys("<enter>"); 96*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 97*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 98*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A3")); 99*80a6f5c5SLiu Zhe 100*80a6f5c5SLiu Zhe SCTool.selectRange("A4"); 101*80a6f5c5SLiu Zhe scInputBarInput.activate(); 102*80a6f5c5SLiu Zhe typeKeys("03/01/08"); 103*80a6f5c5SLiu Zhe typeKeys("<enter>"); 104*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 105*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 106*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A4")); 107*80a6f5c5SLiu Zhe 108*80a6f5c5SLiu Zhe SCTool.selectRange("A5"); 109*80a6f5c5SLiu Zhe scInputBarInput.activate(); 110*80a6f5c5SLiu Zhe typeKeys("01/02/08"); 111*80a6f5c5SLiu Zhe typeKeys("<enter>"); 112*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 113*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 114*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A5")); 115*80a6f5c5SLiu Zhe 116*80a6f5c5SLiu Zhe SCTool.selectRange("B1"); 117*80a6f5c5SLiu Zhe scInputBarInput.activate(); 118*80a6f5c5SLiu Zhe typeKeys("02/29/08"); 119*80a6f5c5SLiu Zhe typeKeys("<enter>"); 120*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 121*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 122*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B1")); 123*80a6f5c5SLiu Zhe 124*80a6f5c5SLiu Zhe SCTool.selectRange("B2"); 125*80a6f5c5SLiu Zhe scInputBarInput.activate(); 126*80a6f5c5SLiu Zhe typeKeys("test"); 127*80a6f5c5SLiu Zhe typeKeys("<enter>"); 128*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 129*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 130*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 131*80a6f5c5SLiu Zhe 132*80a6f5c5SLiu Zhe SCTool.selectRange("B3"); 133*80a6f5c5SLiu Zhe scInputBarInput.activate(); 134*80a6f5c5SLiu Zhe typeKeys("39448"); 135*80a6f5c5SLiu Zhe typeKeys("<enter>"); 136*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 137*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 138*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B3")); 139*80a6f5c5SLiu Zhe } 140*80a6f5c5SLiu Zhe 141*80a6f5c5SLiu Zhe /** 142*80a6f5c5SLiu Zhe * test Allow Decimal equal in Validity. 143*80a6f5c5SLiu Zhe */ 144*80a6f5c5SLiu Zhe @Test 145*80a6f5c5SLiu Zhe public void testAllowDecimalEqual() { 146*80a6f5c5SLiu Zhe 147*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 148*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(2); // "Decimal" 149*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(0); // "equal" 150*80a6f5c5SLiu Zhe scValiditySourceInput.setText("0.33333333"); 151*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 152*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 153*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 154*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 155*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 156*80a6f5c5SLiu Zhe 157*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 158*80a6f5c5SLiu Zhe scInputBarInput.activate(); 159*80a6f5c5SLiu Zhe typeKeys("0.33333333"); 160*80a6f5c5SLiu Zhe typeKeys("<enter>"); 161*80a6f5c5SLiu Zhe assertEquals("0.33333333", SCTool.getCellText("A1")); 162*80a6f5c5SLiu Zhe 163*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 164*80a6f5c5SLiu Zhe scInputBarInput.activate(); 165*80a6f5c5SLiu Zhe typeKeys("=1/3"); 166*80a6f5c5SLiu Zhe typeKeys("<enter>"); 167*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 168*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 169*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A2")); 170*80a6f5c5SLiu Zhe 171*80a6f5c5SLiu Zhe SCTool.selectRange("A3"); 172*80a6f5c5SLiu Zhe scInputBarInput.activate(); 173*80a6f5c5SLiu Zhe typeKeys("0.3"); 174*80a6f5c5SLiu Zhe typeKeys("<enter>"); 175*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 176*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 177*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A3")); 178*80a6f5c5SLiu Zhe 179*80a6f5c5SLiu Zhe SCTool.selectRange("A4"); 180*80a6f5c5SLiu Zhe scInputBarInput.activate(); 181*80a6f5c5SLiu Zhe typeKeys("0.333333333"); 182*80a6f5c5SLiu Zhe typeKeys("<enter>"); 183*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 184*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 185*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A4")); 186*80a6f5c5SLiu Zhe 187*80a6f5c5SLiu Zhe SCTool.selectRange("B2"); 188*80a6f5c5SLiu Zhe scInputBarInput.activate(); 189*80a6f5c5SLiu Zhe typeKeys("test"); 190*80a6f5c5SLiu Zhe typeKeys("<enter>"); 191*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 192*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 193*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 194*80a6f5c5SLiu Zhe } 195*80a6f5c5SLiu Zhe 196*80a6f5c5SLiu Zhe /** 197*80a6f5c5SLiu Zhe * test Allow Text length, greater than or equal to in Validity. 198*80a6f5c5SLiu Zhe */ 199*80a6f5c5SLiu Zhe @Test 200*80a6f5c5SLiu Zhe public void testAllowGreaterTextLength() { 201*80a6f5c5SLiu Zhe 202*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 203*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(7); // "Text length" 204*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(4); // "greater than or equal to" 205*80a6f5c5SLiu Zhe scValiditySourceInput.setText("10"); 206*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 207*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 208*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 209*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 210*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 211*80a6f5c5SLiu Zhe 212*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 213*80a6f5c5SLiu Zhe scInputBarInput.activate(); 214*80a6f5c5SLiu Zhe typeKeys("testtesttesttest"); 215*80a6f5c5SLiu Zhe typeKeys("<enter>"); 216*80a6f5c5SLiu Zhe assertEquals("testtesttesttest", SCTool.getCellText("A1")); 217*80a6f5c5SLiu Zhe 218*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 219*80a6f5c5SLiu Zhe scInputBarInput.activate(); 220*80a6f5c5SLiu Zhe typeKeys("test test "); 221*80a6f5c5SLiu Zhe typeKeys("<enter>"); 222*80a6f5c5SLiu Zhe assertEquals("test test ", SCTool.getCellText("A2")); 223*80a6f5c5SLiu Zhe 224*80a6f5c5SLiu Zhe SCTool.selectRange("A4"); 225*80a6f5c5SLiu Zhe scInputBarInput.activate(); 226*80a6f5c5SLiu Zhe typeKeys(" "); 227*80a6f5c5SLiu Zhe typeKeys("<enter>"); 228*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 229*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 230*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A4")); 231*80a6f5c5SLiu Zhe 232*80a6f5c5SLiu Zhe SCTool.selectRange("A3"); 233*80a6f5c5SLiu Zhe scInputBarInput.activate(); 234*80a6f5c5SLiu Zhe typeKeys("Testatest"); 235*80a6f5c5SLiu Zhe typeKeys("<enter>"); 236*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 237*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 238*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A3")); 239*80a6f5c5SLiu Zhe } 240*80a6f5c5SLiu Zhe 241*80a6f5c5SLiu Zhe /** 242*80a6f5c5SLiu Zhe * test Allow Text length, less than in Validity. 243*80a6f5c5SLiu Zhe */ 244*80a6f5c5SLiu Zhe @Ignore("Bug 93128") 245*80a6f5c5SLiu Zhe public void testAllowLessThanTextLength() { 246*80a6f5c5SLiu Zhe 247*80a6f5c5SLiu Zhe app.dispatch(".uno:Validation"); 248*80a6f5c5SLiu Zhe 249*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 250*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(7); // "Text length" 251*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(1); // "less than" 252*80a6f5c5SLiu Zhe scValiditySourceInput.setText("10"); 253*80a6f5c5SLiu Zhe 254*80a6f5c5SLiu Zhe scValidityInputHelpTabPage.select(); 255*80a6f5c5SLiu Zhe scValidityInputHelpCheckbox.check(); 256*80a6f5c5SLiu Zhe scValidityInputHelpTitle.setText("Help Info Title"); 257*80a6f5c5SLiu Zhe scValidityHelpMessage.setText("help info"); 258*80a6f5c5SLiu Zhe 259*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 260*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 261*80a6f5c5SLiu Zhe scValidityErrorAlertActionList.select("Information"); 262*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Notes to enter"); 263*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 264*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 265*80a6f5c5SLiu Zhe 266*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 267*80a6f5c5SLiu Zhe scInputBarInput.activate(); 268*80a6f5c5SLiu Zhe typeKeys("testtesttesttest<enter>"); 269*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 270*80a6f5c5SLiu Zhe assertEquals("testtesttesttest", SCTool.getCellText("A1")); 271*80a6f5c5SLiu Zhe 272*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 273*80a6f5c5SLiu Zhe scInputBarInput.activate(); 274*80a6f5c5SLiu Zhe typeKeys("sfsafsddddddd<enter>"); 275*80a6f5c5SLiu Zhe ActiveMsgBox.cancel(); 276*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A2")); 277*80a6f5c5SLiu Zhe 278*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 279*80a6f5c5SLiu Zhe scInputBarInput.activate(); 280*80a6f5c5SLiu Zhe typeKeys("10<enter>"); 281*80a6f5c5SLiu Zhe assertEquals("10", SCTool.getCellText("A2")); 282*80a6f5c5SLiu Zhe 283*80a6f5c5SLiu Zhe SCTool.selectRange("A3"); 284*80a6f5c5SLiu Zhe scInputBarInput.activate(); 285*80a6f5c5SLiu Zhe typeKeys("ok<enter>"); 286*80a6f5c5SLiu Zhe assertEquals("ok", SCTool.getCellText("A3")); 287*80a6f5c5SLiu Zhe } 288*80a6f5c5SLiu Zhe 289*80a6f5c5SLiu Zhe /** 290*80a6f5c5SLiu Zhe * test Allow list. 291*80a6f5c5SLiu Zhe */ 292*80a6f5c5SLiu Zhe @Test 293*80a6f5c5SLiu Zhe public void testAllowListSpecialChar() { 294*80a6f5c5SLiu Zhe 295*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 296*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(6); // "List" 297*80a6f5c5SLiu Zhe scValidityEntries.focus(); 298*80a6f5c5SLiu Zhe typeKeys("a"); 299*80a6f5c5SLiu Zhe typeKeys("<enter>"); 300*80a6f5c5SLiu Zhe typeKeys("b"); 301*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 302*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 303*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 304*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 305*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 306*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.ok(); 307*80a6f5c5SLiu Zhe 308*80a6f5c5SLiu Zhe // These codes are not stable: start 309*80a6f5c5SLiu Zhe // calc.rightClick(1, 1); 310*80a6f5c5SLiu Zhe // typeKeys("<shift s>"); 311*80a6f5c5SLiu Zhe // typeKeys("<down><enter>"); // Choose a 312*80a6f5c5SLiu Zhe // sleep(2); // if no sleep, error occur 313*80a6f5c5SLiu Zhe // These codes are not stable: end 314*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 315*80a6f5c5SLiu Zhe scInputBarInput.activate(); 316*80a6f5c5SLiu Zhe typeKeys("a<enter>"); 317*80a6f5c5SLiu Zhe assertEquals("a", SCTool.getCellText("A1")); 318*80a6f5c5SLiu Zhe 319*80a6f5c5SLiu Zhe SCTool.selectRange("B2"); 320*80a6f5c5SLiu Zhe scInputBarInput.activate(); 321*80a6f5c5SLiu Zhe typeKeys("test"); 322*80a6f5c5SLiu Zhe typeKeys("<enter>"); 323*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 324*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 325*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 326*80a6f5c5SLiu Zhe } 327*80a6f5c5SLiu Zhe 328*80a6f5c5SLiu Zhe /** 329*80a6f5c5SLiu Zhe * test Allow time between in Validity. 330*80a6f5c5SLiu Zhe */ 331*80a6f5c5SLiu Zhe @Test 332*80a6f5c5SLiu Zhe public void testAllowTimeBetween() { 333*80a6f5c5SLiu Zhe 334*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 335*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(4); // "Time" 336*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(6); // "between" 337*80a6f5c5SLiu Zhe scValiditySourceInput.setText("27:00"); 338*80a6f5c5SLiu Zhe scValidityMaxValueInput.setText("21:00"); 339*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 340*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 341*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 342*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 343*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 344*80a6f5c5SLiu Zhe 345*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 346*80a6f5c5SLiu Zhe scInputBarInput.activate(); 347*80a6f5c5SLiu Zhe typeKeys("21:00"); 348*80a6f5c5SLiu Zhe typeKeys("<enter>"); 349*80a6f5c5SLiu Zhe assertEquals("09:00:00 PM", SCTool.getCellText("A1")); 350*80a6f5c5SLiu Zhe 351*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 352*80a6f5c5SLiu Zhe scInputBarInput.activate(); 353*80a6f5c5SLiu Zhe typeKeys("27:00"); 354*80a6f5c5SLiu Zhe typeKeys("<enter>"); 355*80a6f5c5SLiu Zhe assertEquals("27:00:00", SCTool.getCellText("A2")); 356*80a6f5c5SLiu Zhe 357*80a6f5c5SLiu Zhe SCTool.selectRange("A3"); 358*80a6f5c5SLiu Zhe scInputBarInput.activate(); 359*80a6f5c5SLiu Zhe typeKeys("1.125"); 360*80a6f5c5SLiu Zhe typeKeys("<enter>"); 361*80a6f5c5SLiu Zhe assertEquals("1.125", SCTool.getCellText("A3")); 362*80a6f5c5SLiu Zhe 363*80a6f5c5SLiu Zhe SCTool.selectRange("A4"); 364*80a6f5c5SLiu Zhe scInputBarInput.activate(); 365*80a6f5c5SLiu Zhe typeKeys("0.875"); 366*80a6f5c5SLiu Zhe typeKeys("<enter>"); 367*80a6f5c5SLiu Zhe assertEquals("0.875", SCTool.getCellText("A4")); 368*80a6f5c5SLiu Zhe 369*80a6f5c5SLiu Zhe SCTool.selectRange("B1"); 370*80a6f5c5SLiu Zhe scInputBarInput.activate(); 371*80a6f5c5SLiu Zhe typeKeys("03:00:01"); 372*80a6f5c5SLiu Zhe typeKeys("<enter>"); 373*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 374*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 375*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B1")); 376*80a6f5c5SLiu Zhe 377*80a6f5c5SLiu Zhe SCTool.selectRange("B2"); 378*80a6f5c5SLiu Zhe scInputBarInput.activate(); 379*80a6f5c5SLiu Zhe typeKeys("20:59:59"); 380*80a6f5c5SLiu Zhe typeKeys("<enter>"); 381*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 382*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 383*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 384*80a6f5c5SLiu Zhe 385*80a6f5c5SLiu Zhe SCTool.selectRange("B3"); 386*80a6f5c5SLiu Zhe scInputBarInput.activate(); 387*80a6f5c5SLiu Zhe typeKeys("1.126"); 388*80a6f5c5SLiu Zhe typeKeys("<enter>"); 389*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 390*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 391*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B3")); 392*80a6f5c5SLiu Zhe 393*80a6f5c5SLiu Zhe SCTool.selectRange("B4"); 394*80a6f5c5SLiu Zhe scInputBarInput.activate(); 395*80a6f5c5SLiu Zhe typeKeys("0.874"); 396*80a6f5c5SLiu Zhe typeKeys("<enter>"); 397*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 398*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 399*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B4")); 400*80a6f5c5SLiu Zhe 401*80a6f5c5SLiu Zhe SCTool.selectRange("C1"); 402*80a6f5c5SLiu Zhe scInputBarInput.activate(); 403*80a6f5c5SLiu Zhe typeKeys("test"); 404*80a6f5c5SLiu Zhe typeKeys("<enter>"); 405*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 406*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 407*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("C1")); 408*80a6f5c5SLiu Zhe 409*80a6f5c5SLiu Zhe SCTool.selectRange("C2"); 410*80a6f5c5SLiu Zhe scInputBarInput.activate(); 411*80a6f5c5SLiu Zhe typeKeys("24:00"); 412*80a6f5c5SLiu Zhe typeKeys("<enter>"); 413*80a6f5c5SLiu Zhe assertEquals("24:00:00", SCTool.getCellText("C2")); 414*80a6f5c5SLiu Zhe 415*80a6f5c5SLiu Zhe SCTool.selectRange("C3"); 416*80a6f5c5SLiu Zhe scInputBarInput.activate(); 417*80a6f5c5SLiu Zhe typeKeys("12:00"); 418*80a6f5c5SLiu Zhe typeKeys("<enter>"); 419*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 420*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 421*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("C3")); 422*80a6f5c5SLiu Zhe } 423*80a6f5c5SLiu Zhe 424*80a6f5c5SLiu Zhe /** 425*80a6f5c5SLiu Zhe * test Allow time Greater than and equal to in Validity. 426*80a6f5c5SLiu Zhe */ 427*80a6f5c5SLiu Zhe @Test 428*80a6f5c5SLiu Zhe public void testAllowTimeGreaterThan() { 429*80a6f5c5SLiu Zhe 430*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 431*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(4); // "Time" 432*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(4); // "greater than or equal to" 433*80a6f5c5SLiu Zhe scValiditySourceInput.setText("8:00"); 434*80a6f5c5SLiu Zhe 435*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 436*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 437*80a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(1); // "Warning" 438*80a6f5c5SLiu Zhe 439*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("warning to enter"); 440*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 441*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 442*80a6f5c5SLiu Zhe 443*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 444*80a6f5c5SLiu Zhe scInputBarInput.activate(); 445*80a6f5c5SLiu Zhe typeKeys("7:30"); 446*80a6f5c5SLiu Zhe typeKeys("<enter>"); 447*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 448*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 449*80a6f5c5SLiu Zhe assertEquals("07:30:00 AM", SCTool.getCellText("A1")); 450*80a6f5c5SLiu Zhe 451*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 452*80a6f5c5SLiu Zhe scInputBarInput.activate(); 453*80a6f5c5SLiu Zhe typeKeys("6:00"); 454*80a6f5c5SLiu Zhe typeKeys("<enter>"); 455*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 456*80a6f5c5SLiu Zhe ActiveMsgBox.cancel(); 457*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A2")); 458*80a6f5c5SLiu Zhe 459*80a6f5c5SLiu Zhe SCTool.selectRange("A3"); 460*80a6f5c5SLiu Zhe scInputBarInput.activate(); 461*80a6f5c5SLiu Zhe typeKeys("8:00"); 462*80a6f5c5SLiu Zhe typeKeys("<enter>"); 463*80a6f5c5SLiu Zhe assertEquals("08:00:00 AM", SCTool.getCellText("A3")); 464*80a6f5c5SLiu Zhe } 465*80a6f5c5SLiu Zhe 466*80a6f5c5SLiu Zhe /** 467*80a6f5c5SLiu Zhe * test Allow whole number, less than or equal to in Validity. 468*80a6f5c5SLiu Zhe */ 469*80a6f5c5SLiu Zhe @Test 470*80a6f5c5SLiu Zhe public void testAllowWholeNumLessThan() { 471*80a6f5c5SLiu Zhe 472*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 473*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(1); // "Whole Numbers" 474*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(3); // "less than or equal" 475*80a6f5c5SLiu Zhe scValiditySourceInput.setText("100"); 476*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 477*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 478*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 479*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value"); 480*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 481*80a6f5c5SLiu Zhe 482*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 483*80a6f5c5SLiu Zhe scInputBarInput.activate(); 484*80a6f5c5SLiu Zhe typeKeys("99"); 485*80a6f5c5SLiu Zhe typeKeys("<enter>"); 486*80a6f5c5SLiu Zhe assertEquals("99", SCTool.getCellText("A1")); 487*80a6f5c5SLiu Zhe 488*80a6f5c5SLiu Zhe SCTool.selectRange("A2"); 489*80a6f5c5SLiu Zhe scInputBarInput.activate(); 490*80a6f5c5SLiu Zhe typeKeys("100"); 491*80a6f5c5SLiu Zhe typeKeys("<enter>"); 492*80a6f5c5SLiu Zhe assertEquals("100", SCTool.getCellText("A2")); 493*80a6f5c5SLiu Zhe 494*80a6f5c5SLiu Zhe SCTool.selectRange("B1"); 495*80a6f5c5SLiu Zhe scInputBarInput.activate(); 496*80a6f5c5SLiu Zhe typeKeys("101"); 497*80a6f5c5SLiu Zhe typeKeys("<enter>"); 498*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 499*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 500*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B1")); 501*80a6f5c5SLiu Zhe 502*80a6f5c5SLiu Zhe SCTool.selectRange("B2"); 503*80a6f5c5SLiu Zhe scInputBarInput.activate(); 504*80a6f5c5SLiu Zhe typeKeys("45.5"); 505*80a6f5c5SLiu Zhe typeKeys("<enter>"); 506*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 507*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 508*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("B2")); 509*80a6f5c5SLiu Zhe 510*80a6f5c5SLiu Zhe SCTool.selectRange("C1"); 511*80a6f5c5SLiu Zhe scInputBarInput.activate(); 512*80a6f5c5SLiu Zhe typeKeys("test"); 513*80a6f5c5SLiu Zhe typeKeys("<enter>"); 514*80a6f5c5SLiu Zhe assertEquals("Invalid value", ActiveMsgBox.getMessage()); 515*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 516*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("C1")); 517*80a6f5c5SLiu Zhe } 518*80a6f5c5SLiu Zhe 519*80a6f5c5SLiu Zhe /** 520*80a6f5c5SLiu Zhe * test default message of Error Alert in Validity. 521*80a6f5c5SLiu Zhe */ 522*80a6f5c5SLiu Zhe @Test 523*80a6f5c5SLiu Zhe public void testDefaultErrorAlertMessage() { 524*80a6f5c5SLiu Zhe 525*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 526*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(2); // "Decimal" 527*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(0); // "equal" 528*80a6f5c5SLiu Zhe scValiditySourceInput.setText("1"); 529*80a6f5c5SLiu Zhe 530*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 531*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 532*80a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(0); // "Stop" 533*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 534*80a6f5c5SLiu Zhe 535*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 536*80a6f5c5SLiu Zhe scInputBarInput.activate(); 537*80a6f5c5SLiu Zhe typeKeys("13"); 538*80a6f5c5SLiu Zhe typeKeys("<enter>"); 539*80a6f5c5SLiu Zhe assertEquals("OpenOffice.org Calc", ActiveMsgBox.getCaption()); 540*80a6f5c5SLiu Zhe // assertEquals("Invalid value.",ActiveMsgBox.getMessage()); // Can not 541*80a6f5c5SLiu Zhe // verify in multi-language 542*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 543*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A1")); 544*80a6f5c5SLiu Zhe } 545*80a6f5c5SLiu Zhe 546*80a6f5c5SLiu Zhe /** 547*80a6f5c5SLiu Zhe * test uncheck Error Alert in Validity. 548*80a6f5c5SLiu Zhe */ 549*80a6f5c5SLiu Zhe @Test 550*80a6f5c5SLiu Zhe public void testUncheckErrorAlert() { 551*80a6f5c5SLiu Zhe 552*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 553*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(2); // "Decimal" 554*80a6f5c5SLiu Zhe scValidityDecimalCompareOperator.select(0); // "equal" 555*80a6f5c5SLiu Zhe scValiditySourceInput.setText("1"); 556*80a6f5c5SLiu Zhe 557*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 558*80a6f5c5SLiu Zhe scValidityShowErrorMessage.uncheck(); 559*80a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(0); // "Stop" 560*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 561*80a6f5c5SLiu Zhe 562*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 563*80a6f5c5SLiu Zhe typeKeys("13"); 564*80a6f5c5SLiu Zhe typeKeys("<enter>"); 565*80a6f5c5SLiu Zhe assertEquals("13", SCTool.getCellText("A1")); 566*80a6f5c5SLiu Zhe } 567*80a6f5c5SLiu Zhe 568*80a6f5c5SLiu Zhe /** 569*80a6f5c5SLiu Zhe * test Cell range source picker in Validity. Input from Edit Box. 570*80a6f5c5SLiu Zhe */ 571*80a6f5c5SLiu Zhe @Test 572*80a6f5c5SLiu Zhe public void testValidityCellRangeSourcePicker() { 573*80a6f5c5SLiu Zhe 574*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 575*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(5); // "Cell range" 576*80a6f5c5SLiu Zhe scValiditySourcePicker.click(); 577*80a6f5c5SLiu Zhe assertEquals(false, scValidityCriteriaAllowList.exists()); 578*80a6f5c5SLiu Zhe scValiditySourceInput.setText("$E$2:$G$5"); 579*80a6f5c5SLiu Zhe scValiditySourcePicker.click(); 580*80a6f5c5SLiu Zhe assertEquals(true, scValidityCriteriaAllowList.exists()); 581*80a6f5c5SLiu Zhe 582*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.select(); 583*80a6f5c5SLiu Zhe scValidityShowErrorMessage.check(); 584*80a6f5c5SLiu Zhe scValidityErrorAlertActionList.select(0); // "Stop" 585*80a6f5c5SLiu Zhe scValidityErrorMessageTitle.setText("Stop to enter"); 586*80a6f5c5SLiu Zhe scValidityErrorMessage.setText("Invalid value."); 587*80a6f5c5SLiu Zhe scValidityErrorAlertTabPage.ok(); 588*80a6f5c5SLiu Zhe 589*80a6f5c5SLiu Zhe // calc.focus(); 590*80a6f5c5SLiu Zhe SCTool.selectRange("E2"); 591*80a6f5c5SLiu Zhe scInputBarInput.activate(); 592*80a6f5c5SLiu Zhe typeKeys("test"); 593*80a6f5c5SLiu Zhe typeKeys("<enter>"); 594*80a6f5c5SLiu Zhe 595*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 596*80a6f5c5SLiu Zhe scInputBarInput.activate(); 597*80a6f5c5SLiu Zhe typeKeys("test32"); 598*80a6f5c5SLiu Zhe typeKeys("<enter>"); 599*80a6f5c5SLiu Zhe assertEquals("Invalid value.", ActiveMsgBox.getMessage()); 600*80a6f5c5SLiu Zhe ActiveMsgBox.ok(); 601*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("A1")); 602*80a6f5c5SLiu Zhe 603*80a6f5c5SLiu Zhe SCTool.selectRange("B1"); 604*80a6f5c5SLiu Zhe scInputBarInput.activate(); 605*80a6f5c5SLiu Zhe typeKeys("test"); 606*80a6f5c5SLiu Zhe typeKeys("<enter>"); 607*80a6f5c5SLiu Zhe assertEquals("test", SCTool.getCellText("B1")); 608*80a6f5c5SLiu Zhe } 609*80a6f5c5SLiu Zhe 610*80a6f5c5SLiu Zhe /** 611*80a6f5c5SLiu Zhe * test Allow Blank cell Checkbox in Validity. 612*80a6f5c5SLiu Zhe */ 613*80a6f5c5SLiu Zhe @Test 614*80a6f5c5SLiu Zhe public void testAllowBlankCells() { 615*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 616*80a6f5c5SLiu Zhe scValidityCriteriaAllowList.select(5); // "Cell range" 617*80a6f5c5SLiu Zhe scValiditySourceInput.setText("$E$1:$E$5"); 618*80a6f5c5SLiu Zhe scValidityAllowBlankCells.check(); 619*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.ok(); 620*80a6f5c5SLiu Zhe 621*80a6f5c5SLiu Zhe SCTool.selectRange("E1"); 622*80a6f5c5SLiu Zhe typeKeys("A<enter>A<enter>A<enter>A<enter>A<enter>"); 623*80a6f5c5SLiu Zhe 624*80a6f5c5SLiu Zhe SCTool.selectRange("A1"); 625*80a6f5c5SLiu Zhe typeKeys("A<enter>"); 626*80a6f5c5SLiu Zhe SCTool.selectRange("D1"); 627*80a6f5c5SLiu Zhe scInputBarInput.activate(); 628*80a6f5c5SLiu Zhe typeKeys("<backspace><enter>"); 629*80a6f5c5SLiu Zhe assertEquals("", SCTool.getCellText("D1")); 630*80a6f5c5SLiu Zhe 631*80a6f5c5SLiu Zhe SCTool.selectRange("B1"); 632*80a6f5c5SLiu Zhe app.dispatch(".uno:Validation"); 633*80a6f5c5SLiu Zhe scValidityCriteriaTabpage.select(); 634*80a6f5c5SLiu Zhe scValidityAllowBlankCells.uncheck(); 635*80a6f5c5SLiu Zhe typeKeys("<enter>"); 636*80a6f5c5SLiu Zhe 637*80a6f5c5SLiu Zhe SCTool.selectRange("B1"); 638*80a6f5c5SLiu Zhe scInputBarInput.activate(); 639*80a6f5c5SLiu Zhe typeKeys("<backspace><enter>"); 640*80a6f5c5SLiu Zhe typeKeys("<enter>"); 641*80a6f5c5SLiu Zhe } 642*80a6f5c5SLiu Zhe } 643