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