1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 /** 22 * 23 */ 24 package fvt.uno.sd.file; 25 import static org.junit.Assert.*; 26 27 import org.junit.After; 28 import org.junit.AfterClass; 29 import org.junit.Before; 30 import org.junit.BeforeClass; 31 import org.junit.Test; 32 import org.openoffice.test.OpenOffice; 33 import org.openoffice.test.uno.UnoApp; 34 import org.openoffice.test.common.FileUtil; 35 import org.openoffice.test.common.Testspace; 36 37 import com.sun.star.beans.IllegalTypeException; 38 import com.sun.star.beans.Property; 39 import com.sun.star.beans.PropertyAttribute; 40 import com.sun.star.beans.PropertyExistException; 41 import com.sun.star.beans.PropertyValue; 42 import com.sun.star.beans.UnknownPropertyException; 43 import com.sun.star.beans.XPropertyContainer; 44 import com.sun.star.beans.XPropertySet; 45 import com.sun.star.beans.XPropertySetInfo; 46 import com.sun.star.container.XNameAccess; 47 import com.sun.star.document.XDocumentProperties; 48 import com.sun.star.document.XDocumentPropertiesSupplier; 49 import java.util.Calendar; 50 import com.sun.star.util.DateTime; 51 import com.sun.star.util.Date; 52 import com.sun.star.util.Duration; 53 import com.sun.star.lang.IllegalArgumentException; 54 import com.sun.star.lang.WrappedTargetException; 55 import com.sun.star.lang.XComponent; 56 import com.sun.star.lang.XMultiServiceFactory; 57 import com.sun.star.uno.UnoRuntime; 58 59 /** 60 * @author LouQL 61 * 62 */ 63 public class CheckFileProperties { 64 65 private static UnoApp app; 66 67 private XComponent m_xSDComponent = null; 68 private static String m_filePath = null; 69 70 @Before 71 public void setUpDocument() throws Exception { 72 if (FileUtil.fileExists(m_filePath)) {//load 73 m_xSDComponent = app.loadDocument(m_filePath); 74 } else {//new 75 m_xSDComponent = (XComponent) UnoRuntime.queryInterface( 76 XComponent.class, app.newDocument("simpress")); 77 } 78 } 79 80 private String getUserName() throws com.sun.star.uno.Exception 81 { 82 Object configurationProvider = app.getServiceFactory(). 83 createInstance("com.sun.star.configuration.ConfigurationProvider"); 84 85 XMultiServiceFactory msFac = (XMultiServiceFactory)UnoRuntime.queryInterface( 86 XMultiServiceFactory.class, configurationProvider); 87 88 PropertyValue[] propValue = new PropertyValue[1]; 89 propValue[0] = new PropertyValue(); 90 propValue[0].Name = "nodepath"; 91 propValue[0].Value = "/org.openoffice.UserProfile/Data"; 92 93 Object configurationAccess = msFac.createInstanceWithArguments( 94 "com.sun.star.configuration.ConfigurationAccess", propValue); 95 XNameAccess nameAcc = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, configurationAccess); 96 String givenname = (String)nameAcc.getByName("givenname"); 97 String sn = (String)nameAcc.getByName("sn"); 98 String name = null; 99 if(givenname.length() == 0) name = sn; 100 else name = givenname+" "+sn; 101 102 return name; 103 } 104 105 private XDocumentProperties getDocumentProperties(){ 106 XDocumentPropertiesSupplier xDocumentProSupplier = (XDocumentPropertiesSupplier)UnoRuntime.queryInterface( 107 XDocumentPropertiesSupplier.class, this.m_xSDComponent); 108 return xDocumentProSupplier.getDocumentProperties(); 109 } 110 111 @After 112 public void tearDownDocument() { 113 app.closeDocument(m_xSDComponent); 114 m_filePath = Testspace.getPath("temp/CheckFileProperties.odp"); 115 FileUtil.deleteFile(m_filePath); 116 117 } 118 119 @BeforeClass 120 public static void setUpConnection() throws Exception { 121 OpenOffice openOffice = UnoApp.getDefaultOpenOffice(); 122 // #128398# 123 openOffice.addRegistryModifications( 124 " <item oor:path=\"/org.openoffice.Office.Common/Security/Scripting\">\n" + 125 " <prop oor:name=\"RemovePersonalInfoOnSaving\" oor:op=\"fuse\">\n" + 126 " <value>false</value>\n" + 127 " </prop>\n" + 128 " </item>"); 129 app = new UnoApp(openOffice); 130 app.start(); 131 m_filePath = Testspace.getPath("temp/CheckFileProperties.odp"); 132 FileUtil.deleteFile(m_filePath); 133 } 134 135 @AfterClass 136 public static void tearDownConnection() throws InterruptedException, 137 Exception { 138 app.close(); 139 } 140 141 /* 142 * UI entry: File->Properties->General->Created*/ 143 @Test 144 public void testGeneralAuthor() throws Exception { 145 String author = getUserName(); 146 XDocumentProperties xDocPro = getDocumentProperties(); 147 xDocPro.setAuthor(author); 148 149 app.saveDocument(m_xSDComponent, m_filePath); 150 app.closeDocument(m_xSDComponent); 151 m_xSDComponent = app.loadDocument(m_filePath); 152 XDocumentProperties xDocPro2 = getDocumentProperties(); 153 assertEquals("Author should be "+ author, author, xDocPro2.getAuthor()); 154 } 155 156 private boolean DateTimeEquals(DateTime datetime1, DateTime datetime2){ 157 158 if(datetime1.Seconds == datetime2.Seconds && 159 datetime1.Minutes == datetime2.Minutes && 160 datetime1.Hours == datetime2.Hours && 161 datetime1.Day == datetime2.Day && 162 datetime1.Month == datetime2.Month && 163 datetime1.Year == datetime2.Year) 164 return true; 165 else 166 return false; 167 } 168 169 private boolean DateEquals(Date date1, Date date2){ 170 171 if(date1.Day == date2.Day && 172 date1.Month == date2.Month && 173 date1.Year == date2.Year) 174 return true; 175 else 176 return false; 177 } 178 179 private boolean DurationEquals(Duration d1, Duration d2){ 180 181 if(d1.Seconds == d2.Seconds && 182 d1.Minutes == d2.Minutes && 183 d1.Hours == d2.Hours && 184 d1.Days == d2.Days && 185 d1.Months == d2.Months && 186 d1.Years == d2.Years) 187 return true; 188 else 189 return false; 190 } 191 192 private DateTime getCurrentDateTime(){ 193 Calendar ca = Calendar.getInstance(); 194 DateTime currentDateTime = new DateTime(); 195 currentDateTime.Year = (short)ca.get(Calendar.YEAR); 196 // java.util.Calendar's months start at 0=January. 197 currentDateTime.Month = (short)(ca.get(Calendar.MONTH) + 1); 198 currentDateTime.Day = (short)ca.get(Calendar.DATE); 199 currentDateTime.Minutes = (short)ca.get(Calendar.MINUTE); 200 currentDateTime.Hours = (short)ca.get(Calendar.HOUR_OF_DAY); 201 currentDateTime.Seconds = (short)ca.get(Calendar.SECOND); 202 203 return currentDateTime; 204 } 205 206 private Date getCurrentDate(){ 207 Calendar ca = Calendar.getInstance(); 208 Date currentDate = new Date(); 209 currentDate.Year = (short)ca.get(Calendar.YEAR); 210 // java.util.Calendar's months start at 0=January. 211 currentDate.Month = (short)(ca.get(Calendar.MONTH) + 1); 212 currentDate.Day = (short)ca.get(Calendar.DATE); 213 214 return currentDate; 215 } 216 217 /* 218 * UI entry: File->Properties->General->Created*/ 219 @Test 220 public void testGeneralCreationDate() throws Exception { 221 DateTime creationDate = getCurrentDateTime(); 222 223 XDocumentProperties xDocPro = getDocumentProperties(); 224 225 xDocPro.setCreationDate(creationDate); 226 227 app.saveDocument(m_xSDComponent, m_filePath); 228 app.closeDocument(m_xSDComponent); 229 m_xSDComponent = app.loadDocument(m_filePath); 230 XDocumentProperties xDocPro2 = getDocumentProperties(); 231 DateTime result = xDocPro2.getCreationDate(); 232 assertTrue("CreationDate should be the same as set", this.DateTimeEquals(creationDate, result)); 233 } 234 235 /* 236 * UI entry: File->Properties->General->Modified*/ 237 @Test 238 //ModifiedBy will be set each time the file loaded. The value is the one set in Tools->options->User data->Last name 239 public void testGeneralModifiedBy() throws Exception { 240 String modifiedBy = this.getUserName(); 241 XDocumentProperties xDocPro = getDocumentProperties(); 242 xDocPro.setModifiedBy(modifiedBy); 243 244 245 app.saveDocument(m_xSDComponent, m_filePath); 246 app.closeDocument(m_xSDComponent); 247 m_xSDComponent = app.loadDocument(m_filePath); 248 XDocumentProperties xDocPro2 = getDocumentProperties(); 249 assertEquals("The file is modified by "+ modifiedBy, modifiedBy, xDocPro2.getModifiedBy()); 250 } 251 252 /* 253 * UI entry: File->Properties->General->Modified*/ 254 @Test 255 public void testGeneralModificationDate() throws Exception { 256 //modification date will be set each time the file saved, so I don't save after set. 257 DateTime modificationDate = getCurrentDateTime(); 258 259 XDocumentProperties xDocPro = getDocumentProperties(); 260 261 xDocPro.setModificationDate(modificationDate); 262 263 DateTime result = xDocPro.getModificationDate(); 264 assertTrue("ModificationDate should be the same as set", this.DateTimeEquals(modificationDate, result)); 265 } 266 267 /* 268 * UI entry: File->Properties->General->Last printed*/ 269 @Test 270 public void testGeneralPrintBy() throws Exception { 271 String printBy = "PrintBy"; 272 XDocumentProperties xDocPro = getDocumentProperties(); 273 274 xDocPro.setPrintedBy(printBy); 275 276 app.saveDocument(m_xSDComponent, m_filePath); 277 app.closeDocument(m_xSDComponent); 278 m_xSDComponent = app.loadDocument(m_filePath); 279 XDocumentProperties xDocPro2 = getDocumentProperties(); 280 assertEquals("This document is printed by "+ printBy, printBy, xDocPro2.getPrintedBy()); 281 } 282 283 /* 284 * UI entry: File->Properties->General->Last printed*/ 285 @Test 286 public void testGeneralPrintDate() throws Exception { 287 DateTime printDate = getCurrentDateTime(); 288 289 XDocumentProperties xDocPro = getDocumentProperties(); 290 291 xDocPro.setPrintDate(printDate); 292 293 app.saveDocument(m_xSDComponent, m_filePath); 294 app.closeDocument(m_xSDComponent); 295 m_xSDComponent = app.loadDocument(m_filePath); 296 XDocumentProperties xDocPro2 = getDocumentProperties(); 297 DateTime result = xDocPro2.getPrintDate(); 298 assertTrue("PrintDate should be the same as set", this.DateTimeEquals(printDate, result)); 299 } 300 301 /* 302 * UI entry: File->Properties->General->Total editing time*/ 303 @Test 304 public void testGeneralEditingDuration() throws Exception { 305 int editingDuration = 60; 306 307 XDocumentProperties xDocPro = getDocumentProperties(); 308 309 xDocPro.setEditingDuration(editingDuration); 310 311 app.saveDocument(m_xSDComponent, m_filePath); 312 app.closeDocument(m_xSDComponent); 313 m_xSDComponent = app.loadDocument(m_filePath); 314 XDocumentProperties xDocPro2 = getDocumentProperties(); 315 assertEquals("Totally editing time should be "+ editingDuration, editingDuration, xDocPro2.getEditingDuration()); 316 } 317 318 /* 319 * UI entry: File->Properties->General->Revision number*/ 320 @Test 321 public void testGeneralRevisionNumber() throws Exception { 322 short revisionNumber = 10; 323 324 XDocumentProperties xDocPro = getDocumentProperties(); 325 326 xDocPro.setEditingCycles(revisionNumber); 327 328 app.saveDocument(m_xSDComponent, m_filePath); 329 app.closeDocument(m_xSDComponent); 330 m_xSDComponent = app.loadDocument(m_filePath); 331 XDocumentProperties xDocPro2 = getDocumentProperties(); 332 assertEquals("Revision number increments by 1", revisionNumber+1, xDocPro2.getEditingCycles()); 333 } 334 335 /* 336 * UI entry: File->Properties->General->template*/ 337 @Test 338 public void testGeneralTemplateName() throws Exception { 339 String templateName = "I'm a template"; 340 341 XDocumentProperties xDocPro = getDocumentProperties(); 342 343 xDocPro.setTemplateName(templateName); 344 345 app.saveDocument(m_xSDComponent, m_filePath); 346 app.closeDocument(m_xSDComponent); 347 m_xSDComponent = app.loadDocument(m_filePath); 348 XDocumentProperties xDocPro2 = getDocumentProperties(); 349 assertEquals("Template name should be "+ templateName, templateName, xDocPro2.getTemplateName()); 350 } 351 352 /* 353 * UI entry: File->Properties->General->Reset*/ 354 @Test 355 public void testGeneralReset() throws Exception { 356 String author = "ResetAuthor"; 357 XDocumentProperties xDocPro = getDocumentProperties(); 358 xDocPro.resetUserData(author); 359 360 assertEquals("Author should be "+ author, author, xDocPro.getAuthor()); 361 assertEquals("Modified should be empty", "", xDocPro.getModifiedBy()); 362 assertTrue("ModificationDate should be empty", 363 DateTimeEquals(new DateTime(), xDocPro.getModificationDate())); 364 assertEquals("PrintBy should be empty", "", xDocPro.getPrintedBy()); 365 assertTrue("PrintDate should be empty", 366 DateTimeEquals(new DateTime(), xDocPro.getPrintDate())); 367 assertEquals("Totally editing time should be empty", 0, xDocPro.getEditingDuration()); 368 assertEquals("Revision number should be empty", 1, xDocPro.getEditingCycles()); 369 } 370 371 // UI entry: File->Properties->General->Apply user data 372 373 // UI entry: File->Properties->General->digital signature 374 375 //Description begin 376 /* 377 * UI entry: File->Properties->Description->Title*/ 378 @Test 379 public void testDescriptionTitle() throws Exception{ 380 String title = "titleForTest"; 381 XDocumentProperties xDocPro = getDocumentProperties(); 382 xDocPro.setTitle(title); 383 384 app.saveDocument(m_xSDComponent, m_filePath); 385 app.closeDocument(m_xSDComponent); 386 m_xSDComponent = app.loadDocument(m_filePath); 387 XDocumentProperties xDocPro2 = getDocumentProperties(); 388 assertEquals("Title should be "+ title, title, xDocPro2.getTitle()); 389 } 390 391 /* 392 * UI entry: File->Properties->Description->Subject*/ 393 @Test 394 public void testDescriptionSubject() throws Exception{ 395 String subject = "subjectForTest"; 396 XDocumentProperties xDocPro = getDocumentProperties(); 397 xDocPro.setSubject(subject); 398 399 app.saveDocument(m_xSDComponent, m_filePath); 400 app.closeDocument(m_xSDComponent); 401 m_xSDComponent = app.loadDocument(m_filePath); 402 XDocumentProperties xDocPro2 = getDocumentProperties(); 403 assertEquals("Subject should be "+ subject, subject, xDocPro2.getSubject()); 404 } 405 406 /* 407 * UI entry: File->Properties->Description->Keywords*/ 408 @Test 409 public void testDescriptionKeywords() throws Exception{ 410 String[] keywords = {"keyword1", "keyword2"}; 411 XDocumentProperties xDocPro = getDocumentProperties(); 412 xDocPro.setKeywords(keywords); 413 414 app.saveDocument(m_xSDComponent, m_filePath); 415 app.closeDocument(m_xSDComponent); 416 417 m_xSDComponent = app.loadDocument(m_filePath); 418 XDocumentProperties xDocPro2 = getDocumentProperties(); 419 String[] keywordsResult = xDocPro2.getKeywords(); 420 assertEquals("There should be 2 Keywords", 2, keywordsResult.length); 421 for(int i=0;i<keywordsResult.length;i++) 422 { 423 String num = Integer.toString(i+1); 424 assertEquals("The keywords should be keyword"+num, "keyword"+num, keywordsResult[i]); 425 } 426 } 427 428 /* 429 * UI entry: File->Properties->Description->Comments*/ 430 @Test 431 public void testDescriptionComments() throws Exception{ 432 String comments = "This is the comment."; 433 XDocumentProperties xDocPro = getDocumentProperties(); 434 xDocPro.setDescription(comments); 435 436 app.saveDocument(m_xSDComponent, m_filePath); 437 app.closeDocument(m_xSDComponent); 438 439 m_xSDComponent = app.loadDocument(m_filePath); 440 XDocumentProperties xDocPro2 = getDocumentProperties(); 441 442 assertEquals("Comments should be "+comments, comments, xDocPro2.getDescription()); 443 } 444 //Description end 445 446 //custom properties begin 447 //UI entry: File->Properties->Custom properties 448 private void addCustomPro(String propertyName, Object value) throws PropertyExistException, IllegalTypeException, IllegalArgumentException{ 449 XDocumentProperties xDocPro = getDocumentProperties(); 450 XPropertyContainer proContainer = xDocPro.getUserDefinedProperties(); 451 proContainer.addProperty(propertyName, PropertyAttribute.REMOVEABLE, value); 452 } 453 454 private Object getCustomPro(String propertyName) throws UnknownPropertyException, WrappedTargetException{ 455 XDocumentProperties xDocPro = getDocumentProperties(); 456 XPropertyContainer proContainer = xDocPro.getUserDefinedProperties(); 457 XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface( 458 XPropertySet.class, proContainer); 459 460 return xProSet.getPropertyValue(propertyName); 461 } 462 463 @Test 464 public void testCustomAddPro_Text() throws Exception{ 465 String addedProName = "TextPro"; 466 String addedProDefaultValue = "testUser"; 467 468 addCustomPro(addedProName, addedProDefaultValue); 469 470 app.saveDocument(m_xSDComponent, m_filePath); 471 app.closeDocument(m_xSDComponent); 472 473 m_xSDComponent = app.loadDocument(m_filePath); 474 475 String result = (String)getCustomPro(addedProName); 476 477 assertTrue("added Text property \""+addedProName+"\" should exist", result != null); 478 assertEquals("value of added property should be "+addedProDefaultValue, 479 addedProDefaultValue, result); 480 } 481 482 @Test 483 public void testCustomAddPro_DateTime() throws Exception{ 484 String addedProName = "DateTimePro"; 485 DateTime addedProDefaultValue = getCurrentDateTime(); 486 487 addCustomPro(addedProName, addedProDefaultValue); 488 489 app.saveDocument(m_xSDComponent, m_filePath); 490 app.closeDocument(m_xSDComponent); 491 492 m_xSDComponent = app.loadDocument(m_filePath); 493 494 DateTime result = (DateTime)getCustomPro(addedProName); 495 assertTrue("added DateTime property \""+addedProName+"\" should exist", result != null); 496 assertTrue("value of added property should be the same as set", 497 this.DateTimeEquals(result, addedProDefaultValue)); 498 } 499 500 @Test 501 public void testCustomAddPro_Date() throws Exception{ 502 String addedProName = "DatePro"; 503 Date addedProDefaultValue = getCurrentDate(); 504 505 addCustomPro(addedProName, addedProDefaultValue); 506 507 app.saveDocument(m_xSDComponent, m_filePath); 508 app.closeDocument(m_xSDComponent); 509 510 m_xSDComponent = app.loadDocument(m_filePath); 511 512 Date result = (Date)getCustomPro(addedProName); 513 assertTrue("added Date property \""+addedProName+"\" should exist", result != null); 514 assertTrue("value of added property should be the same as set", 515 this.DateEquals(result, addedProDefaultValue)); 516 } 517 518 @Test 519 public void testCustomAddPro_Duration() throws Exception{ 520 String addedProName = "DurationPro"; 521 Duration addedProDefaultValue = new Duration(); 522 addedProDefaultValue.Days = 1; 523 524 addCustomPro(addedProName, addedProDefaultValue); 525 526 app.saveDocument(m_xSDComponent, m_filePath); 527 app.closeDocument(m_xSDComponent); 528 529 m_xSDComponent = app.loadDocument(m_filePath); 530 531 Duration result = (Duration)getCustomPro(addedProName); 532 assertTrue("added Date property \""+addedProName+"\" should exist", result != null); 533 assertTrue("value of added property should the same as set", DurationEquals(addedProDefaultValue, result)); 534 } 535 536 @Test 537 public void testCustomAddPro_Number() throws Exception{ 538 String addedProName = "NumberPro"; 539 Double addedProDefaultValue = (double)10; 540 541 addCustomPro(addedProName, addedProDefaultValue); 542 543 app.saveDocument(m_xSDComponent, m_filePath); 544 app.closeDocument(m_xSDComponent); 545 546 m_xSDComponent = app.loadDocument(m_filePath); 547 548 Object oResult = getCustomPro(addedProName); 549 550 Double result = (Double)oResult; 551 assertTrue("added Number property \""+addedProName+"\" should exist", oResult != null); 552 assertEquals("value of added property should be "+Double.toString(addedProDefaultValue), 553 addedProDefaultValue, result); 554 } 555 556 @Test 557 public void testCustomAddPro_Boolean() throws Exception{ 558 String addedProName = "BooleanPro"; 559 Boolean addedProDefaultValue = true; 560 561 addCustomPro(addedProName, addedProDefaultValue); 562 563 app.saveDocument(m_xSDComponent, m_filePath); 564 app.closeDocument(m_xSDComponent); 565 566 m_xSDComponent = app.loadDocument(m_filePath); 567 568 Object oResult = getCustomPro(addedProName); 569 570 boolean result = (Boolean)oResult; 571 assertTrue("added Number property \""+addedProName+"\" should exist", oResult != null); 572 assertEquals("value of added property should be "+Boolean.toString(addedProDefaultValue), 573 addedProDefaultValue, result); 574 } 575 576 @Test 577 public void testCustomRemovePro() throws Exception{ 578 addCustomPro("testPro", "value"); 579 XDocumentProperties xDocPro = getDocumentProperties(); 580 XPropertyContainer proContainer = xDocPro.getUserDefinedProperties(); 581 XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface( 582 XPropertySet.class, proContainer); 583 XPropertySetInfo xproSetInfo = xProSet.getPropertySetInfo(); 584 Property[] pros = xproSetInfo.getProperties(); 585 586 for(int i=0; i< pros.length;i++) 587 { 588 proContainer.removeProperty(pros[i].Name); 589 } 590 591 app.saveDocument(m_xSDComponent, m_filePath); 592 app.closeDocument(m_xSDComponent); 593 594 m_xSDComponent = app.loadDocument(m_filePath); 595 596 XDocumentProperties xDocPro2 = getDocumentProperties(); 597 XPropertyContainer proContainer2 = xDocPro2.getUserDefinedProperties(); 598 XPropertySet xProSet2 = (XPropertySet)UnoRuntime.queryInterface( 599 XPropertySet.class, proContainer2); 600 XPropertySetInfo xproSetInfo2 = xProSet2.getPropertySetInfo(); 601 Property[] pros2 = xproSetInfo2.getProperties(); 602 603 assertEquals("number of custom property should be zero ", 604 0, pros2.length); 605 } 606 //custom properties end 607 608 //Internet begin 609 private void setAutoLoad(String URL, int secs) throws IllegalArgumentException 610 { 611 XDocumentProperties xDocPro = getDocumentProperties(); 612 xDocPro.setAutoloadURL(URL); 613 xDocPro.setAutoloadSecs(secs); 614 xDocPro.setDefaultTarget("_blank"); 615 } 616 617 @Test 618 public void testNoRefresh() throws Exception{ 619 String autoLoadURL = ""; 620 int autoLoadSecs = 0; 621 setAutoLoad(autoLoadURL, autoLoadSecs); 622 623 app.saveDocument(m_xSDComponent, m_filePath); 624 app.closeDocument(m_xSDComponent); 625 626 m_xSDComponent = app.loadDocument(m_filePath); 627 XDocumentProperties xDocPro2 = getDocumentProperties(); 628 629 assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL()); 630 assertEquals("AutoLoadSecs should be 0", autoLoadSecs, xDocPro2.getAutoloadSecs()); 631 } 632 633 @Test 634 public void testRefreshEvery60Secs() throws Exception{ 635 String autoLoadURL = ""; 636 int autoLoadSecs = 60; 637 setAutoLoad(autoLoadURL, autoLoadSecs); 638 639 app.saveDocument(m_xSDComponent, m_filePath); 640 app.closeDocument(m_xSDComponent); 641 642 m_xSDComponent = app.loadDocument(m_filePath); 643 XDocumentProperties xDocPro2 = getDocumentProperties(); 644 645 assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL()); 646 assertEquals("AutoLoadSecs should be "+Integer.toString(autoLoadSecs), autoLoadSecs, xDocPro2.getAutoloadSecs()); 647 } 648 649 @Test 650 public void testRedirect() throws Exception{ 651 String autoLoadURL = "http://www.openoffice.com/"; 652 int autoLoadSecs = 5; 653 setAutoLoad(autoLoadURL, autoLoadSecs); 654 655 app.saveDocument(m_xSDComponent, m_filePath); 656 app.closeDocument(m_xSDComponent); 657 658 m_xSDComponent = app.loadDocument(m_filePath); 659 XDocumentProperties xDocPro2 = getDocumentProperties(); 660 661 assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL()); 662 assertEquals("AutoLoadSecs should be "+Integer.toString(autoLoadSecs), autoLoadSecs, xDocPro2.getAutoloadSecs()); 663 } 664 //Internet end 665 } 666