xref: /aoo41x/main/qadevOOo/tests/java/ifc/awt/_XView.java (revision ef39d40d)
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.awt;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.awt.Size;
29 import com.sun.star.awt.XGraphics;
30 import com.sun.star.awt.XView;
31 
32 /**
33 * Testing <code>com.sun.star.awt.XView</code>
34 * interface methods:
35 * <ul>
36 *  <li><code> setGraphics() </code></li>
37 *  <li><code> getGraphics() </code></li>
38 *  <li><code> getSize() </code></li>
39 *  <li><code> draw() </code></li>
40 *  <li><code> setZoom() </code></li>
41 * </ul><p>
42 * This test needs the following object relations :
43 * <ul>
44 *  <li> <code>'GRAPHICS'</code> (of type <code>XGraphics</code>):
45 *   used as a parameter to setGraphics() </li>
46 * </ul> <p>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * @see com.sun.star.awt.XView
49 */
50 public class _XView extends MultiMethodTest {
51     public XView oObj = null;
52 
53     /**
54     * After obtaining object relation 'GRAPHICS', test calls the method. <p>
55     * Has <b> OK </b> status if the method returns true.
56     */
_setGraphics()57     public void _setGraphics() {
58         XGraphics graph = (XGraphics) tEnv.getObjRelation("GRAPHICS");
59         boolean isSet = oObj.setGraphics(graph);
60         if ( !isSet ) {
61             log.println("setGraphics() returns false");
62         }
63         tRes.tested("setGraphics()", isSet);
64     }
65 
66     /**
67     * Test calls the method. <p>
68     * Has <b> OK </b> status if the method does not return null. <p>
69     * The following method tests are to be completed successfully before :
70     * <ul>
71     *  <li> <code> setGraphics() </code> : sets the output device </li>
72     * </ul>
73     */
_getGraphics()74     public void _getGraphics() {
75         requiredMethod("setGraphics()");
76         XGraphics graph = oObj.getGraphics();
77         if (graph == null) {
78             log.println("getGraphics() returns NULL");
79         }
80         tRes.tested("getGraphics()", graph != null);
81     }
82 
83     /**
84     * Test calls the method. <p>
85     * Has <b> OK </b> status if the method returns structure with fields that
86     * are not equal to zero. <p>
87     * The following method tests are to be completed successfully before :
88     * <ul>
89     *  <li> <code> setGraphics() </code> : sets the output device </li>
90     * </ul>
91     */
_getSize()92     public void _getSize() {
93         requiredMethod("setGraphics()");
94         Size aSize = oObj.getSize();
95         boolean res = (aSize.Height != 0) && (aSize.Width != 0);
96         if ( !res ) {
97             log.println("Height: " + aSize.Height);
98             log.println("Width: " + aSize.Width);
99         }
100         tRes.tested("getSize()", res);
101     }
102 
103     /**
104     * Test calls the method. <p>
105     * Has <b> OK </b> status if no exceptions were thrown. <p>
106     * The following method tests are to be completed successfully before :
107     * <ul>
108     *  <li> <code> setGraphics() </code> : sets the output device </li>
109     * </ul>
110     */
_draw()111     public void _draw() {
112         requiredMethod("setGraphics()");
113         oObj.draw(20, 20);
114         tRes.tested("draw()", true);
115     }
116 
117     /**
118     * Test calls the method. <p>
119     * Has <b> OK </b> status if no exceptions were thrown. <p>
120     * The following method tests are to be completed successfully before :
121     * <ul>
122     *  <li> <code> setGraphics() </code> : sets the output device </li>
123     * </ul>
124     */
_setZoom()125     public void _setZoom() {
126         requiredMethod("setGraphics()");
127         oObj.setZoom(2,2);
128         tRes.tested("setZoom()", true);
129     }
130 
131     /**
132     * Forces environment recreation.
133     */
after()134     protected void after() {
135         disposeEnvironment();
136     }
137 
138 }
139 
140