104bad30fSLiu Zhe /**************************************************************
204bad30fSLiu Zhe  *
304bad30fSLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
404bad30fSLiu Zhe  * or more contributor license agreements.  See the NOTICE file
504bad30fSLiu Zhe  * distributed with this work for additional information
604bad30fSLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
704bad30fSLiu Zhe  * to you under the Apache License, Version 2.0 (the
804bad30fSLiu Zhe  * "License"); you may not use this file except in compliance
904bad30fSLiu Zhe  * with the License.  You may obtain a copy of the License at
1004bad30fSLiu Zhe  *
1104bad30fSLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1204bad30fSLiu Zhe  *
1304bad30fSLiu Zhe  * Unless required by applicable law or agreed to in writing,
1404bad30fSLiu Zhe  * software distributed under the License is distributed on an
1504bad30fSLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1604bad30fSLiu Zhe  * KIND, either express or implied.  See the License for the
1704bad30fSLiu Zhe  * specific language governing permissions and limitations
1804bad30fSLiu Zhe  * under the License.
1904bad30fSLiu Zhe  *
2004bad30fSLiu Zhe  *************************************************************/
2104bad30fSLiu Zhe 
2280a6f5c5SLiu Zhe package fvt.gui.sc.validity;
2304bad30fSLiu Zhe 
2404bad30fSLiu Zhe import static org.junit.Assert.*;
2595269d92SLiu Zhe import static org.openoffice.test.common.Testspace.*;
26b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
2722a14f28SLiu Zhe import static testlib.gui.UIMap.*;
2822a14f28SLiu Zhe 
2904bad30fSLiu Zhe import org.junit.After;
3004bad30fSLiu Zhe import org.junit.Before;
3104bad30fSLiu Zhe import org.junit.Rule;
3204bad30fSLiu Zhe import org.junit.Test;
3322a14f28SLiu Zhe import org.openoffice.test.common.Logger;
3495269d92SLiu Zhe 
35b4d2d410SLiu Zhe import testlib.gui.SCTool;
3604bad30fSLiu Zhe 
3704bad30fSLiu Zhe public class ValiditySampleFile {
3804bad30fSLiu Zhe 
3904bad30fSLiu Zhe 	@Before
4004bad30fSLiu Zhe 	public void setUp() throws Exception {
414d3496b1SLiu Zhe 		app.start(true);
4204bad30fSLiu Zhe 	}
4304bad30fSLiu Zhe 
4404bad30fSLiu Zhe 	@After
4504bad30fSLiu Zhe 	public void tearDown() throws Exception {
46*424494b0SLi Feng Wang 		app.stop();
4722a14f28SLiu Zhe 
4804bad30fSLiu Zhe 	}
4904bad30fSLiu Zhe 
5004bad30fSLiu Zhe 	/**
5104bad30fSLiu Zhe 	 * Test open MS 2003 spreadsheet with ignore blank validity.
5204bad30fSLiu Zhe 	 *
5304bad30fSLiu Zhe 	 * @throws Exception
5404bad30fSLiu Zhe 	 */
5504bad30fSLiu Zhe 	@Test
5622a14f28SLiu Zhe 	public void testFFCIgnoreBlank() throws Exception {
5704bad30fSLiu Zhe 		// Open sample file
5895269d92SLiu Zhe 		String file = prepareData("sc/FFC252FFCSC_XML_Datarange0235.xls");
59*424494b0SLi Feng Wang 		open(file);
6004bad30fSLiu Zhe 		calc.waitForExistence(10, 2);
6104bad30fSLiu Zhe 
62b4d2d410SLiu Zhe 		SCTool.selectRange("D5");
63b4d2d410SLiu Zhe 		scInputBarInput.activate();
6422a14f28SLiu Zhe 		for (int i = 1; i <= 10; i++)
6504bad30fSLiu Zhe 			typeKeys("<backspace>");
6604bad30fSLiu Zhe 		typeKeys("<enter>");
6704bad30fSLiu Zhe 
68b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("D5"));
6904bad30fSLiu Zhe 	}
7004bad30fSLiu Zhe 
7104bad30fSLiu Zhe 	/**
7204bad30fSLiu Zhe 	 * Test open MS 2003 spreadsheet with ignore blank validity.
7304bad30fSLiu Zhe 	 *
7404bad30fSLiu Zhe 	 * @throws Exception
7504bad30fSLiu Zhe 	 */
7604bad30fSLiu Zhe 	@Test
7722a14f28SLiu Zhe 	public void testFFCNotIgnoreBlank() throws Exception {
7822a14f28SLiu Zhe 		// open sample file
7995269d92SLiu Zhe 		String file = prepareData("sc/FFC252FFCSC_XML_Datarange0205.xls");
80*424494b0SLi Feng Wang 		open(file);
8104bad30fSLiu Zhe 		calc.waitForExistence(10, 2);
8204bad30fSLiu Zhe 
83b4d2d410SLiu Zhe 		SCTool.selectRange("F5");
84b4d2d410SLiu Zhe 		scInputBarInput.activate();
8504bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
8604bad30fSLiu Zhe 
87b4d2d410SLiu Zhe 		activeMsgBox.ok();
88b4d2d410SLiu Zhe 		assertEquals("8", SCTool.getCellText("F5"));
8904bad30fSLiu Zhe 	}
9004bad30fSLiu Zhe 
9104bad30fSLiu Zhe 	/**
9204bad30fSLiu Zhe 	 * test Cell is not locked after switch from validity cell to source cells
9304bad30fSLiu Zhe 	 */
9404bad30fSLiu Zhe 	@Test
9504bad30fSLiu Zhe 	public void testNotLockCellFromValidityCell() {
9622a14f28SLiu Zhe 		// open sample file on data path
9795269d92SLiu Zhe 		String file = prepareData("sc/sampledata.ods");
98*424494b0SLi Feng Wang 		open(file);
9904bad30fSLiu Zhe 		calc.waitForExistence(10, 2);
10004bad30fSLiu Zhe 
101b4d2d410SLiu Zhe 		SCTool.selectRange("F19");
10204bad30fSLiu Zhe 		typeKeys("d<enter>");
103b4d2d410SLiu Zhe 		SCTool.selectRange("F17");
10404bad30fSLiu Zhe 		typeKeys("Test<enter>");
10504bad30fSLiu Zhe 
106b4d2d410SLiu Zhe 		assertEquals("Test", SCTool.getCellText("F17"));
10704bad30fSLiu Zhe 	}
10804bad30fSLiu Zhe }
109