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