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