Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScShapeObj.java
blob335f2f848844a9804c917c4c06f3f4d3f503a646
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.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.DrawTools;
27 import util.SOfficeFactory;
29 import com.sun.star.drawing.XShape;
30 import com.sun.star.lang.XComponent;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
34 public class ScShapeObj extends TestCase {
36 static XComponent xSheetDoc;
38 @Override
39 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
40 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
41 log.println( "creating a sheetdoc" );
42 xSheetDoc = UnoRuntime.queryInterface(XComponent.class, SOF.createCalcDoc(null));
45 @Override
46 protected void cleanup( TestParameters tParam, PrintWriter log ) {
47 log.println( " disposing xSheetDoc " );
48 util.DesktopTools.closeDoc(xSheetDoc);
51 /**
52 * Creating a TestEnvironment for the interfaces to be tested.
53 * Creates an instance of the service
54 * <code>com.sun.star.drawing.EllipseShape</code> as tested component
55 * and adds it to the document.
56 * Object relations created :
57 * <ul>
58 * <li> <code>'Style1', 'Style2'</code> for
59 * {@link ifc.drawing._Shape} :
60 * two values of 'Style' property. The first is taken
61 * from the shape tested, the second from another
62 * shape added to the draw page. </li>
63 * <li> <code>'XTEXTINFO'</code> for
64 * {@link ifc.text._XText} :
65 * creator which can create instances of
66 * <code>com.sun.star.text.TextField.URL</code>
67 * service. </li>
68 * </ul>
70 @Override
71 protected TestEnvironment createTestEnvironment
72 (TestParameters tParam, PrintWriter log) {
74 XInterface oObj = null;
75 XShape oShape = null;
77 // creation of testobject here
78 // first we write what we are intend to do to log file
79 log.println( "creating a test environment" );
81 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
82 oShape = SOF.createShape(xSheetDoc,5000, 3500, 7500, 5000,"Rectangle");
83 DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add(oShape);
84 oObj = oShape ;
86 for (int i=0; i < 10; i++) {
87 DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add(
88 SOF.createShape(xSheetDoc,
89 5000, 3500, 7510 + 10 * i, 5010 + 10 * i, "Rectangle"));
92 // create test environment here
93 TestEnvironment tEnv = new TestEnvironment( oShape );
95 log.println("Implementation name: "+util.utils.getImplName(oObj));
96 tEnv.addObjRelation("DOCUMENT",xSheetDoc);
98 return tEnv;
99 } // finish method getTestEnvironment
101 } // finish class ScShapeObj