tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdXPresentation.java
blob344eb205b940b63addfa52ae6382d1194b5e4d79
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._sd;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
28 import com.sun.star.container.XNameContainer;
29 import com.sun.star.lang.XComponent;
30 import com.sun.star.lang.XSingleServiceFactory;
31 import com.sun.star.presentation.XCustomPresentationSupplier;
32 import com.sun.star.presentation.XPresentationSupplier;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.presentation.Presentation</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::presentation::Presentation</code></li>
42 * <li> <code>com::sun::star::presentation::XPresentation</code></li>
43 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
44 * </ul>
45 * @see com.sun.star.presentation.Presentation
46 * @see com.sun.star.presentation.XPresentation
47 * @see com.sun.star.beans.XPropertySet
48 * @see ifc.presentation._Presentation
49 * @see ifc.presentation._XPresentation
50 * @see ifc.beans._XPropertySet
52 public class SdXPresentation extends TestCase {
53 XComponent xImpressDoc;
55 /**
56 * Creates Impress document.
58 @Override
59 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
60 // get a soffice factory object
61 SOfficeFactory SOF = SOfficeFactory.getFactory(
62 Param.getMSF());
63 log.println( "creating a draw document" );
64 xImpressDoc = SOF.createImpressDoc(null);
67 /**
68 * Disposes Impress document.
70 @Override
71 protected void cleanup( TestParameters Param, PrintWriter log) {
72 log.println("disposing xImpressDoc");
73 util.DesktopTools.closeDoc(xImpressDoc);
76 /**
77 * Creating a TestEnvironment for the interfaces to be tested.
78 * Retrieves the presentation from the document using the interface
79 * <code>XPresentationSupplier</code>. The retrieved presentation is the
80 * instance of the service <code>com.sun.star.presentation.Presentation</code>.
81 * Retrieves the collection of the customized presentations from the document
82 * using the interface <code>XCustomPresentationSupplier</code>.
83 * Creates and inserts two new instances of presentation to the retrieved
84 * collection.
85 * Object relations created :
86 * <ul>
87 * <li> <code>'Presentation'</code> for
88 * {@link ifc.presentation._Presentation}(the retrieved presentation)</li>
89 * </ul>
90 * @see com.sun.star.presentation.XCustomPresentationSupplier
91 * @see com.sun.star.presentation.Presentation
92 * @see com.sun.star.presentation.XCustomPresentationSupplier
94 @Override
95 public TestEnvironment createTestEnvironment(
96 TestParameters Param, PrintWriter log) throws Exception {
98 // creation of testobject here
99 // first we write what we are intend to do to log file
100 log.println( "creating a test environment" );
102 log.println( "get presentation" );
103 XPresentationSupplier oPS = UnoRuntime.queryInterface(XPresentationSupplier.class, xImpressDoc);
104 XInterface oObj = oPS.getPresentation();
106 log.println( "get custom presentation" );
107 XCustomPresentationSupplier oCPS = UnoRuntime.queryInterface(
108 XCustomPresentationSupplier.class, xImpressDoc);
109 XNameContainer xCP = oCPS.getCustomPresentations();
111 XInterface oInstance = null;
112 XInterface oInstance2 = null;
114 XSingleServiceFactory oSingleMSF = UnoRuntime.queryInterface(XSingleServiceFactory.class, xCP);
116 oInstance = (XInterface) oSingleMSF.createInstance();
117 oInstance2 = (XInterface) oSingleMSF.createInstance();
119 xCP.insertByName("FirstPresentation",oInstance);
120 xCP.insertByName("SecondPresentation", oInstance2);
122 log.println( "creating a new environment for XPresentation object" );
123 TestEnvironment tEnv = new TestEnvironment( oObj );
125 tEnv.addObjRelation("Presentation",oObj);
127 return tEnv;
128 } // finish method getTestEnvironment
130 } // finish class SdPresentation