Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _fwk / Frame.java
blob9ce802c7264bffa74f1837a82d588a5d2286ec67
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 .
19 package mod._fwk;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.frame.XFrame;
30 import com.sun.star.text.XTextDocument;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
33 import com.sun.star.util.XCloseable;
35 /**
36 * Test for object that implements the following interfaces :
37 * <ul>
38 * <li><code>com::sun::star::frame::XDispatchProvider</code></li>
39 * <li><code>com::sun::star::frame::XFrame</code></li>
40 * <li><code>com::sun::star::frame::XFramesSupplier</code></li>
41 * <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li>
42 * <li><code>com::sun::star::lang::XComponent</code></li>
43 * </ul><p>
44 * @see com.sun.star.frame.XDispatchProvider
45 * @see com.sun.star.frame.XFrame
46 * @see com.sun.star.frame.XFramesSupplier
47 * @see com.sun.star.task.XStatusIndicatorFactory
48 * @see com.sun.star.lang.XComponent
49 * @see ifc.frame._XDispatchProvider
50 * @see ifc.frame._XFrame
51 * @see ifc.frame._XFramesSupplier
52 * @see ifc.task._XStatusIndicatorFactory
53 * @see ifc.lang._XComponent
55 public class Frame extends TestCase {
57 XTextDocument xTextDoc;
58 XFrame frame = null;
61 /**
62 * Creates a text document and obtains a frame of current controller.
64 @Override
65 public TestEnvironment createTestEnvironment( TestParameters Param,
66 PrintWriter log ) throws StatusException {
68 XInterface oObj = null;
70 log.println( "creating a test environment" );
72 // get a soffice factory object
73 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
75 try {
76 log.println( "creating a text document" );
77 xTextDoc = SOF.createTextDoc(null);
78 } catch ( com.sun.star.uno.Exception e ) {
79 // Some exception occurs.FAILED
80 e.printStackTrace( log );
81 throw new StatusException( "Couldn't create document", e );
84 frame = xTextDoc.getCurrentController().getFrame();
85 oObj = UnoRuntime.queryInterface(XInterface.class, frame);
87 log.println(util.utils.getImplName(oObj));
89 TestEnvironment tEnv = new TestEnvironment( oObj );
91 tEnv.addObjRelation("XDispatchProvider.URL",
92 ".uno:SwitchControlDesignMode");
94 return tEnv;
95 } // finish method getTestEnvironment
98 /**
99 * Disposes the document created and finally disposes
100 * the frame containing the document (for case when the frame
101 * contains no model after some interafce manipulations).
103 @Override
104 protected void cleanup( TestParameters Param, PrintWriter log) {
105 try {
106 XCloseable xTextClose = UnoRuntime.queryInterface(XCloseable.class, xTextDoc);
107 xTextClose.close(true);
108 } catch(Exception e){}