1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.task; 29 30 import lib.MultiMethodTest; 31 import lib.Status; 32 import lib.StatusException; 33 34 import com.sun.star.beans.NamedValue; 35 import com.sun.star.task.XJob; 36 37 /** 38 * Testing <code>com.sun.star.frame._XJobExecutor</code> 39 * interface methods: 40 * <ul> 41 * <li><code> trigger() </code></li> 42 * </ul><p> 43 * 44 * This test needs the following object relations : 45 * <ul> 46 * <li> <code>'CallCounter'</code> 47 * (of type <code>com.sun.star.container.XNamed</code>): 48 * the <code>getName()</code> method of which must 49 * return number of calls to <code>XJob.execute</code> 50 * method which is registered for event 'TestEvent' 51 * </li> 52 * <ul> <p> 53 * @see com.sun.star.frame.XJobExecutor 54 */ 55 public class _XJob extends MultiMethodTest { 56 public static XJob oObj = null; 57 58 /** 59 * Tries to query the tested component for object relation 60 * <code>XJobArgs</code> [<code>Object[]</code>] which contains 61 * <code>executeArgs</code> [<code>NamedValue[]</code>] 62 * @throw StatusException If relations are not found 63 */ 64 public void before() { 65 Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs") ; 66 if (XJobArgs == null) 67 throw new StatusException(Status.failed 68 ("'XJobArgs' relation not found ")) ; 69 } 70 71 72 73 /** 74 * Gets the number of Job calls before and after triggering event. 75 * 76 * Has <b>OK</b> status if the Job was called on triggering 77 * event. 78 */ 79 public void _execute() { 80 Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs"); 81 82 boolean bOK = true; 83 84 for (int n = 0; n<XJobArgs.length; n++) { 85 log.println("running XJobArgs[" + n + "]"); 86 try { 87 oObj.execute((NamedValue[])XJobArgs[n]); 88 } catch ( com.sun.star.lang.IllegalArgumentException e) { 89 bOK = false; 90 log.println("Could not success XJobArgs[" + n + "]: " + e); 91 } catch ( com.sun.star.uno.Exception e) { 92 bOK = false; 93 log.println("Could not success XJobArgs[" + n + "]: " + e); 94 } 95 } 96 tRes.tested("execute()", bOK); 97 } 98 } 99