Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / drawing / _ShapeDescriptor.java
blob1e0712cc0ab2c36823c7e8e7281867a4a2910423
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 ************************************************************************/
28 package ifc.drawing;
30 import lib.MultiMethodTest;
31 import util.ValueChanger;
33 import com.sun.star.beans.XPropertySet;
34 import com.sun.star.style.XStyle;
35 import com.sun.star.uno.UnoRuntime;
38 public class _ShapeDescriptor extends MultiMethodTest {
40 public XPropertySet oObj = null; // oObj filled by MultiMethodTest
41 public boolean ro = false;
43 public void _LayerID() {
44 com.sun.star.lang.XServiceInfo xInfo = (com.sun.star.lang.XServiceInfo)
45 UnoRuntime.queryInterface
46 (com.sun.star.lang.XServiceInfo.class, oObj);
47 if ( ! xInfo.supportsService("com.sun.star.drawing.ShapeDescriptor")) {
48 log.println("Service not available !!!!!!!!!!!!!");
49 tRes.tested("Supported", false);
51 ro = true;
52 changeProp("LayerID");
53 ro = false;
55 public void _LayerName() {
56 ro = true;
57 changeProp("LayerName");
58 ro = false;
60 public void _MoveProtect() {
61 changeProp("MoveProtect");
63 public void _Name() {
64 changeProp("Name");
66 public void _Printable() {
67 changeProp("Printable");
69 public void _SizeProtect() {
70 changeProp("SizeProtect");
72 public void _Style() {
73 changeProp("Style");
76 public void _Transformation() {
77 changeProp("Transformation");
80 public void changeProp(String name) {
82 Object gValue = null;
83 Object sValue = null;
84 Object ValueToSet = null;
87 try {
88 //waitForAllThreads();
89 gValue = oObj.getPropertyValue(name);
90 //waitForAllThreads();
91 if (!ro) {
92 ValueToSet = ValueChanger.changePValue(gValue);
93 if ( name.equals("Style") ) {
94 ValueToSet = newStyle(gValue);
96 //waitForAllThreads();
97 oObj.setPropertyValue(name,ValueToSet);
98 sValue = oObj.getPropertyValue(name);
101 //check get-set methods
102 if (gValue.equals(sValue)) {
103 log.println("Value for '"+name+"' hasn't changed");
104 tRes.tested(name, false);
105 } else {
106 log.println("Property '"+name+"' OK");
107 tRes.tested(name, true);
109 } catch (com.sun.star.beans.UnknownPropertyException ex) {
110 if (isOptional(name)) {
111 log.println("Property '"+name+
112 "' is optional and not supported");
113 tRes.tested(name,true);
114 } else {
115 log.println("Exception occurred while testing property '" +
116 name + "'");
117 ex.printStackTrace(log);
118 tRes.tested(name, false);
121 catch (Exception e) {
122 log.println("Exception occurred while testing property '" +
123 name + "'");
124 e.printStackTrace(log);
125 tRes.tested(name, false);
129 }// end of changeProp
131 public XStyle newStyle(Object oldStyle) {
132 XStyle Style1 = (XStyle) tEnv.getObjRelation("Style1");
133 XStyle Style2 = (XStyle) tEnv.getObjRelation("Style2");
134 XStyle back = null;
135 if ( (Style1!=null) && (Style2!=null) ) {
136 if ( ((XStyle) oldStyle).equals(Style1) ) {
137 back = Style2;
138 } else {
139 back = Style1;
142 return back;