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.util; 29 30 import lib.MultiMethodTest; 31 32 import com.sun.star.util.XModeSelector; 33 34 /** 35 * Testing <code>com.sun.star.util.XModeSelector</code> 36 * interface methods : 37 * <ul> 38 * <li><code>setMode()</code></li> 39 * <li><code>getMode()</code></li> 40 * <li><code>getSupportedModes()</code></li> 41 * <li><code>supportsMode()</code></li> 42 * </ul> <p> 43 * Test is <b> NOT </b> multithread compilant. <p> 44 * @see com.sun.star.util.XModeSelector 45 */ 46 public class _XModeSelector extends MultiMethodTest { 47 public XModeSelector oObj = null; 48 49 String[] supportedModes; 50 /** 51 * Calls the method and as argument pass one of the supported modes 52 * that was returned by method getSupportedMode.<p> 53 * Has <b> OK </b> status if no runtime exceptions occured. 54 */ 55 public void _setMode() { 56 requiredMethod("getSupportedModes()"); 57 try { 58 oObj.setMode(supportedModes[0]); 59 } catch(com.sun.star.lang.NoSupportException e) { 60 log.println("Method setMode() doesn't support mode '" 61 + supportedModes[0] + "'"); 62 tRes.tested("setMode()", false); 63 return ; 64 } 65 tRes.tested("setMode()", true); 66 } 67 68 /** 69 * Calls the method and check returned value.<p> 70 * Has <b> OK </b> status if no runtime exceptions occured 71 * and returned value is equal to value that was set by method setMode. 72 */ 73 public void _getMode() { 74 requiredMethod("setMode()"); 75 String curMode = oObj.getMode(); 76 tRes.tested("getMode()", curMode.equals(supportedModes[0])); 77 } 78 79 /** 80 * Calls the method and checks value returned by method.<p> 81 * Has <b> OK </b> status if no runtime exceptions occured 82 * and returned value is not null. 83 */ 84 public void _getSupportedModes() { 85 supportedModes = oObj.getSupportedModes(); 86 tRes.tested("getSupportedModes()", supportedModes != null); 87 } 88 89 /** 90 * Calls the method. First one of the supported modes that was returned 91 * by method getSupportedMode is passed as argument. 92 * Then the method is called again and the mode that is certainly not supported 93 * is passed. Checks up returned values in both cases.<p> 94 * Has <b> OK </b> status if no runtime exceptions occured, 95 * returned value is true in first call and is false in second call. 96 */ 97 public void _supportsMode() { 98 requiredMethod("getSupportedModes()"); 99 boolean result = oObj.supportsMode(supportedModes[0]) && 100 ! oObj.supportsMode(supportedModes[0] + "_ForTest"); 101 tRes.tested("supportsMode()", result); 102 } 103 }// finish class _XModeSelector 104 105