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 ************************************************************************/
30 import lib
.MultiPropertyTest
;
32 import com
.sun
.star
.container
.XNamed
;
33 import com
.sun
.star
.drawing
.XDrawPage
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
35 import util
.ValueChanger
;
38 * Testing <code>com.sun.star.drawing.DrawingDocumentDrawView</code>
39 * service properties :
41 * <li><code> IsMasterPageMode</code></li>
42 * <li><code> IsLayerMode</code></li>
44 * This test needs the following object relations :
46 * <li> <code>'DrawPage'</code> (of type <code>XDrawPage</code>):
47 * a draw page which will be current page. </li>
49 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
50 * @see com.sun.star.drawing.DrawingDocumentDrawView
52 public class _DrawingDocumentDrawView
extends MultiPropertyTest
{
54 XDrawPage drawPage
= null;
55 static String test_name
= "For DrawingDocumentDrawView";
57 protected void before() {
58 drawPage
= (XDrawPage
)tEnv
.getObjRelation("DrawPage");
59 XNamed xNamed
= (XNamed
)
60 UnoRuntime
.queryInterface(XNamed
.class, drawPage
);
61 xNamed
.setName(test_name
);
65 * Property tester which returns new <code>XDrawPage</code> object
66 * and compares draw pages.
68 protected PropertyTester CurPageTester
= new PropertyTester() {
69 protected Object
getNewValue(String propName
, Object oldValue
) {
73 protected boolean compare(Object obj1
, Object obj2
) {
74 XNamed named1
= (XNamed
)UnoRuntime
.queryInterface(XNamed
.class, obj1
);
75 XNamed named2
= (XNamed
)UnoRuntime
.queryInterface(XNamed
.class, obj2
);
78 if (named1
!= null && named2
!= null) {
79 String name1
= named1
.getName();
80 String name2
= named2
.getName();
81 res
= name1
.equals(name2
);
83 log
.println("Interface XNamed not supported");
89 protected String
toString(Object obj
) {
90 XNamed named
= (XNamed
)UnoRuntime
.queryInterface(XNamed
.class, obj
);
91 String res
= (named
== null) ?
"null" : named
.getName();
96 public void _CurrentPage() {
97 log
.println("Testing with custom Property tester");
98 Object oldCurPage
= null;
100 oldCurPage
= oObj
.getPropertyValue("CurrentPage");
101 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
102 e
.printStackTrace(log
);
103 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
104 e
.printStackTrace(log
);
107 testProperty("CurrentPage", CurPageTester
);
110 log
.println("Back old current page");
111 oObj
.setPropertyValue("CurrentPage", oldCurPage
);
112 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
113 e
.printStackTrace(log
);
114 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
115 e
.printStackTrace(log
);
116 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
117 e
.printStackTrace(log
);
118 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
119 e
.printStackTrace(log
);
123 public void _IsMasterPageMode() {
124 testProperty("IsMasterPageMode");
126 oObj
.setPropertyValue("IsMasterPageMode", new Boolean(false));
127 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
128 e
.printStackTrace(log
);
129 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
130 e
.printStackTrace(log
);
131 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
132 e
.printStackTrace(log
);
133 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
134 e
.printStackTrace(log
);
138 public void _IsLayerMode() {
139 testProperty("IsLayerMode");
141 oObj
.setPropertyValue("IsLayerMode", new Boolean(false));
142 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
143 e
.printStackTrace(log
);
144 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
145 e
.printStackTrace(log
);
146 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
147 e
.printStackTrace(log
);
148 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
149 e
.printStackTrace(log
);
153 public void _ZoomType() {
154 Object oldValue
=null;
155 Object newValue
=null;
157 oldValue
= oObj
.getPropertyValue("ZoomValue");
158 Object oldZoom
= oObj
.getPropertyValue("ZoomType");
159 Object newZoom
= ValueChanger
.changePValue(oldZoom
);
160 oObj
.setPropertyValue("ZoomType", newZoom
);
161 newValue
= oObj
.getPropertyValue("ZoomValue");
162 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
163 e
.printStackTrace(log
);
164 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
165 e
.printStackTrace(log
);
166 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
167 e
.printStackTrace(log
);
168 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
169 e
.printStackTrace(log
);
171 log
.println("oldZoomValue: "+oldValue
);
172 log
.println("newZoomValue: "+newValue
);
173 tRes
.tested("ZoomType",(!oldValue
.equals(newValue
)));