1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.util;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.util.XModeSelector;
29 
30 /**
31 * Testing <code>com.sun.star.util.XModeSelector</code>
32 * interface methods :
33 * <ul>
34 *  <li><code>setMode()</code></li>
35 *  <li><code>getMode()</code></li>
36 *  <li><code>getSupportedModes()</code></li>
37 *  <li><code>supportsMode()</code></li>
38 * </ul> <p>
39 * Test is <b> NOT </b> multithread compilant. <p>
40 * @see com.sun.star.util.XModeSelector
41 */
42 public class _XModeSelector extends MultiMethodTest {
43     public XModeSelector oObj = null;
44 
45     String[] supportedModes;
46     /**
47     * Calls the method and as argument pass one of the supported modes
48     * that was returned by method getSupportedMode.<p>
49     * Has <b> OK </b> status if no runtime exceptions occurred.
50     */
_setMode()51     public void _setMode() {
52         requiredMethod("getSupportedModes()");
53         try {
54             oObj.setMode(supportedModes[0]);
55         } catch(com.sun.star.lang.NoSupportException e) {
56             log.println("Method setMode() doesn't support mode '"
57                  + supportedModes[0] + "'");
58             tRes.tested("setMode()", false);
59             return ;
60         }
61         tRes.tested("setMode()", true);
62     }
63 
64     /**
65     * Calls the method and check returned value.<p>
66     * Has <b> OK </b> status if no runtime exceptions occurred
67     * and returned value is equal to value that was set by method setMode.
68     */
_getMode()69     public void _getMode() {
70         requiredMethod("setMode()");
71         String curMode = oObj.getMode();
72         tRes.tested("getMode()", curMode.equals(supportedModes[0]));
73     }
74 
75     /**
76     * Calls the method and checks value returned by method.<p>
77     * Has <b> OK </b> status if no runtime exceptions occurred
78     * and returned value is not null.
79     */
_getSupportedModes()80     public void _getSupportedModes() {
81         supportedModes = oObj.getSupportedModes();
82         tRes.tested("getSupportedModes()", supportedModes != null);
83     }
84 
85     /**
86     * Calls the method. First  one of the supported modes that was returned
87     * by method getSupportedMode is passed as argument.
88     * Then the method is called again and the mode that is certainly not supported
89     * is passed. Checks up returned values in both cases.<p>
90     * Has <b> OK </b> status if no runtime exceptions occurred,
91     * returned value is true in first call and is false in second call.
92     */
_supportsMode()93     public void _supportsMode() {
94         requiredMethod("getSupportedModes()");
95         boolean result = oObj.supportsMode(supportedModes[0]) &&
96             ! oObj.supportsMode(supportedModes[0] + "_ForTest");
97         tRes.tested("supportsMode()", result);
98     }
99 }// finish class _XModeSelector
100 
101