bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / task / _XJob.java
blobefa5d5c4ef1ccefafd77a998e96fc4e027e5fdc2
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.task;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.beans.NamedValue;
26 import com.sun.star.task.XJob;
28 /**
29 * Testing <code>com.sun.star.frame._XJobExecutor</code>
30 * interface methods:
31 * <ul>
32 * <li><code> trigger() </code></li>
33 * </ul><p>
35 * This test needs the following object relations :
36 * <ul>
37 * <li> <code>'CallCounter'</code>
38 * (of type <code>com.sun.star.container.XNamed</code>):
39 * the <code>getName()</code> method of which must
40 * return number of calls to <code>XJob.execute</code>
41 * method which is registered for event 'TestEvent'
42 * </li>
43 * <ul> <p>
44 * @see com.sun.star.frame.XJobExecutor
46 public class _XJob extends MultiMethodTest {
47 public static XJob oObj = null;
49 /**
50 * Tries to query the tested component for object relation
51 * <code>XJobArgs</code> [<code>Object[]</code>] which contains
52 * <code>executeArgs</code> [<code>NamedValue[]</code>]
53 * @throw StatusException If relations are not found
55 public void before() {
56 Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs") ;
57 if (XJobArgs == null)
58 throw new StatusException(Status.failed
59 ("'XJobArgs' relation not found ")) ;
64 /**
65 * Gets the number of Job calls before and after triggering event.
67 * Has <b>OK</b> status if the Job was called on triggering
68 * event.
70 public void _execute() {
71 Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs");
73 boolean bOK = true;
75 for (int n = 0; n<XJobArgs.length; n++) {
76 log.println("running XJobArgs[" + n + "]");
77 try {
78 oObj.execute((NamedValue[])XJobArgs[n]);
79 } catch ( com.sun.star.lang.IllegalArgumentException e) {
80 bOK = false;
81 log.println("Could not success XJobArgs[" + n + "]: " + e);
82 } catch ( com.sun.star.uno.Exception e) {
83 bOK = false;
84 log.println("Could not success XJobArgs[" + n + "]: " + e);
87 tRes.tested("execute()", bOK);