merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / configuration / backend / _XUpdateHandler.java
blob60ebbee1908bec0d202fb99269ee27a5aadd0581
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: _XUpdateHandler.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
30 package ifc.configuration.backend;
32 import com.sun.star.configuration.backend.TemplateIdentifier;
33 import com.sun.star.configuration.backend.XUpdateHandler;
34 import com.sun.star.uno.Type;
36 import lib.MultiMethodTest;
38 import util.XLayerHandlerImpl;
39 import util.XLayerImpl;
42 /**
44 * @author sw93809
46 public class _XUpdateHandler extends MultiMethodTest {
47 public XUpdateHandler oObj;
48 protected XLayerHandlerImpl xLayerHandler = null;
50 public void before() {
51 xLayerHandler = (XLayerHandlerImpl) tEnv.getObjRelation("LayerHandler");
53 try {
54 xLayerHandler.startLayer();
55 xLayerHandler.overrideNode("org.openoffice.Setup", (short) 0,
56 false);
57 xLayerHandler.overrideNode("Office", (short) 0, false);
58 xLayerHandler.overrideProperty("ooSetupInstCompleted", (short) 0,
59 new Type(java.lang.String.class),
60 false);
61 xLayerHandler.setPropertyValue(new Boolean(false));
62 xLayerHandler.endProperty();
63 xLayerHandler.overrideProperty("ooSetupShowIntro", (short) 0,
64 new Type(java.lang.String.class),
65 false);
66 xLayerHandler.setPropertyValue(new Boolean(true));
67 xLayerHandler.endProperty();
68 xLayerHandler.overrideProperty("ooSetupLocales", (short) 0,
69 new Type(java.lang.String.class),
70 false);
71 xLayerHandler.setPropertyValue("en-US");
72 xLayerHandler.endProperty();
73 xLayerHandler.overrideNode("Factories", (short) 0, false);
74 xLayerHandler.addOrReplaceNode("com.sun.star.chart.ChartDocument",
75 (short) 0);
76 xLayerHandler.overrideProperty("ooSetupFactoryEmptyDocumentURL",
77 (short) 0,
78 new Type(java.lang.String.class),
79 false);
80 xLayerHandler.setPropertyValue("private:factory/schart");
81 xLayerHandler.endProperty();
82 xLayerHandler.overrideProperty("ooSetupFactoryIcon", (short) 0,
83 new Type(java.lang.Long.class),
84 false);
85 xLayerHandler.setPropertyValue(new Integer(13));
86 xLayerHandler.endProperty();
87 xLayerHandler.overrideProperty("ooSetupFactoryShortName",
88 (short) 0,
89 new Type(java.lang.String.class),
90 false);
91 xLayerHandler.setPropertyValue("schart");
92 xLayerHandler.setPropertyValueForLocale("TemplateFile", "en-US");
93 xLayerHandler.endProperty();
94 xLayerHandler.overrideProperty("ooSetupFactoryTemplateFile",
95 (short) 0,
96 new Type(java.lang.String.class),
97 false);
98 xLayerHandler.setPropertyValue("empty");
99 xLayerHandler.endProperty();
100 xLayerHandler.addProperty("ooSetupFactoryTemplateFile", (short) 0,
101 new Type(java.lang.String.class));
102 xLayerHandler.addPropertyWithValue("ooSetupFactoryTemplateFile",
103 (short) 0, "TemplateFile");
104 xLayerHandler.endNode();
106 xLayerHandler.addOrReplaceNode("dropme", (short) 0);
107 xLayerHandler.overrideProperty("anyway", (short) 0,
108 new Type(java.lang.String.class),
109 false);
110 xLayerHandler.setPropertyValue("nice");
111 xLayerHandler.endProperty();
112 xLayerHandler.dropNode("dropme");
113 xLayerHandler.endNode();
115 xLayerHandler.addOrReplaceNodeFromTemplate("FromTemplate",
116 new com.sun.star.configuration.backend.TemplateIdentifier(
117 "org.openoffice.Setup",
118 "Setup"),
119 (short) 0);
120 xLayerHandler.endNode();
122 xLayerHandler.endNode();
123 xLayerHandler.endNode();
124 xLayerHandler.endNode();
125 xLayerHandler.endLayer();
126 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
127 log.println("Unexpected Exception " + e);
128 } catch (com.sun.star.lang.WrappedTargetException e) {
129 log.println("Unexpected Exception " + e);
130 } catch (com.sun.star.uno.Exception e) {
131 log.println("Unexpected Exception " + e);
135 public void _addOrReplaceNode() {
136 requiredMethod("startUpdate()");
137 tRes.tested("addOrReplaceNode()", true);
140 public void _addOrReplaceNodeFromTemplate() {
141 requiredMethod("startUpdate()");
142 tRes.tested("addOrReplaceNodeFromTemplate()", true);
145 public void _addOrReplaceProperty() {
146 requiredMethod("startUpdate()");
147 tRes.tested("addOrReplaceProperty()", true);
150 public void _addOrReplacePropertyWithValue() {
151 requiredMethod("startUpdate()");
152 tRes.tested("addOrReplacePropertyWithValue()", true);
155 public void _endNode() {
156 requiredMethod("startUpdate()");
157 tRes.tested("endNode()", true);
160 public void _endProperty() {
161 requiredMethod("startUpdate()");
162 tRes.tested("endProperty()", true);
165 public void _endUpdate() {
166 requiredMethod("startUpdate()");
167 tRes.tested("endUpdate()", true);
170 public void _modifyNode() {
171 requiredMethod("startUpdate()");
172 tRes.tested("modifyNode()", true);
175 public void _modifyProperty() {
176 requiredMethod("startUpdate()");
177 tRes.tested("modifyProperty()", true);
180 public void _removeNode() {
181 requiredMethod("startUpdate()");
182 tRes.tested("removeNode()", true);
185 public void _removeProperty() {
186 requiredMethod("startUpdate()");
187 tRes.tested("removeProperty()", true);
190 public void _resetProperty() {
191 requiredMethod("startUpdate()");
192 tRes.tested("resetProperty()", true);
195 public void _resetPropertyValue() {
196 requiredMethod("startUpdate()");
197 tRes.tested("resetPropertyValue()", true);
200 public void _resetPropertyValueForLocale() {
201 requiredMethod("startUpdate()");
202 tRes.tested("resetPropertyValueForLocale()", true);
205 public void _setPropertyValue() {
206 requiredMethod("startUpdate()");
207 tRes.tested("setPropertyValue()", true);
210 public void _setPropertyValueForLocale() {
211 requiredMethod("startUpdate()");
212 tRes.tested("setPropertyValueForLocale()", true);
215 public void _startUpdate() {
216 boolean res = true;
218 try {
219 XLayerImpl xLayer = (XLayerImpl) tEnv.getObjRelation("Layer");
220 log.println("Layer called (before): " + xLayer.hasBeenCalled());
221 oObj.startUpdate();
222 oObj.addOrReplaceNode("whatever", (short) 0);
223 oObj.addOrReplaceNodeFromTemplate("Office", (short) 0,
224 new TemplateIdentifier());
225 oObj.addOrReplaceProperty("prop", (short) 0,
226 new Type(java.lang.String.class));
227 oObj.addOrReplacePropertyWithValue("prop2", (short) 0, "this");
228 oObj.modifyProperty("ooSetupFactoryIcon", (short) 0, (short) 0,
229 new Type(java.lang.String.class));
230 oObj.resetPropertyValue();
231 oObj.resetPropertyValueForLocale("en-US");
232 oObj.endProperty();
233 oObj.modifyProperty("ooSetupFactoryEmptyDocumentURL", (short) 0,
234 (short) 0, new Type(java.lang.String.class));
235 oObj.setPropertyValue("newValue");
236 oObj.setPropertyValueForLocale("newValue-US", "de-DE");
237 oObj.endProperty();
238 oObj.removeProperty("ooSetupShowIntro");
239 oObj.modifyNode("org.openoffice.Setup", (short) 0, (short) 0, true);
240 oObj.removeNode("whatever");
241 oObj.resetProperty("prop");
242 oObj.endNode();
243 oObj.endNode();
244 oObj.endNode();
245 oObj.endUpdate();
247 log.println("Layer called (after): " + xLayer.hasBeenCalled());
249 res = xLayer.hasBeenCalled();
250 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
251 log.println("Unexpected exception " + e.getMessage());
252 res = false;
253 } catch (com.sun.star.lang.IllegalAccessException e) {
254 log.println("Unexpected exception " + e.getMessage());
255 res = false;
256 } catch (com.sun.star.lang.WrappedTargetException e) {
257 log.println("Unexpected exception " + e.getMessage());
258 res = false;
261 tRes.tested("startUpdate()", res);