Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _XMasterPageTarget.java
bloba1716bbe5725b4378f2c50fad5a9b85dc76e294e
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 ifc.drawing;
21 import lib.MultiMethodTest;
23 import com.sun.star.drawing.XDrawPage;
24 import com.sun.star.drawing.XDrawPages;
25 import com.sun.star.drawing.XMasterPageTarget;
27 /**
28 * Testing <code>com.sun.star.drawing.XMasterPageTarget</code>
29 * interface methods :
30 * <ul>
31 * <li><code> getMasterPage()</code></li>
32 * <li><code> setMasterPage()</code></li>
33 * </ul> <p>
34 * This test needs the following object relations :
35 * <ul>
36 * <li> <code>'MasterPageSupplier'</code>
37 * (of type <code>XDrawPages</code>):
38 * the relation is used to create a new draw page. </li>
39 * <ul> <p>
40 * Test is <b> NOT </b> multithread compliant. <p>
41 * @see com.sun.star.drawing.XMasterPageTarget
43 public class _XMasterPageTarget extends MultiMethodTest{
45 public XMasterPageTarget oObj = null;
46 public XDrawPage DrawPage = null;
48 /**
49 * Gets the master page and stores. <p>
50 * Has <b> OK </b> status if the value returned is not null. <p>
52 public void _getMasterPage(){
53 boolean result = false;
54 log.println("get the MasterPage");
56 DrawPage = oObj.getMasterPage();
57 result = DrawPage != null ;
59 tRes.tested("getMasterPage()",result);
62 /**
63 * Gets the pages supplier from relation. Then a new page is created,
64 * inserted and set as master page.<p>
65 * Has <b> OK </b> status if the master page get is equal to page
66 * which was set. <p>
67 * The following method tests are to be completed successfully before :
68 * <ul>
69 * <li> <code> getMasterPage() </code> : to get old master page.</li>
70 * </ul>
72 public void _setMasterPage() {
73 requiredMethod("getMasterPage()") ;
75 boolean result = true;
76 XDrawPage oNewPage = null;
78 XDrawPages oPages = (XDrawPages) tEnv.getObjRelation("MasterPageSupplier");
79 log.println("inserting new MasterPage");
80 oNewPage = oPages.insertNewByIndex(oPages.getCount());
82 // save the old MasterPage
83 XDrawPage oOldPage = DrawPage;
85 // set the new Page as MasterPage
86 log.println("set the new MasterPage");
87 oObj.setMasterPage(oNewPage);
89 // get the new MasterPage
90 DrawPage = oObj.getMasterPage();
92 // test the different MasterPages
93 if (DrawPage.equals(oOldPage)) result = false;
95 tRes.tested("setMasterPage()",result);
98 } // end of XMasterPageTarget