bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXDrawPage.java
blobf2407f63ab4706a21d074b316cb5b6a4c006ece6
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._sw;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.InstCreator;
28 import util.SOfficeFactory;
29 import util.ShapeDsc;
31 import com.sun.star.drawing.XDrawPage;
32 import com.sun.star.drawing.XDrawPageSupplier;
33 import com.sun.star.drawing.XShapes;
34 import com.sun.star.text.XTextDocument;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
38 /**
39 * Test for object which is represented by service
40 * <code>com.sun.star.drawing.DrawPage</code>. <p>
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>com::sun::star::drawing::GenericDrawPage</code></li>
44 * <li> <code>com::sun::star::drawing::XShapeBinder</code></li>
45 * <li> <code>com::sun::star::drawing::XShapeGrouper</code></li>
46 * <li> <code>com::sun::star::drawing::XShapes</code></li>
47 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
48 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
49 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
50 * <li> <code>com::sun::star::container::XElementAccess</code></li>
51 * <li> <code>com::sun::star::drawing::XMasterPageTarget</code></li>
52 * <li> <code>com::sun::star::container::XNamed</code></li>
53 * <li> <code>com::sun::star::drawing::XShapeCombiner</code></li>
54 * </ul> <p>
55 * This object test <b> is NOT </b> designed to be run in several
56 * threads concurently.
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.XMasterPageTarget
66 * @see com.sun.star.container.XNamed
67 * @see com.sun.star.drawing.XShapeCombiner
68 * @see ifc.drawing._GenericDrawPage
69 * @see ifc.drawing._XShapeBinder
70 * @see ifc.drawing._XShapeGrouper
71 * @see ifc.drawing._XShapes
72 * @see ifc.lang._XServiceInfo
73 * @see ifc.beans._XPropertySet
74 * @see ifc.container._XIndexAccess
75 * @see ifc.container._XElementAccess
76 * @see ifc.drawing._XMasterPageTarget
77 * @see ifc.container._XNamed
78 * @see ifc.drawing._XShapeCombiner
80 public class SwXDrawPage extends TestCase {
81 XTextDocument xTextDoc;
83 /**
84 * Creates text document.
86 @Override
87 protected void initialize( TestParameters tParam, PrintWriter log ) {
88 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
89 try {
90 log.println( "creating a textdocument" );
91 xTextDoc = SOF.createTextDoc( null );
92 } catch ( com.sun.star.uno.Exception e ) {
93 e.printStackTrace( log );
94 throw new StatusException( "Couldn't create document", e );
98 /**
99 * Disposes text document.
101 @Override
102 protected void cleanup( TestParameters tParam, PrintWriter log ) {
103 log.println( " disposing xTextDoc " );
104 util.DesktopTools.closeDoc(xTextDoc);
108 * Creating a Testenvironment for the interfaces to be tested. After
109 * obtaining DrawPage object several shapes are inserted to it.
110 * Object relations created :
111 * <ul>
112 * <li> <code>'Shape'</code> for
113 * {@link ifc.drawing._XShapes} : shape creator. </li>
114 * <li> <code>'DrawPage'</code> for
115 * {@link ifc.drawing._XShapeBinder},
116 * {@link ifc.drawing._XShapeCombiner},
117 * {@link ifc.drawing._XShapeGrouper} : DrawPage component we are
118 * testing.</li>
119 * </ul>
121 @Override
122 public synchronized TestEnvironment createTestEnvironment(
123 TestParameters Param, PrintWriter log ) throws StatusException {
124 XInterface oObj = null;
125 XDrawPageSupplier XDPSupp;
126 XDrawPage xDP = null;
127 XShapes oShapes = null;
129 log.println( "creating a test environment" );
130 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() );
131 XDPSupp = UnoRuntime.queryInterface
132 (XDrawPageSupplier.class, xTextDoc);
133 xDP = XDPSupp.getDrawPage();
134 oObj = xDP;
136 log.println( "inserting some Shapes" );
137 oShapes = UnoRuntime.queryInterface(XShapes.class, oObj);
138 oShapes.add(SOF.createShape(xTextDoc,2000,1500,1000,1000,"Line"));
139 oShapes.add(SOF.createShape(xTextDoc,3000,4500,15000,1000,"Ellipse"));
140 oShapes.add(SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle"));
142 log.println( "creating a new environment for bodytext object" );
143 TestEnvironment tEnv = new TestEnvironment( oObj );
145 ShapeDsc sDsc = new ShapeDsc(15000,13500,7500,10000,"Rectangle");
146 log.println( "adding Shape as mod relation to environment" );
147 tEnv.addObjRelation("Shape", new InstCreator( xTextDoc, sDsc));
148 tEnv.addObjRelation("DrawPage", oObj);
150 return tEnv;
151 } // finish method getTestEnvironment
153 } // finish class SwXDrawPage