2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package complex
.desktop
;
21 import com
.sun
.star
.lang
.XMultiServiceFactory
;
22 import com
.sun
.star
.frame
.XDesktop
;
23 import com
.sun
.star
.uno
.UnoRuntime
;
24 import org
.junit
.AfterClass
;
25 import org
.junit
.BeforeClass
;
26 import org
.junit
.Test
;
27 import org
.openoffice
.test
.OfficeConnection
;
28 import static org
.junit
.Assert
.*;
34 * <li>NoOffice=yes - StarOffice is not started initially.</li>
37 public class DesktopTerminate
40 private XMultiServiceFactory xMSF
;
41 private static final int iOfficeCloseTime
= 1000;
44 * Test if all available document types change the
45 * persistent Window Attributes
47 * The test follows basically these steps:
48 * - Create a configuration reader and a componentloader
49 * - Look for all document types in the configuration
50 * - Do for every doc type
52 * - read configuration attribute settings
53 * - create a new document
54 * - resize the document and close it
57 * - read configuration attribute settings
58 * - create another new document
59 * - compare old settings with new ones: should be different
60 * - compare the document size with the resized document: should be equal
64 @Test public void checkPersistentWindowState()
69 System
.out
.println("Connect the first time.");
87 private boolean connect()
92 util
.utils
.pause(10000);
94 catch (java
.lang
.Exception e
)
96 System
.out
.println(e
.getClass().getName());
97 System
.out
.println("Message: " + e
.getMessage());
98 fail("Cannot connect the Office.");
104 private boolean disconnect()
108 XDesktop desk
= null;
109 desk
= UnoRuntime
.queryInterface(XDesktop
.class, xMSF
.createInstance("com.sun.star.frame.Desktop"));
111 System
.out
.println("Waiting " + iOfficeCloseTime
+ " milliseconds for the Office to close down");
112 util
.utils
.pause(iOfficeCloseTime
);
115 catch (java
.lang
.Exception e
)
118 fail("Cannot dispose the Office.");
125 private XMultiServiceFactory
getMSF()
127 return UnoRuntime
.queryInterface(XMultiServiceFactory
.class, connection
.getComponentContext().getServiceManager());
130 // setup and close connections
131 @BeforeClass public static void setUpConnection() throws Exception
{
132 System
.out
.println("setUpConnection()");
136 @AfterClass public static void tearDownConnection()
138 System
.out
.println("tearDownConnection()");
139 // don't do a tearDown here, desktop is already terminated.
142 private static final OfficeConnection connection
= new OfficeConnection();