1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.inspection;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.inspection.PropertyCategoryDescriptor;
27cdf0e10cSrcweir import com.sun.star.inspection.XObjectInspectorModel;
28cdf0e10cSrcweir import lib.MultiMethodTest;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /**
33cdf0e10cSrcweir  * Testing <code>com.sun.star.inspection.XObjectInspectorModel</code>
34cdf0e10cSrcweir  * interface methods :
35cdf0e10cSrcweir  * <ul>
36cdf0e10cSrcweir  *  <li><code> describeCategories()</code></li>
37cdf0e10cSrcweir  *  <li><code> getHandlerFactories()</code></li>
38cdf0e10cSrcweir  *  <li><code> getPropertyOrderIndex()</code></li>
39cdf0e10cSrcweir  * </ul> <p>
40cdf0e10cSrcweir  * Test is <b> NOT </b> multithread compilant. <p>
41cdf0e10cSrcweir  *
42cdf0e10cSrcweir  */
43cdf0e10cSrcweir public class _XObjectInspectorModel extends MultiMethodTest {
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     /**
46cdf0e10cSrcweir      * the test object
47cdf0e10cSrcweir      */
48cdf0e10cSrcweir     public XObjectInspectorModel oObj = null;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     /**
51cdf0e10cSrcweir      * calls the method <CODE>getHandlerFactories()</CODE>
52cdf0e10cSrcweir      * Has <b>OK</b> status if returned value is not null.
53cdf0e10cSrcweir      */
_HandlerFactories()54cdf0e10cSrcweir     public void _HandlerFactories() {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir         Object[] HandlerFactories = oObj.getHandlerFactories();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir         tRes.tested("HandlerFactories()", HandlerFactories != null) ;
59cdf0e10cSrcweir     }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     /**
62cdf0e10cSrcweir      * Call the method <CODE>getPropertyOrderIndex()</CODE> with an invalid propety name.
63cdf0e10cSrcweir      * Has <CODE>OK</CODE> status if the returned index is "0".
64cdf0e10cSrcweir      */
_getPropertyOrderIndex()65cdf0e10cSrcweir     public void _getPropertyOrderIndex() {
66cdf0e10cSrcweir 
67cdf0e10cSrcweir         int index = 0;
68cdf0e10cSrcweir         boolean result = true;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         log.println("try to get index of INvalid property name 'InvalidPropertyName' ...");
71cdf0e10cSrcweir         index = oObj.getPropertyOrderIndex("InvalidPropertyName");
72cdf0e10cSrcweir         log.println("index is: " + index);
73cdf0e10cSrcweir         result = (index == 0);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir         tRes.tested("getPropertyOrderIndex()", result) ;
76cdf0e10cSrcweir     }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     /**
79cdf0e10cSrcweir      * Call the method <CODE>describeCategories()</CODE>
80cdf0e10cSrcweir      * Has <b>OK</b> status if returned value is not null.
81cdf0e10cSrcweir      */
_describeCategories()82cdf0e10cSrcweir     public void _describeCategories() {
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         PropertyCategoryDescriptor[] categories = oObj.describeCategories();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         tRes.tested("describeCategories()", categories != null) ;
87cdf0e10cSrcweir     }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     /**
90cdf0e10cSrcweir      * Call the method <CODE>getHasHelpSection()</CODE>
91cdf0e10cSrcweir      * Has <b>OK</b> status if method returned </CODE>true</CODE>
92cdf0e10cSrcweir      */
_HasHelpSection()93cdf0e10cSrcweir     public void _HasHelpSection() {
94cdf0e10cSrcweir 
95cdf0e10cSrcweir         boolean hasHelpSection = oObj.getHasHelpSection();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         tRes.tested("HasHelpSection()", hasHelpSection) ;
98cdf0e10cSrcweir     }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     /**
101cdf0e10cSrcweir      * Call the method <CODE>getMinHelpTextLines()</CODE>
102cdf0e10cSrcweir      * Has <b>OK</b> status if returned value equals to object relation 'minHelpTextLines'
103cdf0e10cSrcweir      */
_MinHelpTextLines()104cdf0e10cSrcweir     public void _MinHelpTextLines() {
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         Integer minHelpTextLines = (Integer) tEnv.getObjRelation("minHelpTextLines");
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         int getMinHelpTextLines = oObj.getMinHelpTextLines();
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         boolean result = (minHelpTextLines.intValue() == getMinHelpTextLines);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         if (!result)
113cdf0e10cSrcweir             log.println("FAILED: value:" + minHelpTextLines + " getted value:" + getMinHelpTextLines);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         tRes.tested("MinHelpTextLines()", result) ;
116cdf0e10cSrcweir     }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     /**
119cdf0e10cSrcweir      * Call the method <CODE>getMaxHelpTextLines())</CODE>
120cdf0e10cSrcweir      * Has <b>OK</b> status if returned value equals to object relation 'maxHelpTextLines'
121cdf0e10cSrcweir      */
_MaxHelpTextLines()122cdf0e10cSrcweir     public void _MaxHelpTextLines() {
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         Integer maxHelpTextLines = (Integer) tEnv.getObjRelation("maxHelpTextLines");
125cdf0e10cSrcweir 
126cdf0e10cSrcweir         int getMaxHelpTextLines = oObj.getMaxHelpTextLines();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         boolean result = (maxHelpTextLines.intValue() == getMaxHelpTextLines);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         if (!result)
131cdf0e10cSrcweir             log.println("FAILED: expected value:" + maxHelpTextLines + " getted value:" + getMaxHelpTextLines);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         tRes.tested("MaxHelpTextLines()", result);
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir 
_IsReadOnly()136cdf0e10cSrcweir     public void _IsReadOnly() {
137cdf0e10cSrcweir         boolean readOnly = oObj.getIsReadOnly();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         oObj.setIsReadOnly(!readOnly);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         boolean result = (readOnly != oObj.getIsReadOnly());
142cdf0e10cSrcweir         if (!result){
143cdf0e10cSrcweir             log.println("FAILED: could not change 'IsReadOnly' to value '" + !readOnly + "'");
144cdf0e10cSrcweir         }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         oObj.setIsReadOnly(readOnly);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         result &= (readOnly == oObj.getIsReadOnly());
149cdf0e10cSrcweir         if (!result){
150cdf0e10cSrcweir             log.println("FAILED: could not change back 'IsReadOnly' to value '" + !readOnly + "'");
151cdf0e10cSrcweir         }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         tRes.tested("IsReadOnly()", result);
154cdf0e10cSrcweir     }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir }
157