Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / framework / qa / complex / desktop / DesktopTerminate.java
blob5a60a5ed5ea1eff256af8b1517430809ffd37c95
1 /*
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.*;
31 /**
32 * Parameters:
33 * <ul>
34 * <li>NoOffice=yes - StarOffice is not started initially.</li>
35 * </ul>
37 public class DesktopTerminate
40 private XMultiServiceFactory xMSF;
41 private static final int iOfficeCloseTime = 1000;
43 /**
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
51 * - start office
52 * - read configuration attribute settings
53 * - create a new document
54 * - resize the document and close it
55 * - close office
56 * - start office
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
61 * - close office
62 * - Test finished
64 @Test public void checkPersistentWindowState()
66 try
69 System.out.println("Connect the first time.");
71 if (!connect())
73 return;
76 if (!disconnect())
78 return;
81 catch (Exception e)
83 e.printStackTrace();
87 private boolean connect()
89 try
91 xMSF = getMSF();
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.");
99 return false;
101 return true;
104 private boolean disconnect()
108 XDesktop desk = null;
109 desk = UnoRuntime.queryInterface(XDesktop.class, xMSF.createInstance("com.sun.star.frame.Desktop"));
110 desk.terminate();
111 System.out.println("Waiting " + iOfficeCloseTime + " milliseconds for the Office to close down");
112 util.utils.pause(iOfficeCloseTime);
113 xMSF = null;
115 catch (java.lang.Exception e)
117 e.printStackTrace();
118 fail("Cannot dispose the Office.");
119 return false;
121 return true;
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()");
133 connection.setUp();
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();