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 
39*fd348426SLi Feng Wang 	@Rule
40*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
41*fd348426SLi Feng Wang 
4204bad30fSLiu Zhe 	@Before
setUp()4304bad30fSLiu Zhe 	public void setUp() throws Exception {
444d3496b1SLiu Zhe 		app.start(true);
4504bad30fSLiu Zhe 	}
4604bad30fSLiu Zhe 
4704bad30fSLiu Zhe 	@After
tearDown()4804bad30fSLiu Zhe 	public void tearDown() throws Exception {
49424494b0SLi Feng Wang 		app.stop();
5022a14f28SLiu Zhe 
5104bad30fSLiu Zhe 	}
5204bad30fSLiu Zhe 
5304bad30fSLiu Zhe 	/**
5404bad30fSLiu Zhe 	 * Test open MS 2003 spreadsheet with ignore blank validity.
5504bad30fSLiu Zhe 	 *
5604bad30fSLiu Zhe 	 * @throws Exception
5704bad30fSLiu Zhe 	 */
5804bad30fSLiu Zhe 	@Test
testFFCIgnoreBlank()5922a14f28SLiu Zhe 	public void testFFCIgnoreBlank() throws Exception {
6004bad30fSLiu Zhe 		// Open sample file
6195269d92SLiu Zhe 		String file = prepareData("sc/FFC252FFCSC_XML_Datarange0235.xls");
62424494b0SLi Feng Wang 		open(file);
6304bad30fSLiu Zhe 		calc.waitForExistence(10, 2);
6404bad30fSLiu Zhe 
65b4d2d410SLiu Zhe 		SCTool.selectRange("D5");
66b4d2d410SLiu Zhe 		scInputBarInput.activate();
6722a14f28SLiu Zhe 		for (int i = 1; i <= 10; i++)
6804bad30fSLiu Zhe 			typeKeys("<backspace>");
6904bad30fSLiu Zhe 		typeKeys("<enter>");
7004bad30fSLiu Zhe 
71b4d2d410SLiu Zhe 		assertEquals("", SCTool.getCellText("D5"));
7204bad30fSLiu Zhe 	}
7304bad30fSLiu Zhe 
7404bad30fSLiu Zhe 	/**
7504bad30fSLiu Zhe 	 * Test open MS 2003 spreadsheet with ignore blank validity.
7604bad30fSLiu Zhe 	 *
7704bad30fSLiu Zhe 	 * @throws Exception
7804bad30fSLiu Zhe 	 */
7904bad30fSLiu Zhe 	@Test
testFFCNotIgnoreBlank()8022a14f28SLiu Zhe 	public void testFFCNotIgnoreBlank() throws Exception {
8122a14f28SLiu Zhe 		// open sample file
8295269d92SLiu Zhe 		String file = prepareData("sc/FFC252FFCSC_XML_Datarange0205.xls");
83424494b0SLi Feng Wang 		open(file);
8404bad30fSLiu Zhe 		calc.waitForExistence(10, 2);
8504bad30fSLiu Zhe 
86b4d2d410SLiu Zhe 		SCTool.selectRange("F5");
87b4d2d410SLiu Zhe 		scInputBarInput.activate();
8804bad30fSLiu Zhe 		typeKeys("<backspace><enter>");
8904bad30fSLiu Zhe 
90b4d2d410SLiu Zhe 		activeMsgBox.ok();
91b4d2d410SLiu Zhe 		assertEquals("8", SCTool.getCellText("F5"));
9204bad30fSLiu Zhe 	}
9304bad30fSLiu Zhe 
9404bad30fSLiu Zhe 	/**
9504bad30fSLiu Zhe 	 * test Cell is not locked after switch from validity cell to source cells
9604bad30fSLiu Zhe 	 */
9704bad30fSLiu Zhe 	@Test
testNotLockCellFromValidityCell()9804bad30fSLiu Zhe 	public void testNotLockCellFromValidityCell() {
9922a14f28SLiu Zhe 		// open sample file on data path
10095269d92SLiu Zhe 		String file = prepareData("sc/sampledata.ods");
101424494b0SLi Feng Wang 		open(file);
10204bad30fSLiu Zhe 		calc.waitForExistence(10, 2);
10304bad30fSLiu Zhe 
104b4d2d410SLiu Zhe 		SCTool.selectRange("F19");
10504bad30fSLiu Zhe 		typeKeys("d<enter>");
106b4d2d410SLiu Zhe 		SCTool.selectRange("F17");
10704bad30fSLiu Zhe 		typeKeys("Test<enter>");
10804bad30fSLiu Zhe 
109b4d2d410SLiu Zhe 		assertEquals("Test", SCTool.getCellText("F17"));
11004bad30fSLiu Zhe 	}
11104bad30fSLiu Zhe }
112