1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir package ifc.script; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir import lib.MultiMethodTest; 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir import com.sun.star.lang.EventObject; 33*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 34*cdf0e10cSrcweir import com.sun.star.script.ScriptEvent; 35*cdf0e10cSrcweir import com.sun.star.script.ScriptEventDescriptor; 36*cdf0e10cSrcweir import com.sun.star.script.XEventAttacherManager; 37*cdf0e10cSrcweir import com.sun.star.script.XScriptListener; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir /** 40*cdf0e10cSrcweir * Testing <code>com.sun.star.script.XEventAttacherManager</code> 41*cdf0e10cSrcweir * interface methods : 42*cdf0e10cSrcweir * <ul> 43*cdf0e10cSrcweir * <li><code> registerScriptEvent()</code></li> 44*cdf0e10cSrcweir * <li><code> registerScriptEvents()</code></li> 45*cdf0e10cSrcweir * <li><code> revokeScriptEvent()</code></li> 46*cdf0e10cSrcweir * <li><code> revokeScriptEvents()</code></li> 47*cdf0e10cSrcweir * <li><code> insertEntry()</code></li> 48*cdf0e10cSrcweir * <li><code> removeEntry()</code></li> 49*cdf0e10cSrcweir * <li><code> getScriptEvents()</code></li> 50*cdf0e10cSrcweir * <li><code> attach()</code></li> 51*cdf0e10cSrcweir * <li><code> detach()</code></li> 52*cdf0e10cSrcweir * <li><code> addScriptListener()</code></li> 53*cdf0e10cSrcweir * <li><code> removeScriptListener()</code></li> 54*cdf0e10cSrcweir * </ul> <p> 55*cdf0e10cSrcweir * @see com.sun.star.script.XEventAttacherManager 56*cdf0e10cSrcweir */ 57*cdf0e10cSrcweir public class _XEventAttacherManager extends MultiMethodTest { 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir /** 60*cdf0e10cSrcweir * oObj filled by MultiMethodTest 61*cdf0e10cSrcweir */ 62*cdf0e10cSrcweir public XEventAttacherManager oObj = null; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir int index; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir /** 67*cdf0e10cSrcweir * Test calls the method and stores index of new entry. <p> 68*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 69*cdf0e10cSrcweir * and no exceptions were thrown. <p> 70*cdf0e10cSrcweir */ 71*cdf0e10cSrcweir public void _insertEntry() { 72*cdf0e10cSrcweir index = 0; 73*cdf0e10cSrcweir try { 74*cdf0e10cSrcweir oObj.insertEntry(index); 75*cdf0e10cSrcweir tRes.tested("insertEntry()", true); 76*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 77*cdf0e10cSrcweir log.println("insertEntry(" + index 78*cdf0e10cSrcweir + ") throws unexpected exception " 79*cdf0e10cSrcweir + e.getMessage()); 80*cdf0e10cSrcweir e.printStackTrace(log); 81*cdf0e10cSrcweir tRes.tested("insertEntry()", false); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir ScriptEventDescriptor desc; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir /** 88*cdf0e10cSrcweir * Test creates <code>ScriptEventDescriptor</code>, registers 89*cdf0e10cSrcweir * the script event and stores the descriptor. <p> 90*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 91*cdf0e10cSrcweir * and no exceptions were thrown. <p> 92*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 93*cdf0e10cSrcweir * <ul> 94*cdf0e10cSrcweir * <li> <code> insertEntry() </code> : to have entry's index</li> 95*cdf0e10cSrcweir * </ul> 96*cdf0e10cSrcweir * @see com.sun.star.script.ScriptEventDescriptor 97*cdf0e10cSrcweir */ 98*cdf0e10cSrcweir public void _registerScriptEvent() { 99*cdf0e10cSrcweir requiredMethod("insertEntry()"); 100*cdf0e10cSrcweir desc = new ScriptEventDescriptor( 101*cdf0e10cSrcweir "XEventListener1", 102*cdf0e10cSrcweir "disposing", "", "Basic", ""); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir try { 105*cdf0e10cSrcweir oObj.registerScriptEvent(index, desc); 106*cdf0e10cSrcweir tRes.tested("registerScriptEvent()", true); 107*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 108*cdf0e10cSrcweir log.println("registerScriptEvent() throws unexpected exception " 109*cdf0e10cSrcweir + e.getMessage()); 110*cdf0e10cSrcweir e.printStackTrace(log); 111*cdf0e10cSrcweir tRes.tested("registerScriptEvent()", false); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir ScriptEventDescriptor descs[]; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir /** 118*cdf0e10cSrcweir * Test creates array of <code>ScriptEventDescriptor</code>, registers 119*cdf0e10cSrcweir * this script events and stores the descriptors. <p> 120*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 121*cdf0e10cSrcweir * and no exceptions were thrown. <p> 122*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 123*cdf0e10cSrcweir * <ul> 124*cdf0e10cSrcweir * <li> <code> insertEntry() </code> : to have entry's index</li> 125*cdf0e10cSrcweir * </ul> 126*cdf0e10cSrcweir * @see com.sun.star.script.ScriptEventDescriptor 127*cdf0e10cSrcweir */ 128*cdf0e10cSrcweir public void _registerScriptEvents() { 129*cdf0e10cSrcweir requiredMethod("insertEntry()"); 130*cdf0e10cSrcweir descs = new ScriptEventDescriptor[] { 131*cdf0e10cSrcweir new ScriptEventDescriptor( 132*cdf0e10cSrcweir "XEventListener2", 133*cdf0e10cSrcweir "disposing", "", "Basic", ""), 134*cdf0e10cSrcweir new ScriptEventDescriptor( 135*cdf0e10cSrcweir "XEventListener3", 136*cdf0e10cSrcweir "disposing", "", "Basic", "") 137*cdf0e10cSrcweir }; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir try { 140*cdf0e10cSrcweir oObj.registerScriptEvents(index, descs); 141*cdf0e10cSrcweir tRes.tested("registerScriptEvents()", true); 142*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 143*cdf0e10cSrcweir log.println("registerScriptEvents() throws unexpected exception " 144*cdf0e10cSrcweir + e.getMessage()); 145*cdf0e10cSrcweir e.printStackTrace(log); 146*cdf0e10cSrcweir tRes.tested("registerScriptEvents()", false); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir /** 151*cdf0e10cSrcweir * Test calls the method and checks returned value. <p> 152*cdf0e10cSrcweir * Has <b> OK </b> status if returned array of descriptors contains 153*cdf0e10cSrcweir * array of descriptors registered by methods <code>registerScriptEvents</code> 154*cdf0e10cSrcweir * and <code>registerScriptEvent</code> and no exceptions were thrown. <p> 155*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 156*cdf0e10cSrcweir * <ul> 157*cdf0e10cSrcweir * <li> <code> registerScriptEvent() </code> : 158*cdf0e10cSrcweir * to have registered descriptor </li> 159*cdf0e10cSrcweir * <li> <code> registerScriptEvents() </code> : 160*cdf0e10cSrcweir * to have registered descriptors </li> 161*cdf0e10cSrcweir * </ul> 162*cdf0e10cSrcweir */ 163*cdf0e10cSrcweir public void _getScriptEvents() { 164*cdf0e10cSrcweir requiredMethod("registerScriptEvent()"); 165*cdf0e10cSrcweir requiredMethod("registerScriptEvents()"); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir ScriptEventDescriptor[] res; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir try { 170*cdf0e10cSrcweir res = oObj.getScriptEvents(index); 171*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 172*cdf0e10cSrcweir log.println("registerScriptEvents() throws unexpected exception " 173*cdf0e10cSrcweir + e.getMessage()); 174*cdf0e10cSrcweir e.printStackTrace(log); 175*cdf0e10cSrcweir tRes.tested("registerScriptEvents()", false); 176*cdf0e10cSrcweir return; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir // checking the desc and descs are in script events 180*cdf0e10cSrcweir tRes.tested("getScriptEvents()", 181*cdf0e10cSrcweir contains(res, desc) && containsArray(res, descs)); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir log.println("Script events :") ; 184*cdf0e10cSrcweir printEvents(res) ; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir /** 188*cdf0e10cSrcweir * Method checks that array of descriptors contains the concrete desciptor. 189*cdf0e10cSrcweir * @param container the array of descriptors 190*cdf0e10cSrcweir * @param evt the descriptor which presence in the array is checked 191*cdf0e10cSrcweir * @return true if the descriptor presence in the array 192*cdf0e10cSrcweir */ 193*cdf0e10cSrcweir boolean contains(ScriptEventDescriptor[] container, 194*cdf0e10cSrcweir ScriptEventDescriptor evt) { 195*cdf0e10cSrcweir for (int i = 0; i < container.length; i++) { 196*cdf0e10cSrcweir if (equal(container[i], evt)) { 197*cdf0e10cSrcweir return true; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir return false; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir /** 205*cdf0e10cSrcweir * Method checks that one array of descriptors contains 206*cdf0e10cSrcweir * another array of descriptors. 207*cdf0e10cSrcweir * @param container the array of descriptors 208*cdf0e10cSrcweir * @param events the array of descriptors which presence 209*cdf0e10cSrcweir * in array <code>container</code> is checked 210*cdf0e10cSrcweir * @return true if the array <code>events</code> contains in the array 211*cdf0e10cSrcweir * <code>container</code> 212*cdf0e10cSrcweir */ 213*cdf0e10cSrcweir boolean containsArray(ScriptEventDescriptor[] container, 214*cdf0e10cSrcweir ScriptEventDescriptor[] events) { 215*cdf0e10cSrcweir for (int i = 0; i < events.length; i++) { 216*cdf0e10cSrcweir if (!contains(container, events[i])) { 217*cdf0e10cSrcweir return false; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir return true; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir /** 225*cdf0e10cSrcweir * Compares descriptor <code>evt1</code> to descriptor <code>evt2</code>. 226*cdf0e10cSrcweir * Two descriptors are considered equal if all their fields are equal. 227*cdf0e10cSrcweir * @return true if the argument is not <code>null</code> and 228*cdf0e10cSrcweir * the descriptors are equal; false otherwise 229*cdf0e10cSrcweir */ 230*cdf0e10cSrcweir boolean equal(ScriptEventDescriptor evt1, 231*cdf0e10cSrcweir ScriptEventDescriptor evt2) { 232*cdf0e10cSrcweir return evt1.ListenerType.equals(evt2.ListenerType) 233*cdf0e10cSrcweir && evt1.EventMethod.equals(evt2.EventMethod) 234*cdf0e10cSrcweir && evt1.ScriptType.equals(evt2.ScriptType) 235*cdf0e10cSrcweir && evt1.ScriptCode.equals(evt2.ScriptCode) 236*cdf0e10cSrcweir && evt1.AddListenerParam.equals(evt2.AddListenerParam); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir /** 240*cdf0e10cSrcweir * Prints fields of descriptor <code>evt</code> to log. 241*cdf0e10cSrcweir * @param evt the descriptor that needs to be printed to log 242*cdf0e10cSrcweir */ 243*cdf0e10cSrcweir void printEvent(ScriptEventDescriptor evt) { 244*cdf0e10cSrcweir if (evt == null) { 245*cdf0e10cSrcweir log.println("null"); 246*cdf0e10cSrcweir } else { 247*cdf0e10cSrcweir log.println("\"" + evt.ListenerType + "\",\"" 248*cdf0e10cSrcweir + evt.EventMethod + "\",\"" 249*cdf0e10cSrcweir + evt.ScriptType + "\",\"" 250*cdf0e10cSrcweir + evt.ScriptCode + "\",\"" 251*cdf0e10cSrcweir + evt.AddListenerParam + "\""); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir /** 256*cdf0e10cSrcweir * Prints the descriptors to log. 257*cdf0e10cSrcweir * @param events the array of descriptors that need to be printed to log 258*cdf0e10cSrcweir */ 259*cdf0e10cSrcweir void printEvents(ScriptEventDescriptor events[]) { 260*cdf0e10cSrcweir if (events == null) { 261*cdf0e10cSrcweir log.println("null"); 262*cdf0e10cSrcweir } else { 263*cdf0e10cSrcweir for (int i = 0; i < events.length; i++) { 264*cdf0e10cSrcweir printEvent(events[i]); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir Object attachedObject; 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir /** 272*cdf0e10cSrcweir * Test creates instance of <code>TypeDescriptionProvider</code>, 273*cdf0e10cSrcweir * stores it and attaches it to the entry with index stored in the method 274*cdf0e10cSrcweir * <code>insertEntry()</code>. <p> 275*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 276*cdf0e10cSrcweir * and no exceptions were thrown. <p> 277*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 278*cdf0e10cSrcweir * <ul> 279*cdf0e10cSrcweir * <li> <code> insertEntry() </code> : to have entry's index for attach</li> 280*cdf0e10cSrcweir * @see com.sun.star.reflection.TypeDescriptionProvider 281*cdf0e10cSrcweir */ 282*cdf0e10cSrcweir public void _attach() { 283*cdf0e10cSrcweir requiredMethod("insertEntry()"); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir try { 286*cdf0e10cSrcweir XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF(); 287*cdf0e10cSrcweir attachedObject = xMSF.createInstance 288*cdf0e10cSrcweir ( "com.sun.star.reflection.TypeDescriptionProvider" ); 289*cdf0e10cSrcweir } catch( com.sun.star.uno.Exception e ) { 290*cdf0e10cSrcweir log.println("Service not available" ); 291*cdf0e10cSrcweir e.printStackTrace(log); 292*cdf0e10cSrcweir tRes.tested("attach()", false); 293*cdf0e10cSrcweir return; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir try { 297*cdf0e10cSrcweir oObj.attach(index, attachedObject, "param"); 298*cdf0e10cSrcweir tRes.tested("attach()", true); 299*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 300*cdf0e10cSrcweir log.println("attach() throws exception " 301*cdf0e10cSrcweir + e.getMessage()); 302*cdf0e10cSrcweir e.printStackTrace(log); 303*cdf0e10cSrcweir tRes.tested("attach()", false); 304*cdf0e10cSrcweir } catch (com.sun.star.lang.ServiceNotRegisteredException e) { 305*cdf0e10cSrcweir log.println("attach() throws exception " 306*cdf0e10cSrcweir + e.getMessage()); 307*cdf0e10cSrcweir e.printStackTrace(log); 308*cdf0e10cSrcweir tRes.tested("attach()", false); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir /** 313*cdf0e10cSrcweir * Test calls the method for the object that was stored in the method 314*cdf0e10cSrcweir * <code>attach()</code>. <p> 315*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 316*cdf0e10cSrcweir * and no exceptions were thrown. <p> 317*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 318*cdf0e10cSrcweir * <ul> 319*cdf0e10cSrcweir * <li> <code> attach() </code> : to have attached object </li> 320*cdf0e10cSrcweir * </ul> 321*cdf0e10cSrcweir */ 322*cdf0e10cSrcweir public void _detach() { 323*cdf0e10cSrcweir requiredMethod("attach()"); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir try { 326*cdf0e10cSrcweir oObj.detach(index, attachedObject); 327*cdf0e10cSrcweir tRes.tested("detach()", true); 328*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 329*cdf0e10cSrcweir log.println("detach() throws unexpected exception " 330*cdf0e10cSrcweir + e.getMessage()); 331*cdf0e10cSrcweir e.printStackTrace(log); 332*cdf0e10cSrcweir tRes.tested("detach()", false); 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir /** 337*cdf0e10cSrcweir * Test revokes script event that was registered by method 338*cdf0e10cSrcweir * <code>registerScriptEvent()</code> and checks that the description 339*cdf0e10cSrcweir * was removed. <p> 340*cdf0e10cSrcweir * Has <b> OK </b> status if description was successfully removed. <p> 341*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 342*cdf0e10cSrcweir * <ul> 343*cdf0e10cSrcweir * <li> <code> registerScriptEvent() </code> : 344*cdf0e10cSrcweir * to have registered descriptor </li> 345*cdf0e10cSrcweir * </ul> 346*cdf0e10cSrcweir * The following method tests are to be executed before : 347*cdf0e10cSrcweir * <ul> 348*cdf0e10cSrcweir * <li> <code> getScriptEvents() </code> : 349*cdf0e10cSrcweir * this method must be executed first </li> 350*cdf0e10cSrcweir * </ul> 351*cdf0e10cSrcweir */ 352*cdf0e10cSrcweir public void _revokeScriptEvent() { 353*cdf0e10cSrcweir requiredMethod("registerScriptEvent()"); 354*cdf0e10cSrcweir executeMethod("getScriptEvents()") ; 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir try { 357*cdf0e10cSrcweir oObj.revokeScriptEvent(index, desc.ListenerType, 358*cdf0e10cSrcweir desc.EventMethod, ""); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir ScriptEventDescriptor[] res = oObj.getScriptEvents(index); 361*cdf0e10cSrcweir // checking that the desc has been removed 362*cdf0e10cSrcweir tRes.tested("revokeScriptEvent()", !contains(res, desc)); 363*cdf0e10cSrcweir printEvents(res) ; 364*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 365*cdf0e10cSrcweir log.println("revokeScriptEvent() throws unexpected exception " 366*cdf0e10cSrcweir + e.getMessage()); 367*cdf0e10cSrcweir e.printStackTrace(log); 368*cdf0e10cSrcweir tRes.tested("revokeScriptEvent()", false); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir /** 373*cdf0e10cSrcweir * Test revokes script events that was registered by method 374*cdf0e10cSrcweir * <code>registerScriptEvents()</code> and checks that the descriptions 375*cdf0e10cSrcweir * were removed. <p> 376*cdf0e10cSrcweir * Has <b> OK </b> status if descriptions were successfully removed. <p> 377*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 378*cdf0e10cSrcweir * <ul> 379*cdf0e10cSrcweir * <li> <code> revokeScriptEvent() </code> : 380*cdf0e10cSrcweir * this method must be executed first </li> 381*cdf0e10cSrcweir * </ul> 382*cdf0e10cSrcweir * The following method tests are to be executed before : 383*cdf0e10cSrcweir * <ul> 384*cdf0e10cSrcweir * <li> <code> getScriptEvents() </code> : 385*cdf0e10cSrcweir * this method must be executed first </li> 386*cdf0e10cSrcweir * </ul> 387*cdf0e10cSrcweir */ 388*cdf0e10cSrcweir public void _revokeScriptEvents() { 389*cdf0e10cSrcweir requiredMethod("revokeScriptEvent()"); 390*cdf0e10cSrcweir executeMethod("getScriptEvents()") ; 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir try { 393*cdf0e10cSrcweir oObj.revokeScriptEvents(index); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir ScriptEventDescriptor[] res = oObj.getScriptEvents(index); 396*cdf0e10cSrcweir // checking that all events have been removed 397*cdf0e10cSrcweir tRes.tested("revokeScriptEvents()", 398*cdf0e10cSrcweir res == null || res.length == 0); 399*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 400*cdf0e10cSrcweir log.println("revokeScriptEvents() throws unexpected exception " 401*cdf0e10cSrcweir + e.getMessage()); 402*cdf0e10cSrcweir e.printStackTrace(log); 403*cdf0e10cSrcweir tRes.tested("revokeScriptEvents()", false); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir /** 408*cdf0e10cSrcweir * Test calls the method with entry's index that was stored in method 409*cdf0e10cSrcweir * <code>insertEntry()</code>. <p> 410*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 411*cdf0e10cSrcweir * and no exceptions were thrown. <p> 412*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 413*cdf0e10cSrcweir * <ul> 414*cdf0e10cSrcweir * <li> <code> insertEntry() </code> : 415*cdf0e10cSrcweir * to have entry's index </li> 416*cdf0e10cSrcweir */ 417*cdf0e10cSrcweir public void _removeEntry() { 418*cdf0e10cSrcweir requiredMethod("insertEntry()"); 419*cdf0e10cSrcweir try { 420*cdf0e10cSrcweir oObj.removeEntry(index); 421*cdf0e10cSrcweir tRes.tested("removeEntry()", true); 422*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 423*cdf0e10cSrcweir log.println("removeEntry(" + index 424*cdf0e10cSrcweir + ") throws unexpected exception " 425*cdf0e10cSrcweir + e.getMessage()); 426*cdf0e10cSrcweir e.printStackTrace(log); 427*cdf0e10cSrcweir tRes.tested("removeEntry()", false); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir XScriptListener listener; 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir /** 434*cdf0e10cSrcweir * Test creates object that supports interface <code>XScriptListener</code>, 435*cdf0e10cSrcweir * stores it and addes this scripts listener. <p> 436*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 437*cdf0e10cSrcweir * and no exceptions were thrown. <p> 438*cdf0e10cSrcweir * @see com.sun.star.script.XScriptListener 439*cdf0e10cSrcweir */ 440*cdf0e10cSrcweir public void _addScriptListener() { 441*cdf0e10cSrcweir listener = new MyScriptListener(); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir try { 444*cdf0e10cSrcweir oObj.addScriptListener(listener); 445*cdf0e10cSrcweir tRes.tested("addScriptListener()", true); 446*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 447*cdf0e10cSrcweir log.println("addScriptListener() throws unexpected exception " 448*cdf0e10cSrcweir + e.getMessage()); 449*cdf0e10cSrcweir e.printStackTrace(log); 450*cdf0e10cSrcweir tRes.tested("addScriptListener()", false); 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir /** 455*cdf0e10cSrcweir * Test removes script listener that was stored in method 456*cdf0e10cSrcweir * <code>addScriptListener()</code>. <p> 457*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 458*cdf0e10cSrcweir * and no exceptions were thrown. <p> 459*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 460*cdf0e10cSrcweir * <ul> 461*cdf0e10cSrcweir * <li> <code> addScriptListener() </code> : 462*cdf0e10cSrcweir * to have script listener </li> 463*cdf0e10cSrcweir * </ul> 464*cdf0e10cSrcweir */ 465*cdf0e10cSrcweir public void _removeScriptListener() { 466*cdf0e10cSrcweir requiredMethod("addScriptListener()"); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir try { 469*cdf0e10cSrcweir oObj.removeScriptListener(listener); 470*cdf0e10cSrcweir tRes.tested("removeScriptListener()", true); 471*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 472*cdf0e10cSrcweir log.println("removeScriptListener() throws unexpected exception " 473*cdf0e10cSrcweir + e.getMessage()); 474*cdf0e10cSrcweir e.printStackTrace(log); 475*cdf0e10cSrcweir tRes.tested("removeScriptListener()", false); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir /** 480*cdf0e10cSrcweir * Class implement interface <code>XScriptListener</code> 481*cdf0e10cSrcweir * for test of the method <code>addScriptListener()</code>. 482*cdf0e10cSrcweir * No functionality implemented. 483*cdf0e10cSrcweir * @see com.sun.star.script.XScriptListener 484*cdf0e10cSrcweir */ 485*cdf0e10cSrcweir class MyScriptListener implements XScriptListener { 486*cdf0e10cSrcweir public void firing(ScriptEvent evt) { 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir public Object approveFiring(ScriptEvent evt) { 490*cdf0e10cSrcweir return evt.Helper; 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir public void disposing(EventObject evt) { 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499