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 package fvt.gui.sc.validity;
23 
24 import static org.junit.Assert.*;
25 import static org.openoffice.test.common.Testspace.*;
26 import static testlib.gui.AppTool.*;
27 import static testlib.gui.UIMap.*;
28 
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Rule;
32 import org.junit.Test;
33 import org.openoffice.test.common.Logger;
34 
35 import testlib.gui.SCTool;
36 
37 public class ValiditySampleFile {
38 
39 	@Rule
40 	public Logger log = Logger.getLogger(this);
41 
42 	@Before
43 	public void setUp() throws Exception {
44 		app.start(true);
45 	}
46 
47 	@After
48 	public void tearDown() throws Exception {
49 
50 	}
51 
52 	/**
53 	 * Test open MS 2003 spreadsheet with ignore blank validity.
54 	 *
55 	 * @throws Exception
56 	 */
57 	@Test
58 	public void testFFCIgnoreBlank() throws Exception {
59 		// Open sample file
60 		String file = prepareData("sc/FFC252FFCSC_XML_Datarange0235.xls");
61 		app.dispatch(".uno:Open", 3);
62 		submitOpenDlg(file);
63 		calc.waitForExistence(10, 2);
64 
65 		SCTool.selectRange("D5");
66 		scInputBarInput.activate();
67 		for (int i = 1; i <= 10; i++)
68 			typeKeys("<backspace>");
69 		typeKeys("<enter>");
70 
71 		assertEquals("", SCTool.getCellText("D5"));
72 	}
73 
74 	/**
75 	 * Test open MS 2003 spreadsheet with ignore blank validity.
76 	 *
77 	 * @throws Exception
78 	 */
79 	@Test
80 	public void testFFCNotIgnoreBlank() throws Exception {
81 		// open sample file
82 		String file = prepareData("sc/FFC252FFCSC_XML_Datarange0205.xls");
83 		app.dispatch(".uno:Open", 3);
84 		submitOpenDlg(file);
85 		calc.waitForExistence(10, 2);
86 
87 		SCTool.selectRange("F5");
88 		scInputBarInput.activate();
89 		typeKeys("<backspace><enter>");
90 
91 		activeMsgBox.ok();
92 		assertEquals("8", SCTool.getCellText("F5"));
93 	}
94 
95 	/**
96 	 * test Cell is not locked after switch from validity cell to source cells
97 	 */
98 	@Test
99 	public void testNotLockCellFromValidityCell() {
100 		// open sample file on data path
101 		String file = prepareData("sc/sampledata.ods");
102 		app.dispatch(".uno:Open", 3);
103 		submitOpenDlg(file);
104 		calc.waitForExistence(10, 2);
105 
106 		SCTool.selectRange("F19");
107 		typeKeys("d<enter>");
108 		SCTool.selectRange("F17");
109 		typeKeys("Test<enter>");
110 
111 		assertEquals("Test", SCTool.getCellText("F17"));
112 	}
113 }
114