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