bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / frame / _XModuleManager.java
blobc894c676dd46907618c94c2d7168f9b8984c61b9
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.frame;
21 import com.sun.star.beans.PropertyValue;
23 import com.sun.star.frame.XModuleManager;
24 import lib.MultiMethodTest;
25 import lib.Status;
26 import lib.StatusException;
28 import com.sun.star.lang.IllegalArgumentException;
29 import com.sun.star.frame.UnknownModuleException;
32 /**
33 * Testing <code>com.sun.star.frame.XModuleManager</code>
34 * interface methods:
35 * <ul>
36 * <li><code> identify() </code></li>
37 * </ul><p>
38 * This test needs the following object relations :
39 * <ul>
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>
49 * </ul> <p>
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;
66 /**
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:
71 * <ul>
72 * <li> <code> attachFrame() </code> : attachs frame obtained object
73 * relation 'Frame' </li>
74 * </ul>
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
103 * object relations.
105 public void _identify() {
106 boolean ok = true;
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...");
116 try{
117 oObj.identify(oObj);
118 } catch (IllegalArgumentException e){
119 log.println("expected exception.");
120 } catch (UnknownModuleException e){
121 log.println("expected exception.");
125 private boolean testSequenze(PropertyValue[] sequenze){
126 boolean ok = true;
127 for (int i = 0 ; i < sequenze.length; i++){
128 try{
129 log.println("testing '" + sequenze[i].Name + "'");
130 if (oObj.identify(sequenze[i].Value).equals(
131 sequenze[i].Name)){
132 ok &= ok;
133 }else{
134 log.println("failure: returned value: '" +
135 oObj.identify(sequenze[i].Value) +
136 "' ,expected value: '" + sequenze[i].Name + "'");
137 ok = false;
139 } catch (IllegalArgumentException e){
140 log.println("Could not get value of sequenze '" +
141 sequenze[i].Name + "'");
142 return false;
144 } catch (UnknownModuleException e){
145 log.println("Could not indetify value of sequenze '" +
146 sequenze[i].Name + "'");
147 return false;
150 return ok;