tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdGenericDrawPage.java
blob6190b369331389e8651b56da8687e7482b2bc1e2
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.XShapes;
35 import com.sun.star.lang.XComponent;
36 import com.sun.star.uno.AnyConverter;
37 import com.sun.star.uno.Type;
38 import com.sun.star.uno.UnoRuntime;
39 import com.sun.star.uno.XInterface;
41 /**
42 * Test for object which is represented by service
43 * <code>com.sun.star.drawing.GenericDrawPage</code>. <p>
44 * Object implements the following interfaces :
45 * <ul>
46 * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li>
47 * <li> <code>com::sun::star::drawing::XShapeBinder</code></li>
48 * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li>
49 * <li> <code>com::sun::star::drawing::XShapes</code></li>
50 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
51 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
52 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
53 * <li> <code>com::sun::star::container::XElementAccess</code></li>
54 * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li>
55 * <li> <code>com::sun::star::container::XNamed</code></li>
56 * </ul>
57 * @see com.sun.star.drawing.GenericDrawPage
58 * @see com.sun.star.drawing.XShapeBinder
59 * @see com.sun.star.drawing.XShapeGrouper
60 * @see com.sun.star.drawing.XShapes
61 * @see com.sun.star.lang.XServiceInfo
62 * @see com.sun.star.beans.XPropertySet
63 * @see com.sun.star.container.XIndexAccess
64 * @see com.sun.star.container.XElementAccess
65 * @see com.sun.star.drawing.XShapeCombiner
66 * @see com.sun.star.container.XNamed
67 * @see ifc.drawing._GenericDrawPage
68 * @see ifc.drawing._XShapeBinder
69 * @see ifc.drawing._XShapeGrouper
70 * @see ifc.drawing._XShapes
71 * @see ifc.lang._XServiceInfo
72 * @see ifc.beans._XPropertySet
73 * @see ifc.container._XIndexAccess
74 * @see ifc.container._XElementAccess
75 * @see ifc.drawing._XShapeCombiner
76 * @see ifc.container._XNamed
78 public class SdGenericDrawPage extends TestCase {
79 XComponent xDrawDoc;
81 /**
82 * Creates Drawing document.
84 @Override
85 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
86 // get a soffice factory object
87 SOfficeFactory SOF = SOfficeFactory.getFactory(
88 Param.getMSF());
90 log.println( "creating a draw document" );
91 xDrawDoc = SOF.createDrawDoc(null);
94 /**
95 * Disposes Drawing document.
97 @Override
98 protected void cleanup( TestParameters Param, PrintWriter log) {
99 log.println("disposing xDrawDoc");
100 util.DesktopTools.closeDoc(xDrawDoc);
104 * Creating a TestEnvironment for the interfaces to be tested.
105 * Retrieves the collection of the draw pages from the drawing document using
106 * the interface <code>XDrawPagesSupplier</code> and take one of them.
107 * The retrieved draw page is the instance of the service
108 * <code>com.sun.star.drawing.DrawPage</code>. Inserts some shapes
109 * into the draw page. Creates the rectangle shape.
110 * Object relations created :
111 * <ul>
112 * <li> <code>'Shape'</code> for
113 * {@link ifc.drawing._XShapes}( the created rectangle shape )</li>
114 * <li> <code>'DrawPage'</code> for
115 * {@link ifc.drawing._XShapeBinder}, {@link ifc.drawing._XShapeGrouper},
116 * {@link ifc.drawing._XShapeCombiner}( the retrieved draw page )</li>
117 * </ul>
118 * @see com.sun.star.drawing.DrawPage
119 * @see com.sun.star.drawing.XDrawPagesSupplier
121 @Override
122 protected TestEnvironment createTestEnvironment(
123 TestParameters Param, PrintWriter log) throws Exception {
125 XInterface oObj = null;
126 XShapes oShapes = null;
128 // creation of testobject here
129 // first we write what we are intend to do to log file
130 log.println( "creating a test environment" );
131 // get a soffice factory object
132 SOfficeFactory SOF = SOfficeFactory.getFactory(
133 Param.getMSF());
135 // get the drawpage of drawing here
136 log.println( "getting Drawpage" );
137 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,xDrawDoc);
138 XDrawPages oDPn = oDPS.getDrawPages();
139 XIndexAccess oDPi = UnoRuntime.queryInterface
140 (XIndexAccess.class,oDPn);
141 oObj = (XDrawPage) AnyConverter.toObject(
142 new Type(XDrawPage.class),oDPi.getByIndex(0));
144 //put something on the drawpage
145 log.println( "inserting some Shapes" );
146 oShapes = UnoRuntime.queryInterface(XShapes.class,oObj);
147 oShapes.add(SOF.createShape
148 (xDrawDoc, 2000, 1500, 1000, 1000, "Line"));
149 oShapes.add(SOF.createShape
150 (xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"));
151 oShapes.add(SOF.createShape
152 (xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"));
154 log.println( "creating a new environment for drawpage object" );
155 TestEnvironment tEnv = new TestEnvironment( oObj );
157 ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle");
158 log.println( "adding Shape as mod relation to environment" );
159 tEnv.addObjRelation("Shape", new InstCreator( xDrawDoc, sDsc));
161 // adding relation for XShapeGrouper
162 tEnv.addObjRelation("DrawPage", oObj);
164 return tEnv;
165 } // finish method createTestEnvironment
168 } // finish class SdGenericDrawPage