1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package ifc.configuration.backend; 24 25 import com.sun.star.configuration.backend.TemplateIdentifier; 26 import com.sun.star.configuration.backend.XUpdateHandler; 27 import com.sun.star.uno.Type; 28 29 import lib.MultiMethodTest; 30 31 import util.XLayerHandlerImpl; 32 import util.XLayerImpl; 33 34 35 /** 36 * 37 * @author sw93809 38 */ 39 public class _XUpdateHandler extends MultiMethodTest { 40 public XUpdateHandler oObj; 41 protected XLayerHandlerImpl xLayerHandler = null; 42 before()43 public void before() { 44 xLayerHandler = (XLayerHandlerImpl) tEnv.getObjRelation("LayerHandler"); 45 46 try { 47 xLayerHandler.startLayer(); 48 xLayerHandler.overrideNode("org.openoffice.Setup", (short) 0, 49 false); 50 xLayerHandler.overrideNode("Office", (short) 0, false); 51 xLayerHandler.overrideProperty("ooSetupInstCompleted", (short) 0, 52 new Type(java.lang.String.class), 53 false); 54 xLayerHandler.setPropertyValue(new Boolean(false)); 55 xLayerHandler.endProperty(); 56 xLayerHandler.overrideProperty("ooSetupShowIntro", (short) 0, 57 new Type(java.lang.String.class), 58 false); 59 xLayerHandler.setPropertyValue(new Boolean(true)); 60 xLayerHandler.endProperty(); 61 xLayerHandler.overrideProperty("ooSetupLocales", (short) 0, 62 new Type(java.lang.String.class), 63 false); 64 xLayerHandler.setPropertyValue("en-US"); 65 xLayerHandler.endProperty(); 66 xLayerHandler.overrideNode("Factories", (short) 0, false); 67 xLayerHandler.addOrReplaceNode("com.sun.star.chart.ChartDocument", 68 (short) 0); 69 xLayerHandler.overrideProperty("ooSetupFactoryEmptyDocumentURL", 70 (short) 0, 71 new Type(java.lang.String.class), 72 false); 73 xLayerHandler.setPropertyValue("private:factory/schart"); 74 xLayerHandler.endProperty(); 75 xLayerHandler.overrideProperty("ooSetupFactoryIcon", (short) 0, 76 new Type(java.lang.Long.class), 77 false); 78 xLayerHandler.setPropertyValue(new Integer(13)); 79 xLayerHandler.endProperty(); 80 xLayerHandler.overrideProperty("ooSetupFactoryShortName", 81 (short) 0, 82 new Type(java.lang.String.class), 83 false); 84 xLayerHandler.setPropertyValue("schart"); 85 xLayerHandler.setPropertyValueForLocale("TemplateFile", "en-US"); 86 xLayerHandler.endProperty(); 87 xLayerHandler.overrideProperty("ooSetupFactoryTemplateFile", 88 (short) 0, 89 new Type(java.lang.String.class), 90 false); 91 xLayerHandler.setPropertyValue("empty"); 92 xLayerHandler.endProperty(); 93 xLayerHandler.addProperty("ooSetupFactoryTemplateFile", (short) 0, 94 new Type(java.lang.String.class)); 95 xLayerHandler.addPropertyWithValue("ooSetupFactoryTemplateFile", 96 (short) 0, "TemplateFile"); 97 xLayerHandler.endNode(); 98 99 xLayerHandler.addOrReplaceNode("dropme", (short) 0); 100 xLayerHandler.overrideProperty("anyway", (short) 0, 101 new Type(java.lang.String.class), 102 false); 103 xLayerHandler.setPropertyValue("nice"); 104 xLayerHandler.endProperty(); 105 xLayerHandler.dropNode("dropme"); 106 xLayerHandler.endNode(); 107 108 xLayerHandler.addOrReplaceNodeFromTemplate("FromTemplate", 109 new com.sun.star.configuration.backend.TemplateIdentifier( 110 "org.openoffice.Setup", 111 "Setup"), 112 (short) 0); 113 xLayerHandler.endNode(); 114 115 xLayerHandler.endNode(); 116 xLayerHandler.endNode(); 117 xLayerHandler.endNode(); 118 xLayerHandler.endLayer(); 119 } catch (com.sun.star.configuration.backend.MalformedDataException e) { 120 log.println("Unexpected Exception " + e); 121 } catch (com.sun.star.lang.WrappedTargetException e) { 122 log.println("Unexpected Exception " + e); 123 } catch (com.sun.star.uno.Exception e) { 124 log.println("Unexpected Exception " + e); 125 } 126 } 127 _addOrReplaceNode()128 public void _addOrReplaceNode() { 129 requiredMethod("startUpdate()"); 130 tRes.tested("addOrReplaceNode()", true); 131 } 132 _addOrReplaceNodeFromTemplate()133 public void _addOrReplaceNodeFromTemplate() { 134 requiredMethod("startUpdate()"); 135 tRes.tested("addOrReplaceNodeFromTemplate()", true); 136 } 137 _addOrReplaceProperty()138 public void _addOrReplaceProperty() { 139 requiredMethod("startUpdate()"); 140 tRes.tested("addOrReplaceProperty()", true); 141 } 142 _addOrReplacePropertyWithValue()143 public void _addOrReplacePropertyWithValue() { 144 requiredMethod("startUpdate()"); 145 tRes.tested("addOrReplacePropertyWithValue()", true); 146 } 147 _endNode()148 public void _endNode() { 149 requiredMethod("startUpdate()"); 150 tRes.tested("endNode()", true); 151 } 152 _endProperty()153 public void _endProperty() { 154 requiredMethod("startUpdate()"); 155 tRes.tested("endProperty()", true); 156 } 157 _endUpdate()158 public void _endUpdate() { 159 requiredMethod("startUpdate()"); 160 tRes.tested("endUpdate()", true); 161 } 162 _modifyNode()163 public void _modifyNode() { 164 requiredMethod("startUpdate()"); 165 tRes.tested("modifyNode()", true); 166 } 167 _modifyProperty()168 public void _modifyProperty() { 169 requiredMethod("startUpdate()"); 170 tRes.tested("modifyProperty()", true); 171 } 172 _removeNode()173 public void _removeNode() { 174 requiredMethod("startUpdate()"); 175 tRes.tested("removeNode()", true); 176 } 177 _removeProperty()178 public void _removeProperty() { 179 requiredMethod("startUpdate()"); 180 tRes.tested("removeProperty()", true); 181 } 182 _resetProperty()183 public void _resetProperty() { 184 requiredMethod("startUpdate()"); 185 tRes.tested("resetProperty()", true); 186 } 187 _resetPropertyValue()188 public void _resetPropertyValue() { 189 requiredMethod("startUpdate()"); 190 tRes.tested("resetPropertyValue()", true); 191 } 192 _resetPropertyValueForLocale()193 public void _resetPropertyValueForLocale() { 194 requiredMethod("startUpdate()"); 195 tRes.tested("resetPropertyValueForLocale()", true); 196 } 197 _setPropertyValue()198 public void _setPropertyValue() { 199 requiredMethod("startUpdate()"); 200 tRes.tested("setPropertyValue()", true); 201 } 202 _setPropertyValueForLocale()203 public void _setPropertyValueForLocale() { 204 requiredMethod("startUpdate()"); 205 tRes.tested("setPropertyValueForLocale()", true); 206 } 207 _startUpdate()208 public void _startUpdate() { 209 boolean res = true; 210 211 try { 212 XLayerImpl xLayer = (XLayerImpl) tEnv.getObjRelation("Layer"); 213 log.println("Layer called (before): " + xLayer.hasBeenCalled()); 214 oObj.startUpdate(); 215 oObj.addOrReplaceNode("whatever", (short) 0); 216 oObj.addOrReplaceNodeFromTemplate("Office", (short) 0, 217 new TemplateIdentifier()); 218 oObj.addOrReplaceProperty("prop", (short) 0, 219 new Type(java.lang.String.class)); 220 oObj.addOrReplacePropertyWithValue("prop2", (short) 0, "this"); 221 oObj.modifyProperty("ooSetupFactoryIcon", (short) 0, (short) 0, 222 new Type(java.lang.String.class)); 223 oObj.resetPropertyValue(); 224 oObj.resetPropertyValueForLocale("en-US"); 225 oObj.endProperty(); 226 oObj.modifyProperty("ooSetupFactoryEmptyDocumentURL", (short) 0, 227 (short) 0, new Type(java.lang.String.class)); 228 oObj.setPropertyValue("newValue"); 229 oObj.setPropertyValueForLocale("newValue-US", "de-DE"); 230 oObj.endProperty(); 231 oObj.removeProperty("ooSetupShowIntro"); 232 oObj.modifyNode("org.openoffice.Setup", (short) 0, (short) 0, true); 233 oObj.removeNode("whatever"); 234 oObj.resetProperty("prop"); 235 oObj.endNode(); 236 oObj.endNode(); 237 oObj.endNode(); 238 oObj.endUpdate(); 239 240 log.println("Layer called (after): " + xLayer.hasBeenCalled()); 241 242 res = xLayer.hasBeenCalled(); 243 } catch (com.sun.star.configuration.backend.MalformedDataException e) { 244 log.println("Unexpected exception " + e.getMessage()); 245 res = false; 246 } catch (com.sun.star.lang.IllegalAccessException e) { 247 log.println("Unexpected exception " + e.getMessage()); 248 res = false; 249 } catch (com.sun.star.lang.WrappedTargetException e) { 250 log.println("Unexpected exception " + e.getMessage()); 251 res = false; 252 } 253 254 tRes.tested("startUpdate()", res); 255 } 256 } 257