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
.XLayer
;
21 import com
.sun
.star
.configuration
.backend
.XLayerHandler
;
22 import com
.sun
.star
.io
.XActiveDataSink
;
23 import com
.sun
.star
.io
.XInputStream
;
24 import com
.sun
.star
.ucb
.XSimpleFileAccess
;
25 import com
.sun
.star
.uno
.Type
;
26 import com
.sun
.star
.uno
.UnoRuntime
;
28 import lib
.MultiMethodTest
;
30 import util
.XLayerHandlerImpl
;
33 public class _XLayerHandler
extends MultiMethodTest
{
34 public XLayerHandler oObj
= null;
36 /** this method contains the logic for all test methods
37 * the others will be passed OK if this one is
39 public void _endLayer() {
44 oObj
.overrideNode("org.openoffice.Setup", (short) 0, false);
45 oObj
.overrideNode("Office", (short) 0, false);
46 oObj
.overrideProperty("ooSetupInstCompleted", (short) 0,
47 new Type(String
.class), false);
48 oObj
.setPropertyValue(Boolean
.FALSE
);
50 oObj
.overrideNode("Factories", (short) 0, false);
51 oObj
.addOrReplaceNode("com.sun.star.chart.ChartDocument",
53 oObj
.overrideProperty("ooSetupFactoryEmptyDocumentURL", (short) 0,
54 new Type(String
.class), false);
55 oObj
.setPropertyValue("private:factory/schart");
57 oObj
.overrideProperty("ooSetupFactoryIcon", (short) 0,
58 new Type(java
.lang
.Long
.class), false);
59 oObj
.setPropertyValue(Integer
.valueOf(13));
61 oObj
.overrideProperty("ooSetupFactoryShortName", (short) 0,
62 new Type(String
.class), false);
63 oObj
.setPropertyValue("schart");
64 oObj
.setPropertyValueForLocale("TemplateFile", "en-US");
66 oObj
.overrideProperty("ooSetupFactoryTemplateFile", (short) 0,
67 new Type(String
.class), false);
68 oObj
.setPropertyValue("empty");
70 oObj
.addProperty("ooSetupFactoryTemplateFile", (short) 0,
71 new Type(String
.class));
72 oObj
.addPropertyWithValue("ooSetupFactoryTemplateFile", (short) 0,
76 oObj
.addOrReplaceNode("dropme", (short) 0);
77 oObj
.overrideProperty("anyway", (short) 0,
78 new Type(String
.class), false);
79 oObj
.setPropertyValue("nice");
81 oObj
.dropNode("dropme");
84 oObj
.addOrReplaceNodeFromTemplate("FromTemplate",
85 new com
.sun
.star
.configuration
.backend
.TemplateIdentifier(
86 "org.openoffice.Setup",
95 Object LayerParser
= tParam
.getMSF().createInstance(
96 "com.sun.star.comp.configuration.backend.xml.LayerParser");
98 XActiveDataSink xSink
= UnoRuntime
.queryInterface(
99 XActiveDataSink
.class, LayerParser
);
100 Object fileacc
= tParam
.getMSF().createInstance(
101 "com.sun.star.comp.ucb.SimpleFileAccess");
102 XSimpleFileAccess simpleAccess
= UnoRuntime
.queryInterface(
103 XSimpleFileAccess
.class,
106 String filename
= util
.utils
.getOfficeTemp(
109 log
.println("Going to parse: " + filename
);
111 XInputStream xStream
= simpleAccess
.openFileRead(filename
);
113 xSink
.setInputStream(xStream
);
115 XLayer xLayer
= UnoRuntime
.queryInterface(XLayer
.class,
118 XLayerHandlerImpl xLayerHandler
= new XLayerHandlerImpl();
120 xLayer
.readData(xLayerHandler
);
122 res
= xLayerHandler
.getCalls().equals(getExpected());
125 log
.println("#### Getting: ");
126 log
.println(xLayerHandler
.getCalls());
127 log
.println("#### Expected: ");
128 log
.println(getExpected());
130 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
131 log
.println("Unexpected Exception " + e
);
132 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
133 log
.println("Unexpected Exception " + e
);
134 } catch (com
.sun
.star
.uno
.Exception e
) {
135 log
.println("Unexpected Exception " + e
);
138 tRes
.tested("endLayer()", res
);
141 public void _addOrReplaceNode() {
142 requiredMethod("endLayer()");
143 tRes
.tested("addOrReplaceNode()", true);
146 public void _addOrReplaceNodeFromTemplate() {
147 requiredMethod("endLayer()");
148 tRes
.tested("addOrReplaceNodeFromTemplate()", true);
151 public void _addProperty() {
152 requiredMethod("endLayer()");
153 tRes
.tested("addProperty()", true);
156 public void _addPropertyWithValue() {
157 requiredMethod("endLayer()");
158 tRes
.tested("addPropertyWithValue()", true);
161 public void _dropNode() {
162 requiredMethod("endLayer()");
163 tRes
.tested("dropNode()", true);
166 public void _endNode() {
167 requiredMethod("endLayer()");
168 tRes
.tested("endNode()", true);
171 public void _endProperty() {
172 requiredMethod("endLayer()");
173 tRes
.tested("endProperty()", true);
176 public void _overrideNode() {
177 requiredMethod("endLayer()");
178 tRes
.tested("overrideNode()", true);
181 public void _overrideProperty() {
182 requiredMethod("endLayer()");
183 tRes
.tested("overrideProperty()", true);
186 public void _setPropertyValue() {
187 requiredMethod("endLayer()");
188 tRes
.tested("setPropertyValue()", true);
191 public void _setPropertyValueForLocale() {
192 requiredMethod("endLayer()");
193 tRes
.tested("setPropertyValueForLocale()", true);
196 public void _startLayer() {
197 requiredMethod("endLayer()");
198 tRes
.tested("startLayer()", true);
201 protected String
getExpected() {
202 String ls
= System
.getProperty("line.separator");
203 String expected
= "startLayer();" + ls
;
204 expected
+= ("overrideNode(org.openoffice.Setup,0,false);" + ls
);
205 expected
+= ("overrideNode(Office,0,false);" + ls
);
206 expected
+= ("overrideProperty(ooSetupInstCompleted,0,Type[string],false);" + ls
);
207 expected
+= ("setPropertyValue(false);" + ls
);
208 expected
+= ("endProperty();" + ls
);
209 expected
+= ("overrideNode(Factories,0,false);" + ls
);
210 expected
+= ("addOrReplace(com.sun.star.chart.ChartDocument,0);" + ls
);
211 expected
+= ("overrideProperty(ooSetupFactoryEmptyDocumentURL,0,Type[string],false);" + ls
);
212 expected
+= ("setPropertyValue(private:factory/schart);" + ls
);
213 expected
+= ("endProperty();" + ls
);
214 expected
+= ("overrideProperty(ooSetupFactoryIcon,0,Type[hyper],false);" + ls
);
215 expected
+= ("setPropertyValue(13);" + ls
);
216 expected
+= ("endProperty();" + ls
);
217 expected
+= ("overrideProperty(ooSetupFactoryShortName,0,Type[string],false);" + ls
);
218 expected
+= ("setPropertyValue(schart);" + ls
);
219 expected
+= ("setPropertyValueForLocale(TemplateFile,en-US);" + ls
);
220 expected
+= ("endProperty();" + ls
);
221 expected
+= ("overrideProperty(ooSetupFactoryTemplateFile,0,Type[string],false);" + ls
);
222 expected
+= ("setPropertyValue(empty);" + ls
);
223 expected
+= ("endProperty();" + ls
);
224 expected
+= ("addProperty(ooSetupFactoryTemplateFile,0,Type[string]);" + ls
);
225 expected
+= ("addPropertyWithValue(ooSetupFactoryTemplateFile,0,TemplateFile);" + ls
);
226 expected
+= ("endNode();" + ls
);
227 expected
+= ("addOrReplace(dropme,0);" + ls
);
228 expected
+= ("overrideProperty(anyway,0,Type[string],false);" + ls
);
229 expected
+= ("setPropertyValue(nice);" + ls
);
230 expected
+= ("endProperty();" + ls
);
231 expected
+= ("dropNode(dropme);" + ls
);
232 expected
+= ("endNode();" + ls
);
233 expected
+= ("addOrReplace(FromTemplate,0);" + ls
);
234 expected
+= ("endNode();" + ls
);
235 expected
+= ("endNode();" + ls
);
236 expected
+= ("endNode();" + ls
);
237 expected
+= ("endNode();" + ls
);
238 expected
+= ("endLayer();" + ls
);