1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.awt; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.awt.Rectangle; 29cdf0e10cSrcweir import com.sun.star.awt.WindowDescriptor; 30cdf0e10cSrcweir import com.sun.star.awt.XDevice; 31cdf0e10cSrcweir import com.sun.star.awt.XRegion; 32cdf0e10cSrcweir import com.sun.star.awt.XToolkit; 33cdf0e10cSrcweir import com.sun.star.awt.XWindowPeer; 34cdf0e10cSrcweir import com.sun.star.lang.XComponent; 35cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 36cdf0e10cSrcweir 37cdf0e10cSrcweir /** 38cdf0e10cSrcweir * Testing <code>com.sun.star.awt.XToolkit</code> 39cdf0e10cSrcweir * interface methods: 40cdf0e10cSrcweir * <ul> 41cdf0e10cSrcweir * <li><code> getDesktopWindow() </code></li> 42cdf0e10cSrcweir * <li><code> getWorkArea() </code></li> 43cdf0e10cSrcweir * <li><code> createWindow() </code></li> 44cdf0e10cSrcweir * <li><code> createWindows() </code></li> 45cdf0e10cSrcweir * <li><code> createScreenCompatibleDevice() </code></li> 46cdf0e10cSrcweir * <li><code> createRegion() </code></li> 47cdf0e10cSrcweir * </ul><p> 48cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 49cdf0e10cSrcweir * @see com.sun.star.awt.XToolkit 50cdf0e10cSrcweir */ 51cdf0e10cSrcweir public class _XToolkit extends MultiMethodTest { 52cdf0e10cSrcweir public XToolkit oObj = null; 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** 55cdf0e10cSrcweir * Test calls the method. <p> 56cdf0e10cSrcweir * Has <b> OK </b> status always, because Desktop component 57cdf0e10cSrcweir * currently is not supported as visible. 58cdf0e10cSrcweir */ 59cdf0e10cSrcweir public void _getDesktopWindow() { 60cdf0e10cSrcweir XWindowPeer win = oObj.getDesktopWindow(); 61cdf0e10cSrcweir if (win == null) { 62cdf0e10cSrcweir log.println("getDesktopWindow() returns NULL"); 63cdf0e10cSrcweir } 64cdf0e10cSrcweir tRes.tested("getDesktopWindow()", true); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir /** 68cdf0e10cSrcweir * Test calls the method. <p> 69cdf0e10cSrcweir * Has <b> OK </b> status if the method does not return null. 70cdf0e10cSrcweir */ 71cdf0e10cSrcweir public void _getWorkArea() { 72cdf0e10cSrcweir Rectangle area = oObj.getWorkArea(); 73cdf0e10cSrcweir tRes.tested("getWorkArea()", area != null); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir /** 77cdf0e10cSrcweir * Test calls the method. <p> 78cdf0e10cSrcweir * Has <b> OK </b> status if the method does not return null. 79cdf0e10cSrcweir */ 80cdf0e10cSrcweir public void _createWindow() { 81cdf0e10cSrcweir boolean res = false; 82cdf0e10cSrcweir try { 83cdf0e10cSrcweir XWindowPeer cWin = oObj.createWindow( 84cdf0e10cSrcweir createDesc(new Rectangle(0,0,100,100))); 85cdf0e10cSrcweir if (cWin == null) { 86cdf0e10cSrcweir log.println("createWindow() create a NULL Object"); 87cdf0e10cSrcweir } else { 88cdf0e10cSrcweir UnoRuntime.queryInterface(XComponent.class, cWin).dispose(); 89cdf0e10cSrcweir res = true; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException ex) { 92cdf0e10cSrcweir log.println("Exception occured while checking 'createWindow':"); 93cdf0e10cSrcweir ex.printStackTrace(log); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir tRes.tested("createWindow()", res); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir /** 99cdf0e10cSrcweir * After defining of WindowDescriptor array, test calls the method. <p> 100cdf0e10cSrcweir * Has <b> OK </b> status if all elements of the returned array are 101cdf0e10cSrcweir * not null. 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir public void _createWindows() { 104cdf0e10cSrcweir boolean res = false; 105cdf0e10cSrcweir try { 106cdf0e10cSrcweir WindowDescriptor[] descs = new WindowDescriptor[2]; 107cdf0e10cSrcweir descs[0] = createDesc(new Rectangle(0,0,100,100)); 108cdf0e10cSrcweir descs[1] = createDesc(new Rectangle(100,100,200,200)); 109cdf0e10cSrcweir XWindowPeer[] cWins = oObj.createWindows(descs); 110cdf0e10cSrcweir if ( (cWins[0] == null) || (cWins[1] == null) ) { 111cdf0e10cSrcweir log.println("createWindows() creates NULL Windows"); 112cdf0e10cSrcweir } else { 113cdf0e10cSrcweir UnoRuntime.queryInterface(XComponent.class, cWins[0]).dispose(); 114cdf0e10cSrcweir UnoRuntime.queryInterface(XComponent.class, cWins[1]).dispose(); 115cdf0e10cSrcweir res = true; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException ex) { 118cdf0e10cSrcweir log.println("Exception occured while checking 'createWindows':"); 119cdf0e10cSrcweir ex.printStackTrace(log); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir tRes.tested("createWindows()", res); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir /** 125cdf0e10cSrcweir * Test calls the method. <p> 126cdf0e10cSrcweir * Has <b> OK </b> status if the method does not return null. 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir public void _createScreenCompatibleDevice() { 129cdf0e10cSrcweir XDevice dev = oObj.createScreenCompatibleDevice(100, 100); 130cdf0e10cSrcweir tRes.tested("createScreenCompatibleDevice()", dev != null); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir /** 134cdf0e10cSrcweir * Test calls the method. <p> 135cdf0e10cSrcweir * Has <b> OK </b> status if the method does not return null. 136cdf0e10cSrcweir */ 137cdf0e10cSrcweir public void _createRegion() { 138cdf0e10cSrcweir XRegion reg = oObj.createRegion(); 139cdf0e10cSrcweir tRes.tested("createRegion()", reg != null); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir /** 143cdf0e10cSrcweir * Just creates the WindowDescriptor as an argument for createWindow(). 144cdf0e10cSrcweir */ 145cdf0e10cSrcweir public WindowDescriptor createDesc(Rectangle rect) { 146cdf0e10cSrcweir XWindowPeer win = (XWindowPeer) tEnv.getObjRelation("WINPEER"); 147cdf0e10cSrcweir return new WindowDescriptor(com.sun.star.awt.WindowClass.TOP, 148cdf0e10cSrcweir "", win, (short) -1, rect, com.sun.star.awt.WindowAttribute.SHOW); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153