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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.DrawTools
;
28 import util
.InstCreator
;
29 import util
.SOfficeFactory
;
32 import com
.sun
.star
.drawing
.XShape
;
33 import com
.sun
.star
.drawing
.XShapes
;
34 import com
.sun
.star
.lang
.XComponent
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
38 public class SvxShapeCollection
extends TestCase
{
40 static XComponent xDrawDoc
;
43 * in general this method creates a testdocument
45 * @param tParam class which contains additional test parameters
46 * @param log class to log the test state and result
54 protected void initialize( TestParameters tParam
, PrintWriter log
) {
57 log
.println( "creating a drawdoc" );
58 xDrawDoc
= DrawTools
.createDrawDoc(tParam
.getMSF());
59 } catch ( Exception e
) {
60 // Some exception occurs.FAILED
61 e
.printStackTrace( log
);
62 throw new StatusException( "Couldn't create document", e
);
67 * in general this method disposes the testenvironment and document
69 * @param tParam class which contains additional test parameters
70 * @param log class to log the test state and result
78 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
79 log
.println( " disposing xDrawDoc " );
80 util
.DesktopTools
.closeDoc(xDrawDoc
);
85 * creating a Testenvironment for the interfaces to be tested
87 * @param tParam class which contains additional test parameters
88 * @param log class to log the test state and result
90 * @return Status class
96 protected TestEnvironment createTestEnvironment
97 (TestParameters tParam
, PrintWriter log
) {
99 XInterface oObj
= null;
100 XShape oShape
= null;
102 // creation of testobject here
103 // first we write what we are intend to do to log file
104 log
.println( "creating a test environment" );
107 // adding some shapes for testing.
108 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
109 Object col
= tParam
.getMSF().createInstance
110 ("com.sun.star.drawing.ShapeCollection");
111 XShapes shapes
= UnoRuntime
.queryInterface
114 oShape
= SOF
.createShape(xDrawDoc
,3000,4500,15000,1000,"Ellipse");
115 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
118 oShape
= SOF
.createShape(xDrawDoc
,5000,3500,7500,5000,"Rectangle");
119 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
) ;
122 oObj
= (XInterface
) col
;
125 catch (Exception e
) {
126 log
.println("Couldn't create insance");
127 e
.printStackTrace(log
);
130 // test environment creation
132 TestEnvironment tEnv
= new TestEnvironment(oObj
);
133 System
.out
.println("IName: "+util
.utils
.getImplName(oObj
));
134 ShapeDsc sDsc
= new ShapeDsc(5000,3500,7500,10000,"Line");
135 tEnv
.addObjRelation("Shape", new InstCreator(xDrawDoc
, sDsc
)) ;
138 } // finish method getTestEnvironment
140 } // finish class SvxShapeCollection