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 .
21 import lib
.MultiPropertyTest
;
23 import com
.sun
.star
.container
.XNamed
;
24 import com
.sun
.star
.drawing
.XDrawPage
;
25 import com
.sun
.star
.uno
.UnoRuntime
;
26 import util
.ValueChanger
;
29 * Testing <code>com.sun.star.drawing.DrawingDocumentDrawView</code>
30 * service properties :
32 * <li><code> IsMasterPageMode</code></li>
33 * <li><code> IsLayerMode</code></li>
35 * This test needs the following object relations :
37 * <li> <code>'DrawPage'</code> (of type <code>XDrawPage</code>):
38 * a draw page which will be current page. </li>
40 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
41 * @see com.sun.star.drawing.DrawingDocumentDrawView
43 public class _DrawingDocumentDrawView
extends MultiPropertyTest
{
45 XDrawPage drawPage
= null;
46 static String test_name
= "For DrawingDocumentDrawView";
49 protected void before() {
50 drawPage
= (XDrawPage
)tEnv
.getObjRelation("DrawPage");
51 XNamed xNamed
= UnoRuntime
.queryInterface(XNamed
.class, drawPage
);
52 xNamed
.setName(test_name
);
56 * Property tester which returns new <code>XDrawPage</code> object
57 * and compares draw pages.
59 protected PropertyTester CurPageTester
= new PropertyTester() {
61 protected Object
getNewValue(String propName
, Object oldValue
) {
66 protected boolean compare(Object obj1
, Object obj2
) {
67 XNamed named1
= UnoRuntime
.queryInterface(XNamed
.class, obj1
);
68 XNamed named2
= UnoRuntime
.queryInterface(XNamed
.class, obj2
);
71 if (named1
!= null && named2
!= null) {
72 String name1
= named1
.getName();
73 String name2
= named2
.getName();
74 res
= name1
.equals(name2
);
76 log
.println("Interface XNamed not supported");
83 protected String
toString(Object obj
) {
84 XNamed named
= UnoRuntime
.queryInterface(XNamed
.class, obj
);
85 String res
= (named
== null) ?
"null" : named
.getName();
90 public void _CurrentPage() {
91 log
.println("Testing with custom Property tester");
92 Object oldCurPage
= null;
94 oldCurPage
= oObj
.getPropertyValue("CurrentPage");
95 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
96 e
.printStackTrace(log
);
97 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
98 e
.printStackTrace(log
);
101 testProperty("CurrentPage", CurPageTester
);
104 log
.println("Back old current page");
105 oObj
.setPropertyValue("CurrentPage", oldCurPage
);
106 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
107 e
.printStackTrace(log
);
108 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
109 e
.printStackTrace(log
);
110 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
111 e
.printStackTrace(log
);
112 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
113 e
.printStackTrace(log
);
117 public void _IsMasterPageMode() {
118 testProperty("IsMasterPageMode");
120 oObj
.setPropertyValue("IsMasterPageMode", Boolean
.FALSE
);
121 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
122 e
.printStackTrace(log
);
123 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
124 e
.printStackTrace(log
);
125 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
126 e
.printStackTrace(log
);
127 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
128 e
.printStackTrace(log
);
132 public void _IsLayerMode() {
133 testProperty("IsLayerMode");
135 oObj
.setPropertyValue("IsLayerMode", Boolean
.FALSE
);
136 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
137 e
.printStackTrace(log
);
138 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
139 e
.printStackTrace(log
);
140 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
141 e
.printStackTrace(log
);
142 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
143 e
.printStackTrace(log
);
147 public void _ZoomType() {
148 Object oldValue
=null;
149 Object newValue
=null;
151 oldValue
= oObj
.getPropertyValue("ZoomValue");
152 Object oldZoom
= oObj
.getPropertyValue("ZoomType");
153 Object newZoom
= ValueChanger
.changePValue(oldZoom
);
154 oObj
.setPropertyValue("ZoomType", newZoom
);
155 newValue
= oObj
.getPropertyValue("ZoomValue");
156 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
157 e
.printStackTrace(log
);
158 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
159 e
.printStackTrace(log
);
160 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
161 e
.printStackTrace(log
);
162 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
163 e
.printStackTrace(log
);
165 log
.println("oldZoomValue: "+oldValue
);
166 log
.println("newZoomValue: "+newValue
);
167 if (oldValue
!= null)
168 tRes
.tested("ZoomType",(!oldValue
.equals(newValue
)));