Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _XDrawView.java
blob66f9bd1400b999207ce61365a4727750528a2990
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.drawing;
30 import lib.MultiMethodTest;
32 import com.sun.star.drawing.XDrawPage;
33 import com.sun.star.drawing.XDrawPages;
34 import com.sun.star.drawing.XDrawView;
35 import com.sun.star.uno.AnyConverter;
36 import com.sun.star.uno.Type;
38 /**
39 * Testing <code>com.sun.star.drawing.XDrawView</code>
40 * interface methods :
41 * <ul>
42 * <li><code> setCurrentPage()</code></li>
43 * <li><code> getCurrentPage()</code></li>
44 * </ul> <p>
45 * This test needs the following object relations :
46 * <ul>
47 * <li> <code>'Pages'</code> (of type <code>XDrawPages</code>):
48 * needed to have the access to pages collection.</li>
49 * <ul> <p>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.drawing.XDrawView
53 public class _XDrawView extends MultiMethodTest {
55 public XDrawView oObj = null;
56 public XDrawPage the_page = null;
58 /**
59 * This methods gets the current DrawPage.<p>
60 * Has <b> OK </b> status if the returned DrawPage
61 * isn't empty.
63 public void _getCurrentPage(){
64 the_page = oObj.getCurrentPage();
65 tRes.tested("getCurrentPage()",the_page != null);
66 } // end getCurrentPage
68 /**
69 * This methods sets the current DrawPage<br>
70 * First a new DrawPage is inserted in the document.
71 * Then this DrawPage is set as current Page.
72 * Has <b> OK </b> status if the getCurrentPage() method returns
73 * the DrawPage that was previously set.
74 * @see ifc.drawing._XDrawPages
75 * The following method tests are to be completed successfully before :
76 * <ul>
77 * <li> <code> getCurrentPage() </code> </li>
78 * </ul>
80 public void _setCurrentPage(){
81 requiredMethod("getCurrentPage()");
82 try {
83 XDrawPages the_pages = (XDrawPages) tEnv.getObjRelation("Pages");
84 the_pages.insertNewByIndex(0);
85 XDrawPage newPage = (XDrawPage) AnyConverter.toObject(
86 new Type(XDrawPage.class),the_pages.getByIndex(1));
87 oObj.setCurrentPage(newPage);
88 XDrawPage getting = oObj.getCurrentPage();
89 boolean eq = newPage.equals(getting);
90 if (!eq) {
91 log.println("Getting: "+getting.hasElements());
92 log.println("Expected: "+newPage.hasElements());
94 //back to the previous page
95 oObj.setCurrentPage(the_page);
96 tRes.tested("setCurrentPage()",eq);
97 } catch (com.sun.star.lang.WrappedTargetException ex) {
98 log.println("Exception occurred while checking 'setCurrentPage()'");
99 ex.printStackTrace(log);
100 tRes.tested("setCurrentPage()",false);
101 } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
102 log.println("Exception occurred while checking 'setCurrentPage()'");
103 ex.printStackTrace(log);
104 tRes.tested("setCurrentPage()",false);
105 } catch (com.sun.star.lang.IllegalArgumentException ex) {
106 log.println("Exception occurred while checking 'setCurrentPage()'");
107 ex.printStackTrace(log);
108 tRes.tested("setCurrentPage()",false);
110 } // end setCurrentPage
112 } // end DrawView