1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package testcase.sc.validity; 25 26 import static testlib.AppUtil.submitOpenDlg; 27 import static testlib.AppUtil.testFile; 28 import static testlib.AppUtil.typeKeys; 29 import static testlib.UIMap.*; 30 import static org.junit.Assert.*; 31 import static org.openoffice.test.vcl.Tester.typeKeys; 32 import org.junit.After; 33 import org.junit.Before; 34 import org.junit.Rule; 35 import org.junit.Test; 36 import testlib.CalcUtil; 37 import testlib.Log; 38 39 public class ValiditySampleFile { 40 41 @Rule 42 public Log LOG = new Log(); 43 44 @Before 45 public void setUp() throws Exception { 46 app.start(); 47 } 48 49 @After 50 public void tearDown() throws Exception { 51 app.close(); 52 } 53 54 /** 55 * Test open MS 2003 spreadsheet with ignore blank validity. 56 * 57 * @throws Exception 58 */ 59 @Test 60 public void testFFCIgnoreBlank() throws Exception{ 61 // Open sample file 62 String file = testFile("sc/FFC252FFCSC_XML_Datarange0235.xls"); 63 app.dispatch(".uno:Open", 3); 64 submitOpenDlg(file); 65 calc.waitForExistence(10, 2); 66 67 CalcUtil.selectRange("D5"); 68 SC_InputBar_Input.activate(); 69 for(int i=1;i<=10;i++) 70 typeKeys("<backspace>"); 71 typeKeys("<enter>"); 72 73 assertEquals("",CalcUtil.getCellText("D5")); 74 } 75 76 /** 77 * Test open MS 2003 spreadsheet with ignore blank validity. 78 * 79 * @throws Exception 80 */ 81 @Test 82 public void testFFCNotIgnoreBlank() throws Exception{ 83 //open sample file 84 String file = testFile("sc/FFC252FFCSC_XML_Datarange0205.xls"); 85 app.dispatch(".uno:Open", 3); 86 submitOpenDlg(file); 87 calc.waitForExistence(10, 2); 88 89 CalcUtil.selectRange("F5"); 90 SC_InputBar_Input.activate(); 91 typeKeys("<backspace><enter>"); 92 93 assertEquals("Invalid value.",ActiveMsgBox.getMessage()); 94 ActiveMsgBox.ok(); 95 assertEquals("8",CalcUtil.getCellText("F5")); 96 } 97 98 /** 99 * test Cell is not locked after switch from validity cell to source cells 100 */ 101 @Test 102 public void testNotLockCellFromValidityCell() { 103 //open sample file on data path 104 String file = testFile("sc/sampledata.ods"); 105 app.dispatch(".uno:Open", 3); 106 submitOpenDlg(file); 107 calc.waitForExistence(10, 2); 108 109 CalcUtil.selectRange("Sheet1.F19"); 110 typeKeys("d<enter>"); 111 CalcUtil.selectRange("Sheet1.F17"); 112 typeKeys("Test<enter>"); 113 114 assertEquals("Test",CalcUtil.getCellText("F17")); 115 } 116 } 117