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 com
.sun
.star
.beans
.PropertyValue
;
23 import com
.sun
.star
.frame
.XModuleManager
;
24 import lib
.MultiMethodTest
;
26 import lib
.StatusException
;
28 import com
.sun
.star
.lang
.IllegalArgumentException
;
29 import com
.sun
.star
.frame
.UnknownModuleException
;
33 * Testing <code>com.sun.star.frame.XModuleManager</code>
36 * <li><code> identify() </code></li>
38 * This test needs the following object relations :
40 * <li> <code>'XModuleManager.XFrame'</code> (of type <code>PropertyValue[]</code>):
41 * PropertyValue[n].Value : a XFrame
42 * PropertyValue[n].Name : the expected return value of <code>idendify()</code></li>
43 * <li> <code>'XModuleManager.XController'</code> (of type <code>PropertyValue[]</code>):
44 * PropertyValue[n].Value : a XController
45 * PropertyValue[n].Name : the expected return value of <code>idendify()</code></li>
46 * <li> <code>'XModuleManager.XModel'</code> (of type <code>PropertyValue[]</code>):
47 * PropertyValue[n].Value : a XFrame
48 * PropertyValue[n].Name : the expected return value of <code>idendify()</code></li>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.frame.XModuleManager
53 public class _XModuleManager
extends MultiMethodTest
{
54 /** Test calls the method. <p>
55 * The onject relations <CODE>XModuleManager.XFrame</CODE>,
56 * <CODE>XModuleManager.XController</CODE> and <CODE>XModuleManager.XModel</CODE>
57 * are sequenzes of <CODE>PropertyValue</CODE>. The value of a PropertyValue
58 * containes a <CODE>XFrame</CODE>, <CODE>XController</CODE> or a
59 * <CODE>XModel</CODE>. The name of the PropertyValue contains the expected return
60 * value of method <CODE>indetify()</CODE> if the method was called with
61 * coresponding value.<p>
62 * As enhancement the method <CODE>identify()</CODE> was called with incvalid
63 * parameter. In this case the thrown exceptions was catched.
65 public XModuleManager oObj
= null;
67 * Test calls the method. <p>
68 * Has <b> OK </b> status if the method returns expected values, that's equal to
69 * previously obtained object relation 'Frame'.
70 * The following method tests are to be completed successfully before:
72 * <li> <code> attachFrame() </code> : attachs frame obtained object
73 * relation 'Frame' </li>
77 private PropertyValue
[] xFrameSeq
= null;
78 private PropertyValue
[] xControllerSeq
= null;
79 private PropertyValue
[] xModelSeq
= null;
80 /** Retrieves object relations. */
82 public void before() {
84 xFrameSeq
= (PropertyValue
[]) tEnv
.getObjRelation("XModuleManager.XFrame") ;
86 if (xFrameSeq
== null) throw new StatusException
87 (Status
.failed("Relation 'xFrameSeq' not found.")) ;
90 xControllerSeq
= (PropertyValue
[]) tEnv
.getObjRelation("XModuleManager.XController") ;
92 if (xControllerSeq
== null) throw new StatusException
93 (Status
.failed("Relation 'xControllerSeq' not found.")) ;
96 xModelSeq
= (PropertyValue
[]) tEnv
.getObjRelation("XModuleManager.XModel") ;
98 if (xModelSeq
== null) throw new StatusException
99 (Status
.failed("Relation 'xModelSeq' not found.")) ;
102 /** The method <CODE>identify()</CODE> was tesed for every entry in sequeze of
105 public void _identify() {
107 log
.println("testing frame sequenze...");
108 ok
&= testSequenze(xFrameSeq
);
109 log
.println("testing controller sequenze...");
110 ok
&= testSequenze(xControllerSeq
);
111 log
.println("testing model sequenze...");
112 ok
&= testSequenze(xModelSeq
);
113 tRes
.tested("identify()", ok
);
115 log
.println("testing invalid objects...");
118 } catch (IllegalArgumentException e
){
119 log
.println("expected exception.");
120 } catch (UnknownModuleException e
){
121 log
.println("expected exception.");
125 private boolean testSequenze(PropertyValue
[] sequenze
){
127 for (int i
= 0 ; i
< sequenze
.length
; i
++){
129 log
.println("testing '" + sequenze
[i
].Name
+ "'");
130 if (oObj
.identify(sequenze
[i
].Value
).equals(
134 log
.println("failure: returned value: '" +
135 oObj
.identify(sequenze
[i
].Value
) +
136 "' ,expected value: '" + sequenze
[i
].Name
+ "'");
139 } catch (IllegalArgumentException e
){
140 log
.println("Could not get value of sequenze '" +
141 sequenze
[i
].Name
+ "'");
144 } catch (UnknownModuleException e
){
145 log
.println("Could not indetify value of sequenze '" +
146 sequenze
[i
].Name
+ "'");