Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / task / _XJob.java
blobe4cc567b5b4f56e616d4b10867c7657810bfdb43
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 package ifc.task;
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
34 import com.sun.star.beans.NamedValue;
35 import com.sun.star.task.XJob;
37 /**
38 * Testing <code>com.sun.star.frame._XJobExecutor</code>
39 * interface methods:
40 * <ul>
41 * <li><code> trigger() </code></li>
42 * </ul><p>
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
55 public class _XJob extends MultiMethodTest {
56 public static XJob oObj = null;
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
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 ")) ;
73 /**
74 * Gets the number of Job calls before and after triggering event.
76 * Has <b>OK</b> status if the Job was called on triggering
77 * event.
79 public void _execute() {
80 Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs");
82 boolean bOK = true;
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);
96 tRes.tested("execute()", bOK);