bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _DrawingDocumentDrawView.java
blob86d546cdcf0e3c62cf8241ad4d06dd1883f91149
1 /*
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 .
19 package ifc.drawing;
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;
28 /**
29 * Testing <code>com.sun.star.drawing.DrawingDocumentDrawView</code>
30 * service properties :
31 * <ul>
32 * <li><code> IsMasterPageMode</code></li>
33 * <li><code> IsLayerMode</code></li>
34 * </ul> <p>
35 * This test needs the following object relations :
36 * <ul>
37 * <li> <code>'DrawPage'</code> (of type <code>XDrawPage</code>):
38 * a draw page which will be current page. </li>
39 * <ul> <p>
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";
48 protected void before() {
49 drawPage = (XDrawPage)tEnv.getObjRelation("DrawPage");
50 XNamed xNamed = UnoRuntime.queryInterface(XNamed.class, drawPage);
51 xNamed.setName(test_name);
54 /**
55 * Property tester which returns new <code>XDrawPage</code> object
56 * and compares draw pages.
58 protected PropertyTester CurPageTester = new PropertyTester() {
59 protected Object getNewValue(String propName, Object oldValue) {
60 return drawPage;
63 protected boolean compare(Object obj1, Object obj2) {
64 XNamed named1 = UnoRuntime.queryInterface(XNamed.class, obj1);
65 XNamed named2 = UnoRuntime.queryInterface(XNamed.class, obj2);
66 boolean res = false;
68 if (named1 != null && named2 != null) {
69 String name1 = named1.getName();
70 String name2 = named2.getName();
71 res = name1.equals(name2);
72 } else {
73 log.println("Interface XNamed not supported");
76 return res;
79 protected String toString(Object obj) {
80 XNamed named = UnoRuntime.queryInterface(XNamed.class, obj);
81 String res = (named == null) ? "null" : named.getName();
82 return res;
84 } ;
86 public void _CurrentPage() {
87 log.println("Testing with custom Property tester");
88 Object oldCurPage = null;
89 try {
90 oldCurPage = oObj.getPropertyValue("CurrentPage");
91 } catch(com.sun.star.lang.WrappedTargetException e) {
92 e.printStackTrace(log);
93 } catch(com.sun.star.beans.UnknownPropertyException e) {
94 e.printStackTrace(log);
97 testProperty("CurrentPage", CurPageTester);
99 try {
100 log.println("Back old current page");
101 oObj.setPropertyValue("CurrentPage", oldCurPage);
102 } catch(com.sun.star.lang.WrappedTargetException e) {
103 e.printStackTrace(log);
104 } catch(com.sun.star.beans.UnknownPropertyException e) {
105 e.printStackTrace(log);
106 } catch(com.sun.star.lang.IllegalArgumentException e) {
107 e.printStackTrace(log);
108 } catch(com.sun.star.beans.PropertyVetoException e) {
109 e.printStackTrace(log);
113 public void _IsMasterPageMode() {
114 testProperty("IsMasterPageMode");
115 try {
116 oObj.setPropertyValue("IsMasterPageMode", new Boolean(false));
117 } catch(com.sun.star.lang.WrappedTargetException e) {
118 e.printStackTrace(log);
119 } catch(com.sun.star.beans.UnknownPropertyException e) {
120 e.printStackTrace(log);
121 } catch(com.sun.star.lang.IllegalArgumentException e) {
122 e.printStackTrace(log);
123 } catch(com.sun.star.beans.PropertyVetoException e) {
124 e.printStackTrace(log);
128 public void _IsLayerMode() {
129 testProperty("IsLayerMode");
130 try {
131 oObj.setPropertyValue("IsLayerMode", new Boolean(false));
132 } catch(com.sun.star.lang.WrappedTargetException e) {
133 e.printStackTrace(log);
134 } catch(com.sun.star.beans.UnknownPropertyException e) {
135 e.printStackTrace(log);
136 } catch(com.sun.star.lang.IllegalArgumentException e) {
137 e.printStackTrace(log);
138 } catch(com.sun.star.beans.PropertyVetoException e) {
139 e.printStackTrace(log);
143 public void _ZoomType() {
144 Object oldValue=null;
145 Object newValue=null;
146 try {
147 oldValue = oObj.getPropertyValue("ZoomValue");
148 Object oldZoom = oObj.getPropertyValue("ZoomType");
149 Object newZoom = ValueChanger.changePValue(oldZoom);
150 oObj.setPropertyValue("ZoomType", newZoom);
151 newValue = oObj.getPropertyValue("ZoomValue");
152 } catch(com.sun.star.lang.WrappedTargetException e) {
153 e.printStackTrace(log);
154 } catch(com.sun.star.beans.UnknownPropertyException e) {
155 e.printStackTrace(log);
156 } catch(com.sun.star.lang.IllegalArgumentException e) {
157 e.printStackTrace(log);
158 } catch(com.sun.star.beans.PropertyVetoException e) {
159 e.printStackTrace(log);
161 log.println("oldZoomValue: "+oldValue);
162 log.println("newZoomValue: "+newValue);
163 tRes.tested("ZoomType",(!oldValue.equals(newValue)));