Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScShapeObj.java
blobf1521246323d40bdd966d4f49be33f23baf71f4e
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._sc;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.DrawTools;
28 import util.SOfficeFactory;
30 import com.sun.star.drawing.XShape;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.uno.XInterface;
35 public class ScShapeObj extends TestCase {
37 static XComponent xSheetDoc;
39 @Override
40 protected void initialize( TestParameters tParam, PrintWriter log ) {
42 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
44 try {
45 log.println( "creating a sheetdoc" );
46 xSheetDoc = UnoRuntime.queryInterface(XComponent.class, SOF.createCalcDoc(null));
47 } catch ( com.sun.star.uno.Exception e ) {
48 // Some exception occurs.FAILED
49 e.printStackTrace( log );
50 throw new StatusException( "Couldn't create document", e );
54 @Override
55 protected void cleanup( TestParameters tParam, PrintWriter log ) {
56 log.println( " disposing xSheetDoc " );
57 util.DesktopTools.closeDoc(xSheetDoc);
60 /**
61 * Creating a Testenvironment for the interfaces to be tested.
62 * Creates an instance of the service
63 * <code>com.sun.star.drawing.EllipseShape</code> as tested component
64 * and adds it to the document.
65 * Object relations created :
66 * <ul>
67 * <li> <code>'Style1', 'Style2'</code> for
68 * {@link ifc.drawing._Shape} :
69 * two values of 'Style' property. The first is taken
70 * from the shape tested, the second from another
71 * shape added to the draw page. </li>
72 * <li> <code>'XTEXTINFO'</code> for
73 * {@link ifc.text._XText} :
74 * creator which can create instnaces of
75 * <code>com.sun.star.text.TextField.URL</code>
76 * service. </li>
77 * </ul>
79 @Override
80 protected TestEnvironment createTestEnvironment
81 (TestParameters tParam, PrintWriter log) {
83 XInterface oObj = null;
84 XShape oShape = null;
86 // creation of testobject here
87 // first we write what we are intend to do to log file
88 log.println( "creating a test environment" );
90 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
91 oShape = SOF.createShape(xSheetDoc,5000, 3500, 7500, 5000,"Rectangle");
92 DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add(oShape);
93 oObj = oShape ;
95 for (int i=0; i < 10; i++) {
96 DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add(
97 SOF.createShape(xSheetDoc,
98 5000, 3500, 7510 + 10 * i, 5010 + 10 * i, "Rectangle"));
101 // create test environment here
102 TestEnvironment tEnv = new TestEnvironment( oShape );
104 log.println("Implementation name: "+util.utils.getImplName(oObj));
105 tEnv.addObjRelation("DOCUMENT",xSheetDoc);
107 return tEnv;
108 } // finish method getTestEnvironment
110 } // finish class ScShapeObj