1 /************************************************************************
2  *
3  * Licensed Materials - Property of IBM.
4  * (C) Copyright IBM Corporation 2003, 2012.  All Rights Reserved.
5  * U.S. Government Users Restricted Rights:
6  * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
7  *
8  ************************************************************************/
9 
10 package testcase.sc.validity;
11 
12 import static testlib.AppUtil.*;
13 import static testlib.UIMap.*;
14 
15 import java.io.File;
16 
17 import org.junit.After;
18 import static org.junit.Assert.*;
19 import static org.openoffice.test.vcl.Tester.*;
20 
21 import org.junit.Before;
22 import org.junit.Rule;
23 import org.junit.Test;
24 import org.openoffice.test.vcl.IDList;
25 import org.openoffice.test.vcl.widgets.VclMessageBox;
26 
27 
28 import testlib.CalcUtil;
29 import testlib.Log;
30 
31 
32 public class ValidityDateSupport1024Columns {
33 	private static IDList idList = new IDList(new File("./ids"));
34 	public static final VclMessageBox ActiveMsgBox = new VclMessageBox(idList.getId("UID_ACTIVE"), "Message on message box.");
35 
36 	/**
37 	 * TestCapture helps us to do
38 	 * 1. Take a screenshot when failure occurs.
39 	 * 2. Collect extra data when OpenOffice crashes.
40 	 */
41 	@Rule
42 	public Log LOG = new Log();
43 
44 	/**
45 	 * initApp helps us to do
46 	 * 1. Patch the OpenOffice to enable automation if necessary.
47 	 * 2. Start OpenOffice with automation enabled if necessary.
48 	 * 3. Reset OpenOffice to startcenter.
49 	 *
50 	 * @throws java.lang.Exception
51 	 */
52 	@Before
53 	public void setUp() throws Exception {
54 		initApp();
55 	}
56 
57 	/**
58 	 * test Allow Greater than or equal to Date type in Validity, support 1024 columns.
59 	 */
60 	@Test
61 	public void testValidityDateSupport1024Columns() {
62 		startcenter.menuItem("File->New->Spreadsheet").select();
63 		sleep(1);
64 
65 		CalcUtil.selectRange("Sheet1.ALM1000");
66 		CalcUtil.selectRange("Sheet1.ALM1000:Sheet1.ALO1005");
67 
68 		calc.menuItem("Data->Validity...").select();
69 		sleep(1);
70 
71 		SC_ValidityCriteriaTabpage.select();
72 		SC_ValidityCriteriaAllowList.select("Date");
73 		SC_ValidityDecimalCompareOperator.select("greater than");
74 		SC_ValiditySourceInput.setText("01/01/08");
75 		SC_ValidityErrorAlertTabPage.select();
76 		SC_ValidityShowErrorMessage.check();
77 		SC_ValidityErrorMessageTitle.setText("Stop to enter");
78 		SC_ValidityErrorMessage.setText("Invalid value");
79 		typeKeys("<tab>");
80 		typeKeys("<enter>");
81 		sleep(1);
82 
83 		CalcUtil.selectRange("Sheet1.ALM1001");
84 		SC_CellInput.activate();
85 		typeKeys("02/01/08");
86 		typeKeys("<enter>");
87 		assertEquals("02/01/08",CalcUtil.getCellText("Sheet1.ALM1001"));
88 
89 		CalcUtil.selectRange("Sheet1.ALM1002");
90 		SC_CellInput.activate();
91 		typeKeys("01/02/08");
92 		typeKeys("<enter>");
93 		assertEquals("01/02/08",CalcUtil.getCellText("Sheet1.ALM1002"));
94 
95 		CalcUtil.selectRange("Sheet1.ALM1003");
96 		SC_CellInput.activate();
97 		typeKeys("01/01/08");
98 		typeKeys("<enter>");
99 		assertEquals("Invalid value",ActiveMsgBox.getMessage());
100 		ActiveMsgBox.ok();
101 		assertEquals("",CalcUtil.getCellText("Sheet1.ALM1003"));
102 
103 		CalcUtil.selectRange("Sheet1.AML1003");
104 		SC_CellInput.activate();
105 		typeKeys("12/31/07");
106 		typeKeys("<enter>");
107 		assertEquals("Invalid value",ActiveMsgBox.getMessage());
108 		ActiveMsgBox.ok();
109 		assertEquals("",CalcUtil.getCellText("Sheet1.AML1003"));
110 
111 		}
112 
113 }
114 
115