View | Details | Raw Unified | Return to issue 120603
Collapse All | Expand All

(-)testuno/.externalToolBuilders/Classpath Builder.launch (-16 / +22 lines)
Lines 1-16 Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
2
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
3
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
3
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
4
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
4
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
5
<booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/>
5
<booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/>
6
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
6
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
7
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
7
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
8
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
8
<listEntry value="/testuno"/>
9
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
9
</listAttribute>
10
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
10
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
11
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
11
<listEntry value="4"/>
12
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="testuno"/>
12
</listAttribute>
13
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/testuno/builder.xml}"/>
13
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
14
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/>
14
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
15
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
15
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
16
</launchConfiguration>
16
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
17
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
18
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="testuno"/>
19
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/testuno/builder.xml}"/>
20
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/>
21
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
22
</launchConfiguration>
(-)testuno/source/testcase/uno/sw/field/CheckDateTimeField.java (-83 / +61 lines)
Lines 30-35 Link Here
30
import org.junit.Before;
30
import org.junit.Before;
31
import org.junit.BeforeClass;
31
import org.junit.BeforeClass;
32
import org.junit.Test;
32
import org.junit.Test;
33
import org.openoffice.test.common.FileUtil;
33
import org.openoffice.test.common.Testspace;
34
import org.openoffice.test.common.Testspace;
34
import org.openoffice.test.uno.UnoApp;
35
import org.openoffice.test.uno.UnoApp;
35
36
Lines 66-72 Link Here
66
	@After
67
	@After
67
	public void tearDownDocument() {
68
	public void tearDownDocument() {
68
	     app.closeDocument(document);
69
	     app.closeDocument(document);
69
		// FileUtil.deleteFile(Testspace.getFile(tempPath));
70
		 FileUtil.deleteFile(Testspace.getFile(tempPath));
70
	}
71
	}
71
72
72
73
Lines 89-98 Link Here
89
	 * 2.Verify the Time is created by check the date hour in the new document
90
	 * 2.Verify the Time is created by check the date hour in the new document
90
	 * 3.Save and close the new document to doc format
91
	 * 3.Save and close the new document to doc format
91
	 * 4.Reload the new save doc file, check the  time field
92
	 * 4.Reload the new save doc file, check the  time field
93
	 * @throws Exception 
92
	 */
94
	 */
93
95
94
	@Test
96
	@Test
95
	public void testCreateTimeFieldSaveDoc() {
97
	public void testCreateTimeFieldSaveDoc() throws Exception {
96
		
98
		
97
		String url = Testspace.getUrl(tempPath + tempFileName + ".doc");
99
		String url = Testspace.getUrl(tempPath + tempFileName + ".doc");
98
		PropertyValue[] propsValue = new PropertyValue[1];
100
		PropertyValue[] propsValue = new PropertyValue[1];
Lines 108-116 Link Here
108
	 * 2.Verify the Time Field is created by check the date hour in the new document
110
	 * 2.Verify the Time Field is created by check the date hour in the new document
109
	 * 3.Save and close the new document to doc format
111
	 * 3.Save and close the new document to doc format
110
	 * 4.Reload the new save odt file, check the Time Field
112
	 * 4.Reload the new save odt file, check the Time Field
113
	 * @throws Exception 
111
	 */
114
	 */
112
	@Test
115
	@Test
113
	public void testCreateTimeFieldSaveODT() {
116
	public void testCreateTimeFieldSaveODT() throws Exception {
114
		
117
		
115
		String url = Testspace.getUrl(tempPath + tempFileName + ".odt");
118
		String url = Testspace.getUrl(tempPath + tempFileName + ".odt");
116
		PropertyValue[] propsValue = new PropertyValue[0];
119
		PropertyValue[] propsValue = new PropertyValue[0];
Lines 118-168 Link Here
118
		
121
		
119
	}
122
	}
120
	
123
	
121
	private void createTimeFiled(XTextDocument document, String url, PropertyValue[] propsValue) {
124
	private void createTimeFiled(XTextDocument document, String url, PropertyValue[] propsValue) throws Exception {
122
		XMultiServiceFactory sevriceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
125
		XMultiServiceFactory sevriceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
123
		try {
126
		XTextField  dateFiled = (XTextField)UnoRuntime.queryInterface(XTextField.class, sevriceFactory.createInstance("com.sun.star.text.textfield.DateTime"));
124
			XTextField  dateFiled = (XTextField)UnoRuntime.queryInterface(XTextField.class, sevriceFactory.createInstance("com.sun.star.text.textfield.DateTime"));
125
			
126
		
127
		
127
			XPropertySet props = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, dateFiled);
128
			props.setPropertyValue("IsDate", false);
129
			
130
			document.getText().insertTextContent(document.getText().getEnd(), dateFiled, false);
131
			DateTime dateField = (DateTime) props.getPropertyValue("DateTimeValue");
132
		
128
		
133
			String dateString = document.getText().getString();
129
		XPropertySet props = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, dateFiled);
134
			assertTrue("Verify time field is creatd, by verify it's hour",  dateString.indexOf(String.valueOf(dateField.Hours).trim()) != -1);
130
		props.setPropertyValue("IsDate", false);
135
			assertTrue("Verify time field is creatd, by verify it's minutes",  dateString.indexOf(String.valueOf(dateField.Minutes).trim()) != -1);
131
		
136
			int expectHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
132
		document.getText().insertTextContent(document.getText().getEnd(), dateFiled, false);
137
			assertEquals("Verify time field is creatd, value is right, by compare Hour", expectHour, dateField.Hours);
133
		DateTime dateField = (DateTime) props.getPropertyValue("DateTimeValue");
138
			XStorable store = UnoRuntime.queryInterface(XStorable.class, document);
134
	
139
			store.storeAsURL(url, propsValue);
135
		String dateString = document.getText().getString();
140
			app.closeDocument(document);
136
		assertTrue("Verify time field is creatd, by verify it's hour",  dateString.indexOf(String.valueOf(dateField.Hours).trim()) != -1);
141
			
137
		assertTrue("Verify time field is creatd, by verify it's minutes",  dateString.indexOf(String.valueOf(dateField.Minutes).trim()) != -1);
142
			try {
138
		int expectHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
143
				document = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.loadDocumentFromURL(url));
139
		assertEquals("Verify time field is creatd, value is right, by compare Hour", expectHour, dateField.Hours);
144
				XTextFieldsSupplier fieldsSupplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class, document);
140
		XStorable store = UnoRuntime.queryInterface(XStorable.class, document);
145
				XEnumerationAccess xEnumeratedFields = fieldsSupplier.getTextFields();
141
		store.storeAsURL(url, propsValue);
146
				XEnumeration enumeration = xEnumeratedFields.createEnumeration();
142
		app.closeDocument(document);
147
				while (enumeration.hasMoreElements()) {
143
		document = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.loadDocumentFromURL(url));
148
					  Object field =  enumeration.nextElement();
144
		XTextFieldsSupplier fieldsSupplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class, document);
149
						XPropertySet props2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, field);
145
		XEnumerationAccess xEnumeratedFields = fieldsSupplier.getTextFields();
150
						DateTime dateField2 = (DateTime) props2.getPropertyValue("DateTimeValue");
146
		XEnumeration enumeration = xEnumeratedFields.createEnumeration();
151
						assertEquals("Verify time field is creatd correct by save and reload.", expectHour, dateField2.Hours);
147
		while (enumeration.hasMoreElements()) {
152
				}
148
			  Object field =  enumeration.nextElement();
153
				
149
				XPropertySet props2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, field);
154
				
150
				DateTime dateField2 = (DateTime) props2.getPropertyValue("DateTimeValue");
155
			} catch (Exception e) {
151
				assertEquals("Verify time field is creatd correct by save and reload.", expectHour, dateField2.Hours);
156
				e.printStackTrace();
157
			}
158
			
159
			
160
			
161
			
162
		} catch (com.sun.star.uno.Exception e) {
163
			e.printStackTrace();
164
		}
152
		}
165
		
153
		
154
		
166
	}
155
	}
167
	/**
156
	/**
168
	 * Test Date Field can be created correctly.
157
	 * Test Date Field can be created correctly.
Lines 170-179 Link Here
170
	 * 2.Verify the Date is created by check the date hour in the new document
159
	 * 2.Verify the Date is created by check the date hour in the new document
171
	 * 3.Save and close the new document to doc format
160
	 * 3.Save and close the new document to doc format
172
	 * 4.Reload the new save doc file, check the  Date field
161
	 * 4.Reload the new save doc file, check the  Date field
162
	 * @throws Exception 
173
	 */
163
	 */
174
164
175
	@Test
165
	@Test
176
	public void testCreateDateFieldSaveDoc() {
166
	public void testCreateDateFieldSaveDoc() throws Exception {
177
		
167
		
178
		String url = Testspace.getUrl(tempPath + tempFileName + ".doc");
168
		String url = Testspace.getUrl(tempPath + tempFileName + ".doc");
179
		PropertyValue[] propsValue = new PropertyValue[1];
169
		PropertyValue[] propsValue = new PropertyValue[1];
Lines 189-244 Link Here
189
	 * 2.Verify the dateField is created by check the date hour in the new document
179
	 * 2.Verify the dateField is created by check the date hour in the new document
190
	 * 3.Save and close the new document to doc format
180
	 * 3.Save and close the new document to doc format
191
	 * 4.Reload the new save odt file, check the date  field
181
	 * 4.Reload the new save odt file, check the date  field
182
	 * @throws Exception 
192
	 */
183
	 */
193
	@Test
184
	@Test
194
	public void testCreateDateFieldSaveODT() {
185
	public void testCreateDateFieldSaveODT() throws Exception {
195
		
186
		
196
		String url = Testspace.getUrl(tempPath + tempFileName + ".odt");
187
		String url = Testspace.getUrl(tempPath + tempFileName + ".odt");
197
		PropertyValue[] propsValue = new PropertyValue[0];
188
		PropertyValue[] propsValue = new PropertyValue[0];
198
		createDateFiled(document, url, propsValue);
189
		createDateFiled(document, url, propsValue);
199
		
190
		
200
	}
191
	}
201
	private void createDateFiled(XTextDocument document, String url, PropertyValue[] propsValue) {
192
	private void createDateFiled(XTextDocument document, String url, PropertyValue[] propsValue) throws Exception {
202
		XMultiServiceFactory sevriceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
193
		XMultiServiceFactory sevriceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
203
		try {
194
		XTextField  dateFiled = (XTextField)UnoRuntime.queryInterface(XTextField.class, sevriceFactory.createInstance("com.sun.star.text.textfield.DateTime"));
204
			XTextField  dateFiled = (XTextField)UnoRuntime.queryInterface(XTextField.class, sevriceFactory.createInstance("com.sun.star.text.textfield.DateTime"));
205
			
206
		
195
		
207
			XPropertySet props = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, dateFiled);
208
			props.setPropertyValue("IsDate", true);
209
			
210
			document.getText().insertTextContent(document.getText().getEnd(), dateFiled, false);
211
			DateTime dateField = (DateTime) props.getPropertyValue("DateTimeValue");
212
		
196
		
213
			String dateString = document.getText().getString();
197
		XPropertySet props = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, dateFiled);
214
			assertTrue("Verify date field is creatd, by verify it's Month",  dateString.indexOf(String.valueOf(dateField.Month).trim()) != -1);
198
		props.setPropertyValue("IsDate", true);
215
			assertTrue("Verify date field is creatd, by verify it's Day",  dateString.indexOf(String.valueOf(dateField.Day).trim()) != -1);
199
		
216
			int expectDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
200
		document.getText().insertTextContent(document.getText().getEnd(), dateFiled, false);
217
			assertEquals("Verify date field is creatd, value is right, by compare Day", expectDay, dateField.Day);
201
		DateTime dateField = (DateTime) props.getPropertyValue("DateTimeValue");
218
			XStorable store = UnoRuntime.queryInterface(XStorable.class, document);
202
	
219
			store.storeAsURL(url, propsValue);
203
		String dateString = document.getText().getString();
220
			app.closeDocument(document);
204
		assertTrue("Verify date field is creatd, by verify it's Month",  dateString.indexOf(String.valueOf(dateField.Month).trim()) != -1);
221
			
205
		assertTrue("Verify date field is creatd, by verify it's Day",  dateString.indexOf(String.valueOf(dateField.Day).trim()) != -1);
222
			try {
206
		int expectDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
223
				document = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.loadDocumentFromURL(url));
207
		assertEquals("Verify date field is creatd, value is right, by compare Day", expectDay, dateField.Day);
224
				XTextFieldsSupplier fieldsSupplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class, document);
208
		XStorable store = UnoRuntime.queryInterface(XStorable.class, document);
225
				XEnumerationAccess xEnumeratedFields = fieldsSupplier.getTextFields();
209
		store.storeAsURL(url, propsValue);
226
				XEnumeration enumeration = xEnumeratedFields.createEnumeration();
210
		app.closeDocument(document);
227
				while (enumeration.hasMoreElements()) {
211
		document = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.loadDocumentFromURL(url));
228
					  Object field =  enumeration.nextElement();
212
		XTextFieldsSupplier fieldsSupplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class, document);
229
						XPropertySet props2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, field);
213
		XEnumerationAccess xEnumeratedFields = fieldsSupplier.getTextFields();
230
						DateTime dateField2 = (DateTime) props2.getPropertyValue("DateTimeValue");
214
		XEnumeration enumeration = xEnumeratedFields.createEnumeration();
231
						assertEquals("Verify date field is creatd correct by save and reload.", expectDay, dateField2.Day);
215
		while (enumeration.hasMoreElements()) {
232
				}
216
			  Object field =  enumeration.nextElement();
233
				
217
				XPropertySet props2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, field);
234
				
218
				DateTime dateField2 = (DateTime) props2.getPropertyValue("DateTimeValue");
235
			} catch (Exception e) {
219
				assertEquals("Verify date field is creatd correct by save and reload.", expectDay, dateField2.Day);
236
				e.printStackTrace();
237
			}
238
			
239
			
240
		} catch (com.sun.star.uno.Exception e) {
241
			e.printStackTrace();
242
		}
220
		}
243
		
221
		
244
	}
222
	}
(-)testuno/source/testlib/uno/sw/SWUtil.java (-15 / +8 lines)
Lines 11-45 Link Here
11
public class SWUtil {
11
public class SWUtil {
12
	
12
	
13
	private static final UnoApp app = new UnoApp();
13
	private static final UnoApp app = new UnoApp();
14
	public static void saveAsDoc(XTextDocument document, String url) {
14
	public static void saveAsDoc(XTextDocument document, String url) throws IOException {
15
		saveAs(document, "MS Word 97", url);
15
		saveAs(document, "MS Word 97", url);
16
		
16
		
17
	}
17
	}
18
18
19
	public static void saveAsODT(XTextDocument document, String url) {
19
	public static void saveAsODT(XTextDocument document, String url) throws IOException {
20
		saveAs(document, "writer8", url);
20
		saveAs(document, "writer8", url);
21
	}
21
	}
22
	
22
	
23
	public static void saveAs(XTextDocument document, String filterValue, String url) {
23
	public static void saveAs(XTextDocument document, String filterValue, String url) throws IOException {
24
		XStorable store = UnoRuntime.queryInterface(XStorable.class, document);
24
		XStorable store = UnoRuntime.queryInterface(XStorable.class, document);
25
		
25
		
26
		PropertyValue[] propsValue = new PropertyValue[1];
26
		PropertyValue[] propsValue = new PropertyValue[1];
27
		propsValue[0] = new PropertyValue();
27
		propsValue[0] = new PropertyValue();
28
		propsValue[0].Name = "FilterName";
28
		propsValue[0].Name = "FilterName";
29
		propsValue[0].Value = filterValue;
29
		propsValue[0].Value = filterValue;
30
		try {
30
		store.storeAsURL(url, propsValue);
31
			store.storeAsURL(url, propsValue);
31
		
32
		} catch (IOException e) {
33
			e.printStackTrace();
34
		}
35
	}
32
	}
36
	
33
	
37
	public static XTextDocument newDocument() {
34
	public static XTextDocument newDocument() throws Exception {
38
		try {
35
		return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
39
			return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
36
		
40
		} catch (Exception e) {
41
			e.printStackTrace();
42
		}
43
		return null;
44
	}
37
	}
45
}
38
}

Return to issue 120603