tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdLayerManager.java
blob8d42ce8a902c2468f1d652f0eca50b9073a9c860
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.InstCreator;
27 import util.SOfficeFactory;
28 import util.ShapeDsc;
30 import com.sun.star.container.XIndexAccess;
31 import com.sun.star.drawing.XDrawPage;
32 import com.sun.star.drawing.XDrawPages;
33 import com.sun.star.drawing.XDrawPagesSupplier;
34 import com.sun.star.drawing.XLayerSupplier;
35 import com.sun.star.drawing.XShapes;
36 import com.sun.star.lang.XComponent;
37 import com.sun.star.uno.AnyConverter;
38 import com.sun.star.uno.Type;
39 import com.sun.star.uno.UnoRuntime;
40 import com.sun.star.uno.XInterface;
42 /**
43 * Test for object which is represented by service
44 * <code>com.sun.star.drawing.LayerManager</code>. <p>
45 * Object implements the following interfaces :
46 * <ul>
47 * <li> <code>com::sun::star::drawing::XLayerManager</code></li>
48 * <li> <code>com::sun::star::container::XNameAccess</code></li>
49 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
50 * <li> <code>com::sun::star::container::XElementAccess</code></li>
51 * </ul>
52 * @see com.sun.star.drawing.LayerManager
53 * @see com.sun.star.drawing.XLayerManager
54 * @see com.sun.star.container.XNameAccess
55 * @see com.sun.star.container.XIndexAccess
56 * @see com.sun.star.container.XElementAccess
57 * @see ifc.drawing._XLayerManager
58 * @see ifc.container._XNameAccess
59 * @see ifc.container._XIndexAccess
60 * @see ifc.container._XElementAccess
62 public class SdLayerManager extends TestCase {
63 XComponent xDrawDoc;
65 /**
66 * Creates Drawing document.
68 @Override
69 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
70 // get a soffice factory object
71 SOfficeFactory SOF = SOfficeFactory.getFactory(
72 Param.getMSF());
73 log.println("creating a draw document");
74 xDrawDoc = SOF.createDrawDoc(null);
77 /**
78 * Disposes Drawing document.
80 @Override
81 protected void cleanup( TestParameters Param, PrintWriter log) {
82 log.println("disposing xDrawDoc");
83 util.DesktopTools.closeDoc(xDrawDoc);
86 /**
87 * Creating a TestEnvironment for the interfaces to be tested.
88 * Retrieves the layer manager using the interface <code>XLayerSupplier</code>.
89 * The manager is the instance of the service
90 * <code>com.sun.star.drawing.LayerManager</code>. Creates a rectangle shape.
91 * Retrieves the collection of the draw pages and take one of them.
92 * <ul>
93 * <li> <code>'Shape'</code> for
94 * {@link ifc.drawing._XLayerManager}(the created shape)</li>
95 * <li> <code>'Shapes'</code> for
96 * {@link ifc.drawing._XLayerManager}(the shape collection of
97 * the retrieved draw page)</li>
98 * </ul>
99 * @see com.sun.star.drawing.XLayerSupplier
100 * @see com.sun.star.drawing.LayerManager
102 @Override
103 protected TestEnvironment createTestEnvironment(
104 TestParameters Param, PrintWriter log) throws Exception {
106 // creation of testobject here
107 // first we write what we are intend to do to log file
108 log.println( "creating a test environment" );
110 // create testobject here
111 XLayerSupplier oLS = UnoRuntime.queryInterface(XLayerSupplier.class, xDrawDoc);
112 XInterface oObj = oLS.getLayerManager();
114 log.println( "creating a new environment for XLayerManager object" );
115 TestEnvironment tEnv = new TestEnvironment( oObj );
117 ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle");
118 log.println( "adding Shape as mod relation to environment" );
119 tEnv.addObjRelation("Shape", new InstCreator(xDrawDoc, sDsc));
122 // get the drawpage of drawing here
123 log.println( "getting Drawpage" );
124 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,xDrawDoc);
125 XDrawPages oDPn = oDPS.getDrawPages();
126 XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,oDPn);
128 XDrawPage oDP = (XDrawPage) AnyConverter.toObject(
129 new Type(XDrawPage.class),oDPi.getByIndex(0));
131 XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDP);
133 log.println( "adding Shapes as mod relation to environment" );
134 tEnv.addObjRelation("Shapes", oShapes);
136 return tEnv;
137 } // finish method getTestEnvironment
139 } // finish class SdLayerManager