Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / task / _XJob.java
blob58800f37ebbc7c2dda9a74ca4a04c8f82abdb54e
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 @Override
56 public void before() {
57 Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs") ;
58 if (XJobArgs == null)
59 throw new StatusException(Status.failed
60 ("'XJobArgs' relation not found ")) ;
65 /**
66 * Gets the number of Job calls before and after triggering event.
68 * Has <b>OK</b> status if the Job was called on triggering
69 * event.
71 public void _execute() {
72 Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs");
74 boolean bOK = true;
76 for (int n = 0; n<XJobArgs.length; n++) {
77 log.println("running XJobArgs[" + n + "]");
78 try {
79 oObj.execute((NamedValue[])XJobArgs[n]);
80 } catch ( com.sun.star.lang.IllegalArgumentException e) {
81 bOK = false;
82 log.println("Could not success XJobArgs[" + n + "]: " + e);
83 } catch ( com.sun.star.uno.Exception e) {
84 bOK = false;
85 log.println("Could not success XJobArgs[" + n + "]: " + e);
88 tRes.tested("execute()", bOK);