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 .
18 package ifc
.configuration
.backend
;
20 import com
.sun
.star
.configuration
.backend
.TemplateIdentifier
;
21 import com
.sun
.star
.configuration
.backend
.XUpdateHandler
;
22 import com
.sun
.star
.uno
.Type
;
24 import lib
.MultiMethodTest
;
26 import util
.XLayerHandlerImpl
;
27 import util
.XLayerImpl
;
29 public class _XUpdateHandler
extends MultiMethodTest
{
30 public XUpdateHandler oObj
;
31 protected XLayerHandlerImpl xLayerHandler
= null;
34 public void before() {
35 xLayerHandler
= (XLayerHandlerImpl
) tEnv
.getObjRelation("LayerHandler");
38 xLayerHandler
.startLayer();
39 xLayerHandler
.overrideNode("org.openoffice.Setup", (short) 0,
41 xLayerHandler
.overrideNode("Office", (short) 0, false);
42 xLayerHandler
.overrideProperty("ooSetupInstCompleted", (short) 0,
43 new Type(String
.class),
45 xLayerHandler
.setPropertyValue(Boolean
.FALSE
);
46 xLayerHandler
.endProperty();
47 xLayerHandler
.overrideNode("Factories", (short) 0, false);
48 xLayerHandler
.addOrReplaceNode("com.sun.star.chart.ChartDocument",
50 xLayerHandler
.overrideProperty("ooSetupFactoryEmptyDocumentURL",
52 new Type(String
.class),
54 xLayerHandler
.setPropertyValue("private:factory/schart");
55 xLayerHandler
.endProperty();
56 xLayerHandler
.overrideProperty("ooSetupFactoryIcon", (short) 0,
57 new Type(java
.lang
.Long
.class),
59 xLayerHandler
.setPropertyValue(Integer
.valueOf(13));
60 xLayerHandler
.endProperty();
61 xLayerHandler
.overrideProperty("ooSetupFactoryShortName",
63 new Type(String
.class),
65 xLayerHandler
.setPropertyValue("schart");
66 xLayerHandler
.setPropertyValueForLocale("TemplateFile", "en-US");
67 xLayerHandler
.endProperty();
68 xLayerHandler
.overrideProperty("ooSetupFactoryTemplateFile",
70 new Type(String
.class),
72 xLayerHandler
.setPropertyValue("empty");
73 xLayerHandler
.endProperty();
74 xLayerHandler
.addProperty("ooSetupFactoryTemplateFile", (short) 0,
75 new Type(String
.class));
76 xLayerHandler
.addPropertyWithValue("ooSetupFactoryTemplateFile",
77 (short) 0, "TemplateFile");
78 xLayerHandler
.endNode();
80 xLayerHandler
.addOrReplaceNode("dropme", (short) 0);
81 xLayerHandler
.overrideProperty("anyway", (short) 0,
82 new Type(String
.class),
84 xLayerHandler
.setPropertyValue("nice");
85 xLayerHandler
.endProperty();
86 xLayerHandler
.dropNode("dropme");
87 xLayerHandler
.endNode();
89 xLayerHandler
.addOrReplaceNodeFromTemplate("FromTemplate",
90 new com
.sun
.star
.configuration
.backend
.TemplateIdentifier(
91 "org.openoffice.Setup",
94 xLayerHandler
.endNode();
96 xLayerHandler
.endNode();
97 xLayerHandler
.endNode();
98 xLayerHandler
.endNode();
99 xLayerHandler
.endLayer();
100 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
101 log
.println("Unexpected Exception " + e
);
102 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
103 log
.println("Unexpected Exception " + e
);
107 public void _addOrReplaceNode() {
108 requiredMethod("startUpdate()");
109 tRes
.tested("addOrReplaceNode()", true);
112 public void _addOrReplaceNodeFromTemplate() {
113 requiredMethod("startUpdate()");
114 tRes
.tested("addOrReplaceNodeFromTemplate()", true);
117 public void _addOrReplaceProperty() {
118 requiredMethod("startUpdate()");
119 tRes
.tested("addOrReplaceProperty()", true);
122 public void _addOrReplacePropertyWithValue() {
123 requiredMethod("startUpdate()");
124 tRes
.tested("addOrReplacePropertyWithValue()", true);
127 public void _endNode() {
128 requiredMethod("startUpdate()");
129 tRes
.tested("endNode()", true);
132 public void _endProperty() {
133 requiredMethod("startUpdate()");
134 tRes
.tested("endProperty()", true);
137 public void _endUpdate() {
138 requiredMethod("startUpdate()");
139 tRes
.tested("endUpdate()", true);
142 public void _modifyNode() {
143 requiredMethod("startUpdate()");
144 tRes
.tested("modifyNode()", true);
147 public void _modifyProperty() {
148 requiredMethod("startUpdate()");
149 tRes
.tested("modifyProperty()", true);
152 public void _removeNode() {
153 requiredMethod("startUpdate()");
154 tRes
.tested("removeNode()", true);
157 public void _removeProperty() {
158 requiredMethod("startUpdate()");
159 tRes
.tested("removeProperty()", true);
162 public void _resetProperty() {
163 requiredMethod("startUpdate()");
164 tRes
.tested("resetProperty()", true);
167 public void _resetPropertyValue() {
168 requiredMethod("startUpdate()");
169 tRes
.tested("resetPropertyValue()", true);
172 public void _resetPropertyValueForLocale() {
173 requiredMethod("startUpdate()");
174 tRes
.tested("resetPropertyValueForLocale()", true);
177 public void _setPropertyValue() {
178 requiredMethod("startUpdate()");
179 tRes
.tested("setPropertyValue()", true);
182 public void _setPropertyValueForLocale() {
183 requiredMethod("startUpdate()");
184 tRes
.tested("setPropertyValueForLocale()", true);
187 public void _startUpdate() {
191 XLayerImpl xLayer
= (XLayerImpl
) tEnv
.getObjRelation("Layer");
192 log
.println("Layer called (before): " + xLayer
.hasBeenCalled());
194 oObj
.addOrReplaceNode("whatever", (short) 0);
195 oObj
.addOrReplaceNodeFromTemplate("Office", (short) 0,
196 new TemplateIdentifier());
197 oObj
.addOrReplaceProperty("prop", (short) 0,
198 new Type(String
.class));
199 oObj
.addOrReplacePropertyWithValue("prop2", (short) 0, "this");
200 oObj
.modifyProperty("ooSetupFactoryIcon", (short) 0, (short) 0,
201 new Type(String
.class));
202 oObj
.resetPropertyValue();
203 oObj
.resetPropertyValueForLocale("en-US");
205 oObj
.modifyProperty("ooSetupFactoryEmptyDocumentURL", (short) 0,
206 (short) 0, new Type(String
.class));
207 oObj
.setPropertyValue("newValue");
208 oObj
.setPropertyValueForLocale("newValue-US", "de-DE");
210 oObj
.modifyNode("org.openoffice.Setup", (short) 0, (short) 0, true);
211 oObj
.removeNode("whatever");
212 oObj
.resetProperty("prop");
218 log
.println("Layer called (after): " + xLayer
.hasBeenCalled());
220 res
= xLayer
.hasBeenCalled();
221 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
222 log
.println("Unexpected exception " + e
.getMessage());
224 } catch (com
.sun
.star
.lang
.IllegalAccessException e
) {
225 log
.println("Unexpected exception " + e
.getMessage());
227 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
228 log
.println("Unexpected exception " + e
.getMessage());
232 tRes
.tested("startUpdate()", res
);