xref: /AOO41X/main/qadevOOo/tests/java/ifc/inspection/_XObjectInspectorModel.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package ifc.inspection;
29 
30 import com.sun.star.inspection.PropertyCategoryDescriptor;
31 import com.sun.star.inspection.XObjectInspectorModel;
32 import lib.MultiMethodTest;
33 
34 
35 
36 /**
37  * Testing <code>com.sun.star.inspection.XObjectInspectorModel</code>
38  * interface methods :
39  * <ul>
40  *  <li><code> describeCategories()</code></li>
41  *  <li><code> getHandlerFactories()</code></li>
42  *  <li><code> getPropertyOrderIndex()</code></li>
43  * </ul> <p>
44  * Test is <b> NOT </b> multithread compilant. <p>
45  *
46  */
47 public class _XObjectInspectorModel extends MultiMethodTest {
48 
49     /**
50      * the test object
51      */
52     public XObjectInspectorModel oObj = null;
53 
54     /**
55      * calls the method <CODE>getHandlerFactories()</CODE>
56      * Has <b>OK</b> status if returned value is not null.
57      */
58     public void _HandlerFactories() {
59 
60         Object[] HandlerFactories = oObj.getHandlerFactories();
61 
62         tRes.tested("HandlerFactories()", HandlerFactories != null) ;
63     }
64 
65     /**
66      * Call the method <CODE>getPropertyOrderIndex()</CODE> with an invalid propety name.
67      * Has <CODE>OK</CODE> status if the returned index is "0".
68      */
69     public void _getPropertyOrderIndex() {
70 
71         int index = 0;
72         boolean result = true;
73 
74         log.println("try to get index of INvalid property name 'InvalidPropertyName' ...");
75         index = oObj.getPropertyOrderIndex("InvalidPropertyName");
76         log.println("index is: " + index);
77         result = (index == 0);
78 
79         tRes.tested("getPropertyOrderIndex()", result) ;
80     }
81 
82     /**
83      * Call the method <CODE>describeCategories()</CODE>
84      * Has <b>OK</b> status if returned value is not null.
85      */
86     public void _describeCategories() {
87 
88         PropertyCategoryDescriptor[] categories = oObj.describeCategories();
89 
90         tRes.tested("describeCategories()", categories != null) ;
91     }
92 
93     /**
94      * Call the method <CODE>getHasHelpSection()</CODE>
95      * Has <b>OK</b> status if method returned </CODE>true</CODE>
96      */
97     public void _HasHelpSection() {
98 
99         boolean hasHelpSection = oObj.getHasHelpSection();
100 
101         tRes.tested("HasHelpSection()", hasHelpSection) ;
102     }
103 
104     /**
105      * Call the method <CODE>getMinHelpTextLines()</CODE>
106      * Has <b>OK</b> status if returned value equals to object relation 'minHelpTextLines'
107      */
108     public void _MinHelpTextLines() {
109 
110         Integer minHelpTextLines = (Integer) tEnv.getObjRelation("minHelpTextLines");
111 
112         int getMinHelpTextLines = oObj.getMinHelpTextLines();
113 
114         boolean result = (minHelpTextLines.intValue() == getMinHelpTextLines);
115 
116         if (!result)
117             log.println("FAILED: value:" + minHelpTextLines + " getted value:" + getMinHelpTextLines);
118 
119         tRes.tested("MinHelpTextLines()", result) ;
120     }
121 
122     /**
123      * Call the method <CODE>getMaxHelpTextLines())</CODE>
124      * Has <b>OK</b> status if returned value equals to object relation 'maxHelpTextLines'
125      */
126     public void _MaxHelpTextLines() {
127 
128         Integer maxHelpTextLines = (Integer) tEnv.getObjRelation("maxHelpTextLines");
129 
130         int getMaxHelpTextLines = oObj.getMaxHelpTextLines();
131 
132         boolean result = (maxHelpTextLines.intValue() == getMaxHelpTextLines);
133 
134         if (!result)
135             log.println("FAILED: expected value:" + maxHelpTextLines + " getted value:" + getMaxHelpTextLines);
136 
137         tRes.tested("MaxHelpTextLines()", result);
138     }
139 
140     public void _IsReadOnly() {
141         boolean readOnly = oObj.getIsReadOnly();
142 
143         oObj.setIsReadOnly(!readOnly);
144 
145         boolean result = (readOnly != oObj.getIsReadOnly());
146         if (!result){
147             log.println("FAILED: could not change 'IsReadOnly' to value '" + !readOnly + "'");
148         }
149 
150         oObj.setIsReadOnly(readOnly);
151 
152         result &= (readOnly == oObj.getIsReadOnly());
153         if (!result){
154             log.println("FAILED: could not change back 'IsReadOnly' to value '" + !readOnly + "'");
155         }
156 
157         tRes.tested("IsReadOnly()", result);
158     }
159 
160 }
161