Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / frame / _XModuleManager.java
blob3af654a9e13f62709310220bfdbb1bc4e4309fbe
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XModuleManager.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.frame;
33 import com.sun.star.beans.PropertyValue;
35 import com.sun.star.frame.XModuleManager;
36 import lib.MultiMethodTest;
37 import lib.Status;
38 import lib.StatusException;
40 import com.sun.star.lang.IllegalArgumentException;
41 import com.sun.star.frame.UnknownModuleException;
44 /**
45 * Testing <code>com.sun.star.frame.XModuleManager</code>
46 * interface methods:
47 * <ul>
48 * <li><code> identify() </code></li>
49 * </ul><p>
50 * This test needs the following object relations :
51 * <ul>
52 * <li> <code>'XModuleManager.XFrame'</code> (of type <code>PropertyValue[]</code>):
53 * PropertyValue[n].Value : a XFrame
54 * PropertyValue[n].Name : the expected return value of <code>idendify()</code></li>
55 * <li> <code>'XModuleManager.XController'</code> (of type <code>PropertyValue[]</code>):
56 * PropertyValue[n].Value : a XController
57 * PropertyValue[n].Name : the expected return value of <code>idendify()</code></li>
58 * <li> <code>'XModuleManager.XModel'</code> (of type <code>PropertyValue[]</code>):
59 * PropertyValue[n].Value : a XFrame
60 * PropertyValue[n].Name : the expected return value of <code>idendify()</code></li>
61 * </ul> <p>
62 * Test is <b> NOT </b> multithread compilant. <p>
63 * @see com.sun.star.frame.XModuleManager
65 public class _XModuleManager extends MultiMethodTest {
66 /** Test calls the method. <p>
67 * The onject relations <CODE>XModuleManager.XFrame</CODE>,
68 * <CODE>XModuleManager.XController</CODE> and <CODE>XModuleManager.XModel</CODE>
69 * are sequenzes of <CODE>PropertyValue</CODE>. The value of a PropertyValue
70 * containes a <CODE>XFrame</CODE>, <CODE>XController</CODE> or a
71 * <CODE>XModel</CODE>. The name of the PropertyValue contains the expected return
72 * value of method <CODE>indetify()</CODE> if the method was called with
73 * coresponding value.<p>
74 * As enhancement the method <CODE>identify()</CODE> was called with incvalid
75 * parameter. In this case the thrown exceptions was catched.
76 */
77 public XModuleManager oObj = null;
78 /**
79 * Test calls the method. <p>
80 * Has <b> OK </b> status if the method returns expected values, that's equal to
81 * previously obtained object relation 'Frame'.
82 * The following method tests are to be completed successfully before:
83 * <ul>
84 * <li> <code> attachFrame() </code> : attachs frame obtained object
85 * relation 'Frame' </li>
86 * </ul>
89 private PropertyValue[] xFrameSeq = null;
90 private PropertyValue[] xControllerSeq = null;
91 private PropertyValue[] xModelSeq = null;
92 /** Retrieves object relations. */
94 public void before() {
96 xFrameSeq = (PropertyValue[]) tEnv.getObjRelation("XModuleManager.XFrame") ;
98 if (xFrameSeq == null) throw new StatusException
99 (Status.failed("Relation 'xFrameSeq' not found.")) ;
102 xControllerSeq = (PropertyValue[]) tEnv.getObjRelation("XModuleManager.XController") ;
104 if (xControllerSeq == null) throw new StatusException
105 (Status.failed("Relation 'xControllerSeq' not found.")) ;
108 xModelSeq = (PropertyValue[]) tEnv.getObjRelation("XModuleManager.XModel") ;
110 if (xModelSeq == null) throw new StatusException
111 (Status.failed("Relation 'xModelSeq' not found.")) ;
114 /** The method <CODE>identify()</CODE> was tesed for every entry in sequeze of
115 * object relations.
117 public void _identify() {
118 boolean ok = true;
119 log.println("testing frame sequenze...");
120 ok &= testSequenze(xFrameSeq);
121 log.println("testing controller sequenze...");
122 ok &= testSequenze(xControllerSeq);
123 log.println("testing model sequenze...");
124 ok &= testSequenze(xModelSeq);
125 tRes.tested("identify()", ok);
127 log.println("testing invalid objects...");
128 try{
129 oObj.identify(oObj);
130 } catch (IllegalArgumentException e){
131 log.println("expected exception.");
132 } catch (UnknownModuleException e){
133 log.println("expected exception.");
137 private boolean testSequenze(PropertyValue[] sequenze){
138 boolean ok = true;
139 for (int i = 0 ; i < sequenze.length; i++){
140 try{
141 log.println("testing '" + sequenze[i].Name + "'");
142 if (oObj.identify(sequenze[i].Value).equals(
143 sequenze[i].Name)){
144 ok &= ok;
145 }else{
146 log.println("failure: returned value: '" +
147 oObj.identify(sequenze[i].Value) +
148 "' ,expected value: '" + sequenze[i].Name + "'");
149 ok = false;
151 } catch (IllegalArgumentException e){
152 log.println("Could not get value of sequenze '" +
153 sequenze[i].Name + "'");
154 return false;
156 } catch (UnknownModuleException e){
157 log.println("Could not indetify value of sequenze '" +
158 sequenze[i].Name + "'");
159 return false;
162 return ok;