merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / util / _XModeSelector.java
blobca397ad8952af79954f19e6b84a98db3c1a5e886
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XModeSelector.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.util;
33 import lib.MultiMethodTest;
35 import com.sun.star.util.XModeSelector;
37 /**
38 * Testing <code>com.sun.star.util.XModeSelector</code>
39 * interface methods :
40 * <ul>
41 * <li><code>setMode()</code></li>
42 * <li><code>getMode()</code></li>
43 * <li><code>getSupportedModes()</code></li>
44 * <li><code>supportsMode()</code></li>
45 * </ul> <p>
46 * Test is <b> NOT </b> multithread compilant. <p>
47 * @see com.sun.star.util.XModeSelector
49 public class _XModeSelector extends MultiMethodTest {
50 public XModeSelector oObj = null;
52 String[] supportedModes;
53 /**
54 * Calls the method and as argument pass one of the supported modes
55 * that was returned by method getSupportedMode.<p>
56 * Has <b> OK </b> status if no runtime exceptions occured.
58 public void _setMode() {
59 requiredMethod("getSupportedModes()");
60 try {
61 oObj.setMode(supportedModes[0]);
62 } catch(com.sun.star.lang.NoSupportException e) {
63 log.println("Method setMode() doesn't support mode '"
64 + supportedModes[0] + "'");
65 tRes.tested("setMode()", false);
66 return ;
68 tRes.tested("setMode()", true);
71 /**
72 * Calls the method and check returned value.<p>
73 * Has <b> OK </b> status if no runtime exceptions occured
74 * and returned value is equal to value that was set by method setMode.
76 public void _getMode() {
77 requiredMethod("setMode()");
78 String curMode = oObj.getMode();
79 tRes.tested("getMode()", curMode.equals(supportedModes[0]));
82 /**
83 * Calls the method and checks value returned by method.<p>
84 * Has <b> OK </b> status if no runtime exceptions occured
85 * and returned value is not null.
87 public void _getSupportedModes() {
88 supportedModes = oObj.getSupportedModes();
89 tRes.tested("getSupportedModes()", supportedModes != null);
92 /**
93 * Calls the method. First one of the supported modes that was returned
94 * by method getSupportedMode is passed as argument.
95 * Then the method is called again and the mode that is certainly not supported
96 * is passed. Checks up returned values in both cases.<p>
97 * Has <b> OK </b> status if no runtime exceptions occured,
98 * returned value is true in first call and is false in second call.
100 public void _supportsMode() {
101 requiredMethod("getSupportedModes()");
102 boolean result = oObj.supportsMode(supportedModes[0]) &&
103 ! oObj.supportsMode(supportedModes[0] + "_ForTest");
104 tRes.tested("supportsMode()", result);
106 }// finish class _XModeSelector