Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XView.java
bloba7858d037dc5f10899dcd640b7a4f5ebb5f006a4
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.awt;
21 import lib.MultiMethodTest;
23 import com.sun.star.awt.Size;
24 import com.sun.star.awt.XGraphics;
25 import com.sun.star.awt.XView;
27 /**
28 * Testing <code>com.sun.star.awt.XView</code>
29 * interface methods:
30 * <ul>
31 * <li><code> setGraphics() </code></li>
32 * <li><code> getGraphics() </code></li>
33 * <li><code> getSize() </code></li>
34 * <li><code> draw() </code></li>
35 * <li><code> setZoom() </code></li>
36 * </ul><p>
37 * This test needs the following object relations :
38 * <ul>
39 * <li> <code>'GRAPHICS'</code> (of type <code>XGraphics</code>):
40 * used as a parameter to setGraphics() </li>
41 * </ul> <p>
42 * Test is <b> NOT </b> multithread compliant. <p>
43 * @see com.sun.star.awt.XView
45 public class _XView extends MultiMethodTest {
46 public XView oObj = null;
48 /**
49 * After obtaining object relation 'GRAPHICS', test calls the method. <p>
50 * Has <b> OK </b> status if the method returns true.
52 public void _setGraphics() {
53 XGraphics graph = (XGraphics) tEnv.getObjRelation("GRAPHICS");
54 boolean isSet = oObj.setGraphics(graph);
55 if ( !isSet ) {
56 log.println("setGraphics() returns false");
58 tRes.tested("setGraphics()", isSet);
61 /**
62 * Test calls the method. <p>
63 * Has <b> OK </b> status if the method does not return null. <p>
64 * The following method tests are to be completed successfully before :
65 * <ul>
66 * <li> <code> setGraphics() </code> : sets the output device </li>
67 * </ul>
69 public void _getGraphics() {
70 requiredMethod("setGraphics()");
71 XGraphics graph = oObj.getGraphics();
72 if (graph == null) {
73 log.println("getGraphics() returns NULL");
75 tRes.tested("getGraphics()", graph != null);
78 /**
79 * Test calls the method. <p>
80 * Has <b> OK </b> status if the method returns structure with fields that
81 * are not equal to zero. <p>
82 * The following method tests are to be completed successfully before :
83 * <ul>
84 * <li> <code> setGraphics() </code> : sets the output device </li>
85 * </ul>
87 public void _getSize() {
88 requiredMethod("setGraphics()");
89 Size aSize = oObj.getSize();
90 boolean res = (aSize.Height != 0) && (aSize.Width != 0);
91 if ( !res ) {
92 log.println("Height: " + aSize.Height);
93 log.println("Width: " + aSize.Width);
95 tRes.tested("getSize()", res);
98 /**
99 * Test calls the method. <p>
100 * Has <b> OK </b> status if no exceptions were thrown. <p>
101 * The following method tests are to be completed successfully before :
102 * <ul>
103 * <li> <code> setGraphics() </code> : sets the output device </li>
104 * </ul>
106 public void _draw() {
107 requiredMethod("setGraphics()");
108 oObj.draw(20, 20);
109 tRes.tested("draw()", true);
113 * Test calls the method. <p>
114 * Has <b> OK </b> status if no exceptions were thrown. <p>
115 * The following method tests are to be completed successfully before :
116 * <ul>
117 * <li> <code> setGraphics() </code> : sets the output device </li>
118 * </ul>
120 public void _setZoom() {
121 requiredMethod("setGraphics()");
122 oObj.setZoom(2,2);
123 tRes.tested("setZoom()", true);
127 * Forces environment recreation.
129 @Override
130 protected void after() {
131 disposeEnvironment();