bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXShape.java
blob1a19f15eb8ecc532314fe964178b55d4de607111
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.SOfficeFactory;
29 import com.sun.star.drawing.XDrawPage;
30 import com.sun.star.drawing.XDrawPageSupplier;
31 import com.sun.star.drawing.XShape;
32 import com.sun.star.drawing.XShapes;
33 import com.sun.star.text.XTextDocument;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XInterface;
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.drawing.Shape</code>. <p>
40 * Object implements the following interfaces :
41 * <ul>
42 * <li> <code>com::sun::star::lang::XComponent</code></li>
43 * <li> <code>com::sun::star::drawing::XShape</code></li>
44 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li>
45 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
46 * <li> <code>com::sun::star::drawing::Shape</code></li>
47 * </ul> <p>
48 * This object test <b> is NOT </b> designed to be run in several
49 * threads concurently.
50 * @see com.sun.star.lang.XComponent
51 * @see com.sun.star.drawing.XShape
52 * @see com.sun.star.drawing.XShapeDescriptor
53 * @see com.sun.star.beans.XPropertySet
54 * @see com.sun.star.drawing.Shape
55 * @see ifc.lang._XComponent
56 * @see ifc.drawing._XShape
57 * @see ifc.drawing._XShapeDescriptor
58 * @see ifc.beans._XPropertySet
59 * @see ifc.drawing._Shape
61 public class SwXShape extends TestCase {
62 XTextDocument xTextDoc;
63 SOfficeFactory SOF;
65 /**
66 * Creates text document.
68 @Override
69 protected void initialize( TestParameters tParam, PrintWriter log ) {
70 SOF = SOfficeFactory.getFactory( tParam.getMSF() );
71 try {
72 log.println( "creating a textdocument" );
73 xTextDoc = SOF.createTextDoc( null );
74 } catch ( com.sun.star.uno.Exception e ) {
75 e.printStackTrace( log );
76 throw new StatusException( "Couldn't create document", e );
80 /**
81 * Disposes text document.
83 @Override
84 protected void cleanup( TestParameters tParam, PrintWriter log ) {
85 log.println( " disposing xTextDoc " );
86 util.DesktopTools.closeDoc(xTextDoc);
89 /**
90 * Creating a Testenvironment for the interfaces to be tested. At first,
91 * DrawPage is gotten from text document using <code>XDrawPageSupplier</code>
92 * interface. Then shape (rectangle) is created and added to DrawPage
93 * obtained before, then returned as a test component.
95 @Override
96 public synchronized TestEnvironment createTestEnvironment(
97 TestParameters tParam, PrintWriter log ) throws StatusException {
98 XInterface oObj = null;
99 XDrawPage oDP = null;
100 XShapes oShapes = null;
102 log.println( "creating a test environment" );
103 log.println( "getting Drawpage" );
104 XDrawPageSupplier oDPS = UnoRuntime.queryInterface(XDrawPageSupplier.class, xTextDoc);
105 oDP = oDPS.getDrawPage();
107 log.println( "getting Shape" );
108 oShapes = UnoRuntime.queryInterface(XShapes.class, oDP);
109 oObj = SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle");
110 oShapes.add((XShape) oObj);
112 for ( int i = 0; i < 9; i++){
113 XInterface oShape = SOF.createShape(xTextDoc,
114 5000 + 100*i,3500,7500,5000,"Rectangle");
115 oShapes.add((XShape) oShape);
118 log.println( "creating a new environment for XShape object" );
119 TestEnvironment tEnv = new TestEnvironment( oObj );
121 return tEnv;
122 } // finish method getTestEnvironment
124 } // finish class SwXShape