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 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.beans
.NamedValue
;
26 import com
.sun
.star
.task
.XJob
;
29 * Testing <code>com.sun.star.frame._XJobExecutor</code>
32 * <li><code> trigger() </code></li>
35 * This test needs the following object relations :
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'
44 * @see com.sun.star.frame.XJobExecutor
46 public class _XJob
extends MultiMethodTest
{
47 public static XJob oObj
= null;
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
56 public void before() {
57 Object
[] XJobArgs
= (Object
[]) tEnv
.getObjRelation("XJobArgs") ;
59 throw new StatusException(Status
.failed
60 ("'XJobArgs' relation not found ")) ;
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
71 public void _execute() {
72 Object
[] XJobArgs
= (Object
[]) tEnv
.getObjRelation("XJobArgs");
76 for (int n
= 0; n
<XJobArgs
.length
; n
++) {
77 log
.println("running XJobArgs[" + n
+ "]");
79 oObj
.execute((NamedValue
[])XJobArgs
[n
]);
80 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
82 log
.println("Could not success XJobArgs[" + n
+ "]: " + e
);
83 } catch ( com
.sun
.star
.uno
.Exception e
) {
85 log
.println("Could not success XJobArgs[" + n
+ "]: " + e
);
88 tRes
.tested("execute()", bOK
);