1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XView.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.awt
.Size
;
36 import com
.sun
.star
.awt
.XGraphics
;
37 import com
.sun
.star
.awt
.XView
;
40 * Testing <code>com.sun.star.awt.XView</code>
43 * <li><code> setGraphics() </code></li>
44 * <li><code> getGraphics() </code></li>
45 * <li><code> getSize() </code></li>
46 * <li><code> draw() </code></li>
47 * <li><code> setZoom() </code></li>
49 * This test needs the following object relations :
51 * <li> <code>'GRAPHICS'</code> (of type <code>XGraphics</code>):
52 * used as a parameter to setGraphics() </li>
54 * Test is <b> NOT </b> multithread compilant. <p>
55 * @see com.sun.star.awt.XView
57 public class _XView
extends MultiMethodTest
{
58 public XView oObj
= null;
61 * After obtaining object relation 'GRAPHICS', test calls the method. <p>
62 * Has <b> OK </b> status if the method returns true.
64 public void _setGraphics() {
65 XGraphics graph
= (XGraphics
) tEnv
.getObjRelation("GRAPHICS");
66 boolean isSet
= oObj
.setGraphics(graph
);
68 log
.println("setGraphics() returns false");
70 tRes
.tested("setGraphics()", isSet
);
74 * Test calls the method. <p>
75 * Has <b> OK </b> status if the method does not return null. <p>
76 * The following method tests are to be completed successfully before :
78 * <li> <code> setGraphics() </code> : sets the output device </li>
81 public void _getGraphics() {
82 requiredMethod("setGraphics()");
83 XGraphics graph
= oObj
.getGraphics();
85 log
.println("getGraphics() returns NULL");
87 tRes
.tested("getGraphics()", graph
!= null);
91 * Test calls the method. <p>
92 * Has <b> OK </b> status if the method returns structure with fields that
93 * are not equal to zero. <p>
94 * The following method tests are to be completed successfully before :
96 * <li> <code> setGraphics() </code> : sets the output device </li>
99 public void _getSize() {
100 requiredMethod("setGraphics()");
101 Size aSize
= oObj
.getSize();
102 boolean res
= (aSize
.Height
!= 0) && (aSize
.Width
!= 0);
104 log
.println("Height: " + aSize
.Height
);
105 log
.println("Width: " + aSize
.Width
);
107 tRes
.tested("getSize()", res
);
111 * Test calls the method. <p>
112 * Has <b> OK </b> status if no exceptions were thrown. <p>
113 * The following method tests are to be completed successfully before :
115 * <li> <code> setGraphics() </code> : sets the output device </li>
118 public void _draw() {
119 requiredMethod("setGraphics()");
121 tRes
.tested("draw()", true);
125 * Test calls the method. <p>
126 * Has <b> OK </b> status if no exceptions were thrown. <p>
127 * The following method tests are to be completed successfully before :
129 * <li> <code> setGraphics() </code> : sets the output device </li>
132 public void _setZoom() {
133 requiredMethod("setGraphics()");
135 tRes
.tested("setZoom()", true);
139 * Forces environment recreation.
141 protected void after() {
142 disposeEnvironment();