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 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import lib
.StatusException
;
34 import com
.sun
.star
.beans
.NamedValue
;
35 import com
.sun
.star
.task
.XJob
;
38 * Testing <code>com.sun.star.frame._XJobExecutor</code>
41 * <li><code> trigger() </code></li>
44 * This test needs the following object relations :
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'
53 * @see com.sun.star.frame.XJobExecutor
55 public class _XJob
extends MultiMethodTest
{
56 public static XJob oObj
= null;
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") ;
67 throw new StatusException(Status
.failed
68 ("'XJobArgs' relation not found ")) ;
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
79 public void _execute() {
80 Object
[] XJobArgs
= (Object
[]) tEnv
.getObjRelation("XJobArgs");
84 for (int n
= 0; n
<XJobArgs
.length
; n
++) {
85 log
.println("running XJobArgs[" + n
+ "]");
87 oObj
.execute((NamedValue
[])XJobArgs
[n
]);
88 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
90 log
.println("Could not success XJobArgs[" + n
+ "]: " + e
);
91 } catch ( com
.sun
.star
.uno
.Exception e
) {
93 log
.println("Could not success XJobArgs[" + n
+ "]: " + e
);
96 tRes
.tested("execute()", bOK
);