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.beans; 29 30 import com.sun.star.beans.PropertyState; 31 import com.sun.star.uno.XInterface; 32 import lib.MultiMethodTest; 33 34 import com.sun.star.beans.XPropertyWithState; 35 import lib.Status; 36 import lib.StatusException; 37 38 /** 39 * Testing <code>com.sun.star.beans.XPropertyWithState</code> 40 * interface methods : 41 * <ul> 42 * <li><code> getDefaultAsProperty()</code></li> 43 * <li><code> getStateAsProperty()</code></li> 44 * <li><code> setToDefaultAsProperty()</code></li> 45 * </ul> <p> 46 * @see com.sun.star.beans.XPropertyWithState 47 */ 48 49 public class _XPropertyWithState extends MultiMethodTest { 50 51 /** 52 * the test object 53 */ 54 public XPropertyWithState oObj; 55 56 57 /** 58 * Test calls the method. 59 * Test has ok status if no 60 * <CODE>com.sun.star.lang.WrappedTargetException</CODE> 61 * was thrown 62 */ 63 public void _getDefaultAsProperty() { 64 try{ 65 66 XInterface defaultState = (XInterface) oObj.getDefaultAsProperty(); 67 68 } catch (com.sun.star.lang.WrappedTargetException e){ 69 e.printStackTrace(log); 70 throw new StatusException(Status.failed("'com.sun.star.lang.WrappedTargetException' was thrown")); 71 } 72 73 tRes.tested("getDefaultAsProperty()", true); 74 } 75 76 /** 77 * Test is ok if <CODE>getStateAsProperty()</CODE> returns 78 * as <CODE>PropertyState</CODE> which is not <CODE>null</CODE> 79 */ 80 public void _getStateAsProperty() { 81 82 boolean res = true; 83 84 PropertyState propState = oObj.getStateAsProperty(); 85 86 if (propState == null) { 87 log.println("the returned PropertyState is null -> FALSE"); 88 res = false; 89 } 90 91 tRes.tested("getStateAsProperty()", res); 92 } 93 94 /** 95 * Test calls the method. 96 * Test has ok status if no 97 * <CODE>com.sun.star.lang.WrappedTargetException</CODE> 98 * was thrown 99 */ 100 public void _setToDefaultAsProperty() { 101 try{ 102 103 oObj.setToDefaultAsProperty(); 104 105 } catch (com.sun.star.lang.WrappedTargetException e){ 106 e.printStackTrace(log); 107 throw new StatusException(Status.failed("'com.sun.star.lang.WrappedTargetException' was thrown")); 108 } 109 110 tRes.tested("setToDefaultAsProperty()", true); 111 } 112 113 } 114