merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / drawing / _DrawingDocumentDrawView.java
blob8a4490991567665df22149b855f5940cb285d5ca
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: _DrawingDocumentDrawView.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.MultiPropertyTest;
35 import com.sun.star.container.XNamed;
36 import com.sun.star.drawing.XDrawPage;
37 import com.sun.star.uno.UnoRuntime;
38 import util.ValueChanger;
40 /**
41 * Testing <code>com.sun.star.drawing.DrawingDocumentDrawView</code>
42 * service properties :
43 * <ul>
44 * <li><code> IsMasterPageMode</code></li>
45 * <li><code> IsLayerMode</code></li>
46 * </ul> <p>
47 * This test needs the following object relations :
48 * <ul>
49 * <li> <code>'DrawPage'</code> (of type <code>XDrawPage</code>):
50 * a draw page which will be current page. </li>
51 * <ul> <p>
52 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
53 * @see com.sun.star.drawing.DrawingDocumentDrawView
55 public class _DrawingDocumentDrawView extends MultiPropertyTest {
57 XDrawPage drawPage = null;
58 static String test_name = "For DrawingDocumentDrawView";
60 protected void before() {
61 drawPage = (XDrawPage)tEnv.getObjRelation("DrawPage");
62 XNamed xNamed = (XNamed)
63 UnoRuntime.queryInterface(XNamed.class, drawPage);
64 xNamed.setName(test_name);
67 /**
68 * Property tester which returns new <code>XDrawPage</code> object
69 * and compares draw pages.
71 protected PropertyTester CurPageTester = new PropertyTester() {
72 protected Object getNewValue(String propName, Object oldValue) {
73 return drawPage;
76 protected boolean compare(Object obj1, Object obj2) {
77 XNamed named1 = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj1);
78 XNamed named2 = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj2);
79 boolean res = false;
81 if (named1 != null && named2 != null) {
82 String name1 = named1.getName();
83 String name2 = named2.getName();
84 res = name1.equals(name2);
85 } else {
86 log.println("Interface XNamed not supported");
89 return res;
92 protected String toString(Object obj) {
93 XNamed named = (XNamed)UnoRuntime.queryInterface(XNamed.class, obj);
94 String res = (named == null) ? "null" : named.getName();
95 return res;
97 } ;
99 public void _CurrentPage() {
100 log.println("Testing with custom Property tester");
101 Object oldCurPage = null;
102 try {
103 oldCurPage = oObj.getPropertyValue("CurrentPage");
104 } catch(com.sun.star.lang.WrappedTargetException e) {
105 e.printStackTrace(log);
106 } catch(com.sun.star.beans.UnknownPropertyException e) {
107 e.printStackTrace(log);
110 testProperty("CurrentPage", CurPageTester);
112 try {
113 log.println("Back old current page");
114 oObj.setPropertyValue("CurrentPage", oldCurPage);
115 } catch(com.sun.star.lang.WrappedTargetException e) {
116 e.printStackTrace(log);
117 } catch(com.sun.star.beans.UnknownPropertyException e) {
118 e.printStackTrace(log);
119 } catch(com.sun.star.lang.IllegalArgumentException e) {
120 e.printStackTrace(log);
121 } catch(com.sun.star.beans.PropertyVetoException e) {
122 e.printStackTrace(log);
126 public void _IsMasterPageMode() {
127 testProperty("IsMasterPageMode");
128 try {
129 oObj.setPropertyValue("IsMasterPageMode", new Boolean(false));
130 } catch(com.sun.star.lang.WrappedTargetException e) {
131 e.printStackTrace(log);
132 } catch(com.sun.star.beans.UnknownPropertyException e) {
133 e.printStackTrace(log);
134 } catch(com.sun.star.lang.IllegalArgumentException e) {
135 e.printStackTrace(log);
136 } catch(com.sun.star.beans.PropertyVetoException e) {
137 e.printStackTrace(log);
141 public void _IsLayerMode() {
142 testProperty("IsLayerMode");
143 try {
144 oObj.setPropertyValue("IsLayerMode", new Boolean(false));
145 } catch(com.sun.star.lang.WrappedTargetException e) {
146 e.printStackTrace(log);
147 } catch(com.sun.star.beans.UnknownPropertyException e) {
148 e.printStackTrace(log);
149 } catch(com.sun.star.lang.IllegalArgumentException e) {
150 e.printStackTrace(log);
151 } catch(com.sun.star.beans.PropertyVetoException e) {
152 e.printStackTrace(log);
156 public void _ZoomType() {
157 Object oldValue=null;
158 Object newValue=null;
159 try {
160 oldValue = oObj.getPropertyValue("ZoomValue");
161 Object oldZoom = oObj.getPropertyValue("ZoomType");
162 Object newZoom = ValueChanger.changePValue(oldZoom);
163 oObj.setPropertyValue("ZoomType", newZoom);
164 newValue = oObj.getPropertyValue("ZoomValue");
165 } catch(com.sun.star.lang.WrappedTargetException e) {
166 e.printStackTrace(log);
167 } catch(com.sun.star.beans.UnknownPropertyException e) {
168 e.printStackTrace(log);
169 } catch(com.sun.star.lang.IllegalArgumentException e) {
170 e.printStackTrace(log);
171 } catch(com.sun.star.beans.PropertyVetoException e) {
172 e.printStackTrace(log);
174 log.println("oldZoomValue: "+oldValue);
175 log.println("newZoomValue: "+newValue);
176 tRes.tested("ZoomType",(!oldValue.equals(newValue)));