1323ac9c5SLi Feng Wang /**************************************************************
2323ac9c5SLi Feng Wang  *
3323ac9c5SLi Feng Wang  * Licensed to the Apache Software Foundation (ASF) under one
4323ac9c5SLi Feng Wang  * or more contributor license agreements.  See the NOTICE file
5323ac9c5SLi Feng Wang  * distributed with this work for additional information
6323ac9c5SLi Feng Wang  * regarding copyright ownership.  The ASF licenses this file
7323ac9c5SLi Feng Wang  * to you under the Apache License, Version 2.0 (the
8323ac9c5SLi Feng Wang  * "License"); you may not use this file except in compliance
9323ac9c5SLi Feng Wang  * with the License.  You may obtain a copy of the License at
10323ac9c5SLi Feng Wang  *
11323ac9c5SLi Feng Wang  *   http://www.apache.org/licenses/LICENSE-2.0
12323ac9c5SLi Feng Wang  *
13323ac9c5SLi Feng Wang  * Unless required by applicable law or agreed to in writing,
14323ac9c5SLi Feng Wang  * software distributed under the License is distributed on an
15323ac9c5SLi Feng Wang  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16323ac9c5SLi Feng Wang  * KIND, either express or implied.  See the License for the
17323ac9c5SLi Feng Wang  * specific language governing permissions and limitations
18323ac9c5SLi Feng Wang  * under the License.
19323ac9c5SLi Feng Wang  *
20323ac9c5SLi Feng Wang  *************************************************************/
21323ac9c5SLi Feng Wang /**
22323ac9c5SLi Feng Wang  *
23323ac9c5SLi Feng Wang  */
24323ac9c5SLi Feng Wang package fvt.uno.sd.file;
25323ac9c5SLi Feng Wang import static org.junit.Assert.*;
26323ac9c5SLi Feng Wang 
27323ac9c5SLi Feng Wang import org.junit.After;
28323ac9c5SLi Feng Wang import org.junit.AfterClass;
29323ac9c5SLi Feng Wang import org.junit.Before;
30323ac9c5SLi Feng Wang import org.junit.BeforeClass;
31323ac9c5SLi Feng Wang import org.junit.Test;
32323ac9c5SLi Feng Wang import org.openoffice.test.uno.UnoApp;
33323ac9c5SLi Feng Wang import org.openoffice.test.common.FileUtil;
34323ac9c5SLi Feng Wang import org.openoffice.test.common.Testspace;
35323ac9c5SLi Feng Wang 
36323ac9c5SLi Feng Wang import com.sun.star.beans.IllegalTypeException;
37323ac9c5SLi Feng Wang import com.sun.star.beans.Property;
38323ac9c5SLi Feng Wang import com.sun.star.beans.PropertyAttribute;
39323ac9c5SLi Feng Wang import com.sun.star.beans.PropertyExistException;
40323ac9c5SLi Feng Wang import com.sun.star.beans.PropertyValue;
41323ac9c5SLi Feng Wang import com.sun.star.beans.UnknownPropertyException;
42323ac9c5SLi Feng Wang import com.sun.star.beans.XPropertyContainer;
43323ac9c5SLi Feng Wang import com.sun.star.beans.XPropertySet;
44323ac9c5SLi Feng Wang import com.sun.star.beans.XPropertySetInfo;
45323ac9c5SLi Feng Wang import com.sun.star.container.XNameAccess;
46323ac9c5SLi Feng Wang import com.sun.star.document.XDocumentProperties;
47323ac9c5SLi Feng Wang import com.sun.star.document.XDocumentPropertiesSupplier;
48323ac9c5SLi Feng Wang import java.util.Calendar;
49323ac9c5SLi Feng Wang import com.sun.star.util.DateTime;
50323ac9c5SLi Feng Wang import com.sun.star.util.Date;
51323ac9c5SLi Feng Wang import com.sun.star.util.Duration;
52323ac9c5SLi Feng Wang import com.sun.star.lang.IllegalArgumentException;
53323ac9c5SLi Feng Wang import com.sun.star.lang.WrappedTargetException;
54323ac9c5SLi Feng Wang import com.sun.star.lang.XComponent;
55323ac9c5SLi Feng Wang import com.sun.star.lang.XMultiServiceFactory;
56323ac9c5SLi Feng Wang import com.sun.star.uno.UnoRuntime;
57323ac9c5SLi Feng Wang 
58323ac9c5SLi Feng Wang /**
59323ac9c5SLi Feng Wang  * @author LouQL
60323ac9c5SLi Feng Wang  *
61323ac9c5SLi Feng Wang  */
62323ac9c5SLi Feng Wang public class CheckFileProperties {
63323ac9c5SLi Feng Wang 
64323ac9c5SLi Feng Wang 	private static final UnoApp app = new UnoApp();
65323ac9c5SLi Feng Wang 
66323ac9c5SLi Feng Wang 	private XComponent m_xSDComponent = null;
67323ac9c5SLi Feng Wang 	private static String m_filePath = null;
68323ac9c5SLi Feng Wang 
69323ac9c5SLi Feng Wang 	@Before
70323ac9c5SLi Feng Wang 	public void setUpDocument() throws Exception {
71323ac9c5SLi Feng Wang 		if (FileUtil.fileExists(m_filePath)) {//load
72323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
73323ac9c5SLi Feng Wang 		} else {//new
74323ac9c5SLi Feng Wang 			m_xSDComponent = (XComponent) UnoRuntime.queryInterface(
75323ac9c5SLi Feng Wang 					XComponent.class, app.newDocument("simpress"));
76323ac9c5SLi Feng Wang 		}
77323ac9c5SLi Feng Wang 	}
78323ac9c5SLi Feng Wang 
79323ac9c5SLi Feng Wang 	private String getUserName() throws com.sun.star.uno.Exception
80323ac9c5SLi Feng Wang 	{
81323ac9c5SLi Feng Wang 		Object configurationProvider = app.getServiceFactory().
82323ac9c5SLi Feng Wang 				createInstance("com.sun.star.configuration.ConfigurationProvider");
83323ac9c5SLi Feng Wang 
84323ac9c5SLi Feng Wang 		XMultiServiceFactory msFac = (XMultiServiceFactory)UnoRuntime.queryInterface(
85323ac9c5SLi Feng Wang 				XMultiServiceFactory.class, configurationProvider);
86323ac9c5SLi Feng Wang 
87323ac9c5SLi Feng Wang 		PropertyValue[] propValue = new PropertyValue[1];
88323ac9c5SLi Feng Wang 		propValue[0] = new PropertyValue();
89323ac9c5SLi Feng Wang 		propValue[0].Name = "nodepath";
90323ac9c5SLi Feng Wang 		propValue[0].Value = "/org.openoffice.UserProfile/Data";
91323ac9c5SLi Feng Wang 
92323ac9c5SLi Feng Wang 		Object configurationAccess = msFac.createInstanceWithArguments(
93323ac9c5SLi Feng Wang 				"com.sun.star.configuration.ConfigurationAccess", propValue);
94323ac9c5SLi Feng Wang 		XNameAccess nameAcc = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, configurationAccess);
95323ac9c5SLi Feng Wang 		String givenname = (String)nameAcc.getByName("givenname");
96323ac9c5SLi Feng Wang 		String sn = (String)nameAcc.getByName("sn");
97323ac9c5SLi Feng Wang 		String name = null;
98323ac9c5SLi Feng Wang 		if(givenname.length() == 0) name = sn;
99323ac9c5SLi Feng Wang 		else	name = givenname+" "+sn;
100323ac9c5SLi Feng Wang 
101323ac9c5SLi Feng Wang 		return name;
102323ac9c5SLi Feng Wang 	}
103323ac9c5SLi Feng Wang 
104323ac9c5SLi Feng Wang 	private XDocumentProperties getDocumentProperties(){
105323ac9c5SLi Feng Wang 		XDocumentPropertiesSupplier xDocumentProSupplier = (XDocumentPropertiesSupplier)UnoRuntime.queryInterface(
106323ac9c5SLi Feng Wang 				XDocumentPropertiesSupplier.class, this.m_xSDComponent);
107323ac9c5SLi Feng Wang 		return xDocumentProSupplier.getDocumentProperties();
108323ac9c5SLi Feng Wang 	}
109323ac9c5SLi Feng Wang 
110323ac9c5SLi Feng Wang 	@After
111323ac9c5SLi Feng Wang 	public void tearDownDocument() {
112323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
113*de51bb97SLi Feng Wang 		m_filePath = Testspace.getPath("temp/CheckFileProperties.odp");
114*de51bb97SLi Feng Wang 		FileUtil.deleteFile(m_filePath);
115323ac9c5SLi Feng Wang 
116323ac9c5SLi Feng Wang 	}
117323ac9c5SLi Feng Wang 
118323ac9c5SLi Feng Wang 	@BeforeClass
119323ac9c5SLi Feng Wang 	public static void setUpConnection() throws Exception {
120323ac9c5SLi Feng Wang 		app.start();
121323ac9c5SLi Feng Wang 		m_filePath = Testspace.getPath("temp/CheckFileProperties.odp");
122323ac9c5SLi Feng Wang 		FileUtil.deleteFile(m_filePath);
123323ac9c5SLi Feng Wang 	}
124323ac9c5SLi Feng Wang 
125323ac9c5SLi Feng Wang 	@AfterClass
126323ac9c5SLi Feng Wang 	public static void tearDownConnection() throws InterruptedException,
127323ac9c5SLi Feng Wang 			Exception {
128323ac9c5SLi Feng Wang 		app.close();
129323ac9c5SLi Feng Wang 	}
130323ac9c5SLi Feng Wang 
131323ac9c5SLi Feng Wang 	/*
132323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Created*/
133323ac9c5SLi Feng Wang 	@Test
134323ac9c5SLi Feng Wang 	public void testGeneralAuthor() throws Exception {
135323ac9c5SLi Feng Wang 		String author = getUserName();
136323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
137323ac9c5SLi Feng Wang 		xDocPro.setAuthor(author);
138323ac9c5SLi Feng Wang 
139323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
140323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
141323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
142323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
143323ac9c5SLi Feng Wang 		assertEquals("Author should be "+ author, author, xDocPro2.getAuthor());
144323ac9c5SLi Feng Wang 	}
145323ac9c5SLi Feng Wang 
146323ac9c5SLi Feng Wang 	private boolean DateTimeEquals(DateTime datetime1, DateTime datetime2){
147323ac9c5SLi Feng Wang 
148323ac9c5SLi Feng Wang 		if(datetime1.Seconds == datetime2.Seconds &&
149323ac9c5SLi Feng Wang 				datetime1.Minutes == datetime2.Minutes &&
150323ac9c5SLi Feng Wang 				datetime1.Hours == datetime2.Hours &&
151323ac9c5SLi Feng Wang 				datetime1.Day == datetime2.Day &&
152323ac9c5SLi Feng Wang 				datetime1.Month == datetime2.Month &&
153323ac9c5SLi Feng Wang 				datetime1.Year == datetime2.Year)
154323ac9c5SLi Feng Wang 			return true;
155323ac9c5SLi Feng Wang 		else
156323ac9c5SLi Feng Wang 			return false;
157323ac9c5SLi Feng Wang 	}
158323ac9c5SLi Feng Wang 
159323ac9c5SLi Feng Wang 	private boolean DateEquals(Date date1, Date date2){
160323ac9c5SLi Feng Wang 
161323ac9c5SLi Feng Wang 		if(date1.Day == date2.Day &&
162323ac9c5SLi Feng Wang 		   date1.Month == date2.Month &&
163323ac9c5SLi Feng Wang 			date1.Year == date2.Year)
164323ac9c5SLi Feng Wang 			return true;
165323ac9c5SLi Feng Wang 		else
166323ac9c5SLi Feng Wang 			return false;
167323ac9c5SLi Feng Wang 	}
168323ac9c5SLi Feng Wang 
169323ac9c5SLi Feng Wang 	private boolean DurationEquals(Duration d1, Duration d2){
170323ac9c5SLi Feng Wang 
171323ac9c5SLi Feng Wang 		if(d1.Seconds == d2.Seconds &&
172323ac9c5SLi Feng Wang 				d1.Minutes == d2.Minutes &&
173323ac9c5SLi Feng Wang 				d1.Hours == d2.Hours &&
174323ac9c5SLi Feng Wang 				d1.Days == d2.Days &&
175323ac9c5SLi Feng Wang 				d1.Months == d2.Months &&
176323ac9c5SLi Feng Wang 				d1.Years == d2.Years)
177323ac9c5SLi Feng Wang 			return true;
178323ac9c5SLi Feng Wang 		else
179323ac9c5SLi Feng Wang 			return false;
180323ac9c5SLi Feng Wang 	}
181323ac9c5SLi Feng Wang 
182323ac9c5SLi Feng Wang 	private DateTime getCurrentDateTime(){
183323ac9c5SLi Feng Wang 		Calendar ca = Calendar.getInstance();
184323ac9c5SLi Feng Wang 		DateTime currentDateTime = new DateTime();
185323ac9c5SLi Feng Wang 		currentDateTime.Year = (short)ca.get(Calendar.YEAR);
186323ac9c5SLi Feng Wang 		currentDateTime.Month = (short)ca.get(Calendar.MONTH);
187323ac9c5SLi Feng Wang 		currentDateTime.Day = (short)ca.get(Calendar.DATE);
188323ac9c5SLi Feng Wang 		currentDateTime.Minutes = (short)ca.get(Calendar.MINUTE);
189323ac9c5SLi Feng Wang 		currentDateTime.Hours = (short)ca.get(Calendar.HOUR);
190323ac9c5SLi Feng Wang 		currentDateTime.Seconds = (short)ca.get(Calendar.SECOND);
191323ac9c5SLi Feng Wang 
192323ac9c5SLi Feng Wang 		return currentDateTime;
193323ac9c5SLi Feng Wang 	}
194323ac9c5SLi Feng Wang 
195323ac9c5SLi Feng Wang 	private Date getCurrentDate(){
196323ac9c5SLi Feng Wang 		Calendar ca = Calendar.getInstance();
197323ac9c5SLi Feng Wang 		Date currentDate = new Date();
198323ac9c5SLi Feng Wang 		currentDate.Year = (short)ca.get(Calendar.YEAR);
199323ac9c5SLi Feng Wang 		currentDate.Month = (short)ca.get(Calendar.MONTH);
200323ac9c5SLi Feng Wang 		currentDate.Day = (short)ca.get(Calendar.DATE);
201323ac9c5SLi Feng Wang 
202323ac9c5SLi Feng Wang 		return currentDate;
203323ac9c5SLi Feng Wang 	}
204323ac9c5SLi Feng Wang 
205323ac9c5SLi Feng Wang 	/*
206323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Created*/
207323ac9c5SLi Feng Wang 	@Test
208323ac9c5SLi Feng Wang 	public void testGeneralCreationDate() throws Exception {
209323ac9c5SLi Feng Wang 		DateTime creationDate = getCurrentDateTime();
210323ac9c5SLi Feng Wang 
211323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
212323ac9c5SLi Feng Wang 
213323ac9c5SLi Feng Wang 		xDocPro.setCreationDate(creationDate);
214323ac9c5SLi Feng Wang 
215323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
216323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
217323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
218323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
219323ac9c5SLi Feng Wang 		DateTime result = xDocPro2.getCreationDate();
220323ac9c5SLi Feng Wang 		assertTrue("CreationDate should be the same as set", this.DateTimeEquals(creationDate, result));
221323ac9c5SLi Feng Wang 	}
222323ac9c5SLi Feng Wang 
223323ac9c5SLi Feng Wang 	/*
224323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Modified*/
225323ac9c5SLi Feng Wang 	@Test
226323ac9c5SLi Feng Wang 	//ModifiedBy will be set each time the file loaded. The value is the one set in Tools->options->User data->Last name
227323ac9c5SLi Feng Wang 	public void testGeneralModifiedBy() throws Exception {
228323ac9c5SLi Feng Wang 		String modifiedBy = this.getUserName();
229323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
230323ac9c5SLi Feng Wang 		xDocPro.setModifiedBy(modifiedBy);
231323ac9c5SLi Feng Wang 
232323ac9c5SLi Feng Wang 
233323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
234323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
235323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
236323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
237323ac9c5SLi Feng Wang 		assertEquals("The file is modified by "+ modifiedBy, modifiedBy, xDocPro2.getModifiedBy());
238323ac9c5SLi Feng Wang 	}
239323ac9c5SLi Feng Wang 
240323ac9c5SLi Feng Wang 	/*
241323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Modified*/
242323ac9c5SLi Feng Wang 	@Test
243323ac9c5SLi Feng Wang 	public void testGeneralModificationDate() throws Exception {
244323ac9c5SLi Feng Wang 		//modification date will be set each time the file saved, so I don't save after set.
245323ac9c5SLi Feng Wang 		DateTime modificationDate = getCurrentDateTime();
246323ac9c5SLi Feng Wang 
247323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
248323ac9c5SLi Feng Wang 
249323ac9c5SLi Feng Wang 		xDocPro.setModificationDate(modificationDate);
250323ac9c5SLi Feng Wang 
251323ac9c5SLi Feng Wang 		DateTime result = xDocPro.getModificationDate();
252323ac9c5SLi Feng Wang 		assertTrue("ModificationDate should be the same as set", this.DateTimeEquals(modificationDate, result));
253323ac9c5SLi Feng Wang 	}
254323ac9c5SLi Feng Wang 
255323ac9c5SLi Feng Wang 	/*
256323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Last printed*/
257323ac9c5SLi Feng Wang 	@Test
258323ac9c5SLi Feng Wang 	public void testGeneralPrintBy() throws Exception {
259323ac9c5SLi Feng Wang 		String printBy = "PrintBy";
260323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
261323ac9c5SLi Feng Wang 
262323ac9c5SLi Feng Wang 		xDocPro.setPrintedBy(printBy);
263323ac9c5SLi Feng Wang 
264323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
265323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
266323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
267323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
268323ac9c5SLi Feng Wang 		assertEquals("This document is printed by "+ printBy, printBy, xDocPro2.getPrintedBy());
269323ac9c5SLi Feng Wang 	}
270323ac9c5SLi Feng Wang 
271323ac9c5SLi Feng Wang 	/*
272323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Last printed*/
273323ac9c5SLi Feng Wang 	@Test
274323ac9c5SLi Feng Wang 	public void testGeneralPrintDate() throws Exception {
275323ac9c5SLi Feng Wang 		DateTime printDate = getCurrentDateTime();
276323ac9c5SLi Feng Wang 
277323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
278323ac9c5SLi Feng Wang 
279323ac9c5SLi Feng Wang 		xDocPro.setPrintDate(printDate);
280323ac9c5SLi Feng Wang 
281323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
282323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
283323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
284323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
285323ac9c5SLi Feng Wang 		DateTime result = xDocPro2.getPrintDate();
286323ac9c5SLi Feng Wang 		assertTrue("PrintDate should be the same as set", this.DateTimeEquals(printDate, result));
287323ac9c5SLi Feng Wang 	}
288323ac9c5SLi Feng Wang 
289323ac9c5SLi Feng Wang 	/*
290323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Total editing time*/
291323ac9c5SLi Feng Wang 	@Test
292323ac9c5SLi Feng Wang 	public void testGeneralEditingDuration() throws Exception {
293323ac9c5SLi Feng Wang 		int editingDuration = 60;
294323ac9c5SLi Feng Wang 
295323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
296323ac9c5SLi Feng Wang 
297323ac9c5SLi Feng Wang 		xDocPro.setEditingDuration(editingDuration);
298323ac9c5SLi Feng Wang 
299323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
300323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
301323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
302323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
303323ac9c5SLi Feng Wang 		assertEquals("Totally editing time should be "+ editingDuration, editingDuration, xDocPro2.getEditingDuration());
304323ac9c5SLi Feng Wang 	}
305323ac9c5SLi Feng Wang 
306323ac9c5SLi Feng Wang 	/*
307323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Revision number*/
308323ac9c5SLi Feng Wang 	@Test
309323ac9c5SLi Feng Wang 	public void testGeneralRevisionNumber() throws Exception {
310323ac9c5SLi Feng Wang 		short revisionNumber = 10;
311323ac9c5SLi Feng Wang 
312323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
313323ac9c5SLi Feng Wang 
314323ac9c5SLi Feng Wang 		xDocPro.setEditingCycles(revisionNumber);
315323ac9c5SLi Feng Wang 
316323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
317323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
318323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
319323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
320*de51bb97SLi Feng Wang 		assertEquals("Revision number should be "+ revisionNumber+1, revisionNumber+1, xDocPro2.getEditingCycles());
321323ac9c5SLi Feng Wang 	}
322323ac9c5SLi Feng Wang 
323323ac9c5SLi Feng Wang 	/*
324323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->template*/
325323ac9c5SLi Feng Wang 	@Test
326323ac9c5SLi Feng Wang 	public void testGeneralTemplateName() throws Exception {
327323ac9c5SLi Feng Wang 		String templateName = "I'm a template";
328323ac9c5SLi Feng Wang 
329323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
330323ac9c5SLi Feng Wang 
331323ac9c5SLi Feng Wang 		xDocPro.setTemplateName(templateName);
332323ac9c5SLi Feng Wang 
333323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
334323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
335323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
336323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
337323ac9c5SLi Feng Wang 		assertEquals("Template name should be "+ templateName, templateName, xDocPro2.getTemplateName());
338323ac9c5SLi Feng Wang 	}
339323ac9c5SLi Feng Wang 
340323ac9c5SLi Feng Wang 	/*
341323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->General->Reset*/
342323ac9c5SLi Feng Wang 	@Test
343323ac9c5SLi Feng Wang 	public void testGeneralReset() throws Exception {
344323ac9c5SLi Feng Wang 		String author = "ResetAuthor";
345323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
346323ac9c5SLi Feng Wang 		xDocPro.resetUserData(author);
347323ac9c5SLi Feng Wang 
348323ac9c5SLi Feng Wang 		assertEquals("Author should be "+ author, author, xDocPro.getAuthor());
349323ac9c5SLi Feng Wang 		assertEquals("Modified should be empty", "", xDocPro.getModifiedBy());
350323ac9c5SLi Feng Wang 		assertTrue("ModificationDate should be empty",
351323ac9c5SLi Feng Wang 				DateTimeEquals(new DateTime(), xDocPro.getModificationDate()));
352323ac9c5SLi Feng Wang 		assertEquals("PrintBy should be empty", "", xDocPro.getPrintedBy());
353323ac9c5SLi Feng Wang 		assertTrue("PrintDate should be empty",
354323ac9c5SLi Feng Wang 				DateTimeEquals(new DateTime(), xDocPro.getPrintDate()));
355323ac9c5SLi Feng Wang 		assertEquals("Totally editing time should be empty", 0, xDocPro.getEditingDuration());
356323ac9c5SLi Feng Wang 		assertEquals("Revision number should be empty", 1, xDocPro.getEditingCycles());
357323ac9c5SLi Feng Wang 	}
358323ac9c5SLi Feng Wang 
359323ac9c5SLi Feng Wang 	// UI entry: File->Properties->General->Apply user data
360323ac9c5SLi Feng Wang 
361323ac9c5SLi Feng Wang 	// UI entry: File->Properties->General->digital signature
362323ac9c5SLi Feng Wang 
363323ac9c5SLi Feng Wang 	//Description begin
364323ac9c5SLi Feng Wang 	/*
365323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->Description->Title*/
366323ac9c5SLi Feng Wang 	@Test
367323ac9c5SLi Feng Wang 	public void testDescriptionTitle() throws Exception{
368323ac9c5SLi Feng Wang 		String title = "titleForTest";
369323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
370323ac9c5SLi Feng Wang 		xDocPro.setTitle(title);
371323ac9c5SLi Feng Wang 
372323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
373323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
374323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
375323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
376323ac9c5SLi Feng Wang 		assertEquals("Title should be "+ title, title, xDocPro2.getTitle());
377323ac9c5SLi Feng Wang 	}
378323ac9c5SLi Feng Wang 
379323ac9c5SLi Feng Wang 	/*
380323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->Description->Subject*/
381323ac9c5SLi Feng Wang 	@Test
382323ac9c5SLi Feng Wang 	public void testDescriptionSubject() throws Exception{
383323ac9c5SLi Feng Wang 		String subject = "subjectForTest";
384323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
385323ac9c5SLi Feng Wang 		xDocPro.setSubject(subject);
386323ac9c5SLi Feng Wang 
387323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
388323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
389323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
390323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
391323ac9c5SLi Feng Wang 		assertEquals("Subject should be "+ subject, subject, xDocPro2.getSubject());
392323ac9c5SLi Feng Wang 	}
393323ac9c5SLi Feng Wang 
394323ac9c5SLi Feng Wang 	/*
395323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->Description->Keywords*/
396323ac9c5SLi Feng Wang 	@Test
397323ac9c5SLi Feng Wang 	public void testDescriptionKeywords() throws Exception{
398323ac9c5SLi Feng Wang 		String[] keywords = {"keyword1", "keyword2"};
399323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
400323ac9c5SLi Feng Wang 		xDocPro.setKeywords(keywords);
401323ac9c5SLi Feng Wang 
402323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
403323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
404323ac9c5SLi Feng Wang 
405323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
406323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
407323ac9c5SLi Feng Wang 		String[] keywordsResult = xDocPro2.getKeywords();
408323ac9c5SLi Feng Wang 		assertEquals("There should be 2 Keywords", 2, keywordsResult.length);
409323ac9c5SLi Feng Wang 		for(int i=0;i<keywordsResult.length;i++)
410323ac9c5SLi Feng Wang 		{
411323ac9c5SLi Feng Wang 			String num = Integer.toString(i+1);
412323ac9c5SLi Feng Wang 			assertEquals("The keywords should be keyword"+num, "keyword"+num, keywordsResult[i]);
413323ac9c5SLi Feng Wang 		}
414323ac9c5SLi Feng Wang 	}
415323ac9c5SLi Feng Wang 
416323ac9c5SLi Feng Wang 	/*
417323ac9c5SLi Feng Wang 	 * UI entry: File->Properties->Description->Comments*/
418323ac9c5SLi Feng Wang 	@Test
419323ac9c5SLi Feng Wang 	public void testDescriptionComments() throws Exception{
420323ac9c5SLi Feng Wang 		String comments = "This is the comment.";
421323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro = getDocumentProperties();
422323ac9c5SLi Feng Wang 		xDocPro.setDescription(comments);
423323ac9c5SLi Feng Wang 
424323ac9c5SLi Feng Wang 		app.saveDocument(m_xSDComponent, m_filePath);
425323ac9c5SLi Feng Wang 		app.closeDocument(m_xSDComponent);
426323ac9c5SLi Feng Wang 
427323ac9c5SLi Feng Wang 		m_xSDComponent = app.loadDocument(m_filePath);
428323ac9c5SLi Feng Wang 		XDocumentProperties xDocPro2 = getDocumentProperties();
429323ac9c5SLi Feng Wang 
430323ac9c5SLi Feng Wang 		assertEquals("Comments should be "+comments, comments, xDocPro2.getDescription());
431323ac9c5SLi Feng Wang 	}
432323ac9c5SLi Feng Wang 	//Description end
433323ac9c5SLi Feng Wang 
434323ac9c5SLi Feng Wang 	//custom properties begin
435323ac9c5SLi Feng Wang 	//UI entry: File->Properties->Custom properties
436323ac9c5SLi Feng Wang 		private void addCustomPro(String propertyName, Object value) throws PropertyExistException, IllegalTypeException, IllegalArgumentException{
437323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro = getDocumentProperties();
438323ac9c5SLi Feng Wang 			XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
439323ac9c5SLi Feng Wang 			proContainer.addProperty(propertyName, PropertyAttribute.REMOVEABLE, value);
440323ac9c5SLi Feng Wang 		}
441323ac9c5SLi Feng Wang 
442323ac9c5SLi Feng Wang 		private Object getCustomPro(String propertyName) throws UnknownPropertyException, WrappedTargetException{
443323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro = getDocumentProperties();
444323ac9c5SLi Feng Wang 			XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
445323ac9c5SLi Feng Wang 			XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface(
446323ac9c5SLi Feng Wang 					XPropertySet.class, proContainer);
447323ac9c5SLi Feng Wang 
448323ac9c5SLi Feng Wang 			return xProSet.getPropertyValue(propertyName);
449323ac9c5SLi Feng Wang 		}
450323ac9c5SLi Feng Wang 
451323ac9c5SLi Feng Wang 		@Test
452323ac9c5SLi Feng Wang 		public void testCustomAddPro_Text() throws Exception{
453323ac9c5SLi Feng Wang 			String addedProName = "TextPro";
454323ac9c5SLi Feng Wang 			String addedProDefaultValue = "testUser";
455323ac9c5SLi Feng Wang 
456323ac9c5SLi Feng Wang 			addCustomPro(addedProName, addedProDefaultValue);
457323ac9c5SLi Feng Wang 
458323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
459323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
460323ac9c5SLi Feng Wang 
461323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
462323ac9c5SLi Feng Wang 
463323ac9c5SLi Feng Wang 			String result = (String)getCustomPro(addedProName);
464323ac9c5SLi Feng Wang 
465323ac9c5SLi Feng Wang 			assertTrue("added Text property \""+addedProName+"\" should exist", result != null);
466323ac9c5SLi Feng Wang 			assertEquals("value of added property should be "+addedProDefaultValue,
467323ac9c5SLi Feng Wang 					addedProDefaultValue, result);
468323ac9c5SLi Feng Wang 		}
469323ac9c5SLi Feng Wang 
470323ac9c5SLi Feng Wang 		@Test
471323ac9c5SLi Feng Wang 		public void testCustomAddPro_DateTime() throws Exception{
472323ac9c5SLi Feng Wang 			String addedProName = "DateTimePro";
473323ac9c5SLi Feng Wang 			DateTime addedProDefaultValue = getCurrentDateTime();
474323ac9c5SLi Feng Wang 
475323ac9c5SLi Feng Wang 			addCustomPro(addedProName, addedProDefaultValue);
476323ac9c5SLi Feng Wang 
477323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
478323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
479323ac9c5SLi Feng Wang 
480323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
481323ac9c5SLi Feng Wang 
482323ac9c5SLi Feng Wang 			DateTime result = (DateTime)getCustomPro(addedProName);
483323ac9c5SLi Feng Wang 			assertTrue("added DateTime property \""+addedProName+"\" should exist", result != null);
484323ac9c5SLi Feng Wang 			assertTrue("value of added property should be the same as set",
485323ac9c5SLi Feng Wang 					this.DateTimeEquals(result, addedProDefaultValue));
486323ac9c5SLi Feng Wang 		}
487323ac9c5SLi Feng Wang 
488323ac9c5SLi Feng Wang 		@Test
489323ac9c5SLi Feng Wang 		public void testCustomAddPro_Date() throws Exception{
490323ac9c5SLi Feng Wang 			String addedProName = "DatePro";
491323ac9c5SLi Feng Wang 			Date addedProDefaultValue = getCurrentDate();
492323ac9c5SLi Feng Wang 
493323ac9c5SLi Feng Wang 			addCustomPro(addedProName, addedProDefaultValue);
494323ac9c5SLi Feng Wang 
495323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
496323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
497323ac9c5SLi Feng Wang 
498323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
499323ac9c5SLi Feng Wang 
500323ac9c5SLi Feng Wang 			Date result = (Date)getCustomPro(addedProName);
501323ac9c5SLi Feng Wang 			assertTrue("added Date property \""+addedProName+"\" should exist", result != null);
502323ac9c5SLi Feng Wang 			assertTrue("value of added property should be the same as set",
503323ac9c5SLi Feng Wang 					this.DateEquals(result, addedProDefaultValue));
504323ac9c5SLi Feng Wang 		}
505323ac9c5SLi Feng Wang 
506323ac9c5SLi Feng Wang 		@Test
507323ac9c5SLi Feng Wang 		public void testCustomAddPro_Duration() throws Exception{
508323ac9c5SLi Feng Wang 			String addedProName = "DurationPro";
509323ac9c5SLi Feng Wang 			Duration addedProDefaultValue = new Duration();
510323ac9c5SLi Feng Wang 			addedProDefaultValue.Days = 1;
511323ac9c5SLi Feng Wang 
512323ac9c5SLi Feng Wang 			addCustomPro(addedProName, addedProDefaultValue);
513323ac9c5SLi Feng Wang 
514323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
515323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
516323ac9c5SLi Feng Wang 
517323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
518323ac9c5SLi Feng Wang 
519323ac9c5SLi Feng Wang 			Duration result = (Duration)getCustomPro(addedProName);
520323ac9c5SLi Feng Wang 			assertTrue("added Date property \""+addedProName+"\" should exist", result != null);
521323ac9c5SLi Feng Wang 			assertTrue("value of added property should the same as set", DurationEquals(addedProDefaultValue, result));
522323ac9c5SLi Feng Wang 		}
523323ac9c5SLi Feng Wang 
524323ac9c5SLi Feng Wang 		@Test
525323ac9c5SLi Feng Wang 		public void testCustomAddPro_Number() throws Exception{
526323ac9c5SLi Feng Wang 			String addedProName = "NumberPro";
527323ac9c5SLi Feng Wang 			Double addedProDefaultValue = (double)10;
528323ac9c5SLi Feng Wang 
529323ac9c5SLi Feng Wang 			addCustomPro(addedProName, addedProDefaultValue);
530323ac9c5SLi Feng Wang 
531323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
532323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
533323ac9c5SLi Feng Wang 
534323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
535323ac9c5SLi Feng Wang 
536323ac9c5SLi Feng Wang 			Object oResult = getCustomPro(addedProName);
537323ac9c5SLi Feng Wang 
538323ac9c5SLi Feng Wang 			Double result = (Double)oResult;
539323ac9c5SLi Feng Wang 			assertTrue("added Number property \""+addedProName+"\" should exist", oResult != null);
540323ac9c5SLi Feng Wang 			assertEquals("value of added property should be "+Double.toString(addedProDefaultValue),
541323ac9c5SLi Feng Wang 					addedProDefaultValue, result);
542323ac9c5SLi Feng Wang 		}
543323ac9c5SLi Feng Wang 
544323ac9c5SLi Feng Wang 		@Test
545323ac9c5SLi Feng Wang 		public void testCustomAddPro_Boolean() throws Exception{
546323ac9c5SLi Feng Wang 			String addedProName = "BooleanPro";
547323ac9c5SLi Feng Wang 			Boolean addedProDefaultValue = true;
548323ac9c5SLi Feng Wang 
549323ac9c5SLi Feng Wang 			addCustomPro(addedProName, addedProDefaultValue);
550323ac9c5SLi Feng Wang 
551323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
552323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
553323ac9c5SLi Feng Wang 
554323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
555323ac9c5SLi Feng Wang 
556323ac9c5SLi Feng Wang 			Object oResult = getCustomPro(addedProName);
557323ac9c5SLi Feng Wang 
558323ac9c5SLi Feng Wang 			boolean result = (Boolean)oResult;
559323ac9c5SLi Feng Wang 			assertTrue("added Number property \""+addedProName+"\" should exist", oResult != null);
560323ac9c5SLi Feng Wang 			assertEquals("value of added property should be "+Boolean.toString(addedProDefaultValue),
561323ac9c5SLi Feng Wang 					addedProDefaultValue, result);
562323ac9c5SLi Feng Wang 		}
563323ac9c5SLi Feng Wang 
564323ac9c5SLi Feng Wang 		@Test
565*de51bb97SLi Feng Wang 		public void testCustomRemovePro() throws Exception{
566*de51bb97SLi Feng Wang 			addCustomPro("testPro", "value");
567323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro = getDocumentProperties();
568323ac9c5SLi Feng Wang 			XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
569323ac9c5SLi Feng Wang 			XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface(
570323ac9c5SLi Feng Wang 					XPropertySet.class, proContainer);
571323ac9c5SLi Feng Wang 			XPropertySetInfo xproSetInfo = xProSet.getPropertySetInfo();
572323ac9c5SLi Feng Wang 			Property[] pros = xproSetInfo.getProperties();
573323ac9c5SLi Feng Wang 
574323ac9c5SLi Feng Wang 			for(int i=0; i< pros.length;i++)
575323ac9c5SLi Feng Wang 			{
576323ac9c5SLi Feng Wang 				proContainer.removeProperty(pros[i].Name);
577323ac9c5SLi Feng Wang 			}
578323ac9c5SLi Feng Wang 
579323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
580323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
581323ac9c5SLi Feng Wang 
582323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
583323ac9c5SLi Feng Wang 
584323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro2 = getDocumentProperties();
585323ac9c5SLi Feng Wang 			XPropertyContainer proContainer2 = xDocPro2.getUserDefinedProperties();
586323ac9c5SLi Feng Wang 			XPropertySet xProSet2 = (XPropertySet)UnoRuntime.queryInterface(
587323ac9c5SLi Feng Wang 					XPropertySet.class, proContainer2);
588323ac9c5SLi Feng Wang 			XPropertySetInfo xproSetInfo2 = xProSet2.getPropertySetInfo();
589323ac9c5SLi Feng Wang 			Property[] pros2 = xproSetInfo2.getProperties();
590323ac9c5SLi Feng Wang 
591323ac9c5SLi Feng Wang 			assertEquals("number of custom property should be zero ",
592323ac9c5SLi Feng Wang 					0, pros2.length);
593323ac9c5SLi Feng Wang 		}
594323ac9c5SLi Feng Wang 	//custom properties end
595323ac9c5SLi Feng Wang 
596323ac9c5SLi Feng Wang 		//Internet begin
597323ac9c5SLi Feng Wang 		private void setAutoLoad(String URL, int secs) throws IllegalArgumentException
598323ac9c5SLi Feng Wang 		{
599323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro = getDocumentProperties();
600323ac9c5SLi Feng Wang 			xDocPro.setAutoloadURL(URL);
601323ac9c5SLi Feng Wang 			xDocPro.setAutoloadSecs(secs);
602323ac9c5SLi Feng Wang 			xDocPro.setDefaultTarget("_blank");
603323ac9c5SLi Feng Wang 		}
604323ac9c5SLi Feng Wang 
605323ac9c5SLi Feng Wang 		@Test
606323ac9c5SLi Feng Wang 		public void testNoRefresh() throws Exception{
607323ac9c5SLi Feng Wang 			String autoLoadURL = "";
608323ac9c5SLi Feng Wang 			int autoLoadSecs = 0;
609323ac9c5SLi Feng Wang 			setAutoLoad(autoLoadURL, autoLoadSecs);
610323ac9c5SLi Feng Wang 
611323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
612323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
613323ac9c5SLi Feng Wang 
614323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
615323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro2 = getDocumentProperties();
616323ac9c5SLi Feng Wang 
617323ac9c5SLi Feng Wang 			assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL());
618323ac9c5SLi Feng Wang 			assertEquals("AutoLoadSecs should be 0", autoLoadSecs, xDocPro2.getAutoloadSecs());
619323ac9c5SLi Feng Wang 		}
620323ac9c5SLi Feng Wang 
621323ac9c5SLi Feng Wang 		@Test
622323ac9c5SLi Feng Wang 		public void testRefreshEvery60Secs() throws Exception{
623323ac9c5SLi Feng Wang 			String autoLoadURL = "";
624323ac9c5SLi Feng Wang 			int autoLoadSecs = 60;
625323ac9c5SLi Feng Wang 			setAutoLoad(autoLoadURL, autoLoadSecs);
626323ac9c5SLi Feng Wang 
627323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
628323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
629323ac9c5SLi Feng Wang 
630323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
631323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro2 = getDocumentProperties();
632323ac9c5SLi Feng Wang 
633323ac9c5SLi Feng Wang 			assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL());
634323ac9c5SLi Feng Wang 			assertEquals("AutoLoadSecs should be "+Integer.toString(autoLoadSecs), autoLoadSecs, xDocPro2.getAutoloadSecs());
635323ac9c5SLi Feng Wang 		}
636323ac9c5SLi Feng Wang 
637323ac9c5SLi Feng Wang 		@Test
638323ac9c5SLi Feng Wang 		public void testRedirect() throws Exception{
639323ac9c5SLi Feng Wang 			String autoLoadURL = "http://www.openoffice.com/";
640323ac9c5SLi Feng Wang 			int autoLoadSecs = 5;
641323ac9c5SLi Feng Wang 			setAutoLoad(autoLoadURL, autoLoadSecs);
642323ac9c5SLi Feng Wang 
643323ac9c5SLi Feng Wang 			app.saveDocument(m_xSDComponent, m_filePath);
644323ac9c5SLi Feng Wang 			app.closeDocument(m_xSDComponent);
645323ac9c5SLi Feng Wang 
646323ac9c5SLi Feng Wang 			m_xSDComponent = app.loadDocument(m_filePath);
647323ac9c5SLi Feng Wang 			XDocumentProperties xDocPro2 = getDocumentProperties();
648323ac9c5SLi Feng Wang 
649323ac9c5SLi Feng Wang 			assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL());
650323ac9c5SLi Feng Wang 			assertEquals("AutoLoadSecs should be "+Integer.toString(autoLoadSecs), autoLoadSecs, xDocPro2.getAutoloadSecs());
651323ac9c5SLi Feng Wang 		}
652323ac9c5SLi Feng Wang 		//Internet end
653323ac9c5SLi Feng Wang }
654