xref: /aoo42x/main/qadevOOo/tests/java/ifc/task/_XJob.java (revision ef39d40d)
1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.task;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import lib.MultiMethodTest;
27cdf0e10cSrcweir import lib.Status;
28cdf0e10cSrcweir import lib.StatusException;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir import com.sun.star.beans.NamedValue;
31cdf0e10cSrcweir import com.sun.star.task.XJob;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /**
34cdf0e10cSrcweir  * Testing <code>com.sun.star.frame._XJobExecutor</code>
35cdf0e10cSrcweir  * interface methods:
36cdf0e10cSrcweir  * <ul>
37cdf0e10cSrcweir  *  <li><code> trigger() </code></li>
38cdf0e10cSrcweir  * </ul><p>
39cdf0e10cSrcweir  *
40cdf0e10cSrcweir  * This test needs the following object relations :
41cdf0e10cSrcweir  * <ul>
42cdf0e10cSrcweir  *  <li> <code>'CallCounter'</code>
43cdf0e10cSrcweir  *      (of type <code>com.sun.star.container.XNamed</code>):
44cdf0e10cSrcweir  *      the <code>getName()</code> method of which must
45cdf0e10cSrcweir  *      return number of calls to <code>XJob.execute</code>
46cdf0e10cSrcweir  *      method which is registered for event 'TestEvent'
47cdf0e10cSrcweir  *  </li>
48cdf0e10cSrcweir  * <ul> <p>
49cdf0e10cSrcweir  * @see com.sun.star.frame.XJobExecutor
50cdf0e10cSrcweir  */
51cdf0e10cSrcweir public class _XJob extends MultiMethodTest {
52cdf0e10cSrcweir 	public static XJob oObj = null;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     /**
55cdf0e10cSrcweir      * Tries to query the tested component for object relation
56cdf0e10cSrcweir      * <code>XJobArgs</code> [<code>Object[]</code>] which contains
57cdf0e10cSrcweir      * <code>executeArgs</code> [<code>NamedValue[]</code>]
58cdf0e10cSrcweir      * @throw StatusException If relations are not found
59cdf0e10cSrcweir      */
before()60cdf0e10cSrcweir     public void before() {
61cdf0e10cSrcweir         Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs") ;
62cdf0e10cSrcweir         if (XJobArgs == null)
63cdf0e10cSrcweir             throw new StatusException(Status.failed
64cdf0e10cSrcweir                 ("'XJobArgs' relation not found ")) ;
65cdf0e10cSrcweir     }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     /**
70cdf0e10cSrcweir      * Gets the number of Job calls before and after triggering event.
71cdf0e10cSrcweir      *
72cdf0e10cSrcweir      * Has <b>OK</b> status if the Job was called on triggering
73cdf0e10cSrcweir      * event.
74cdf0e10cSrcweir      */
_execute()75cdf0e10cSrcweir     public void _execute() {
76cdf0e10cSrcweir         Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs");
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	boolean bOK = true;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir         for (int n = 0; n<XJobArgs.length; n++) {
81cdf0e10cSrcweir             log.println("running XJobArgs[" + n + "]");
82cdf0e10cSrcweir             try {
83cdf0e10cSrcweir                 oObj.execute((NamedValue[])XJobArgs[n]);
84cdf0e10cSrcweir             } catch ( com.sun.star.lang.IllegalArgumentException e) {
85cdf0e10cSrcweir                 bOK = false;
86cdf0e10cSrcweir                 log.println("Could not success XJobArgs[" + n + "]: " + e);
87cdf0e10cSrcweir             } catch ( com.sun.star.uno.Exception e) {
88cdf0e10cSrcweir                 bOK = false;
89cdf0e10cSrcweir                 log.println("Could not success XJobArgs[" + n + "]: " + e);
90cdf0e10cSrcweir             }
91cdf0e10cSrcweir         }
92cdf0e10cSrcweir         tRes.tested("execute()", bOK);
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir }
95