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 import lib.Status;
28 import lib.StatusException;
29 
30 import com.sun.star.beans.XPropertySet;
31 import com.sun.star.util.XIndent;
32 
33 /**
34 * Testing <code>com.sun.star.util.XCancellable</code>
35 * interface methods :
36 * <ul>
37 *  <li><code> decrementIndent()</code></li>
38 *  <li><code> incrementIndent()</code></li>
39 * </ul> <p>
40 * @see com.sun.star.util.XIndent
41 */
42 public class _XIndent extends MultiMethodTest {
43 
44     // oObj filled by MultiMethodTest
45     public XIndent oObj = null ;
46 
47     protected XPropertySet PropSet = null;
48 
49     /**
50      * Ensures that the ObjRelation PropSet is given.
51      */
before()52     public void before() {
53         PropSet = (XPropertySet) tEnv.getObjRelation("PropSet");
54         if (PropSet == null) {
55             throw new StatusException(Status.failed("No PropertySet given"));
56         }
57     }
58 
59     /**
60      * Calls the method. <p>
61      * Has <b>OK</b> status if the property 'ParaIndent' is incremented afterwards<p>
62      */
_incrementIndent()63     public void _incrementIndent() {
64         int oldValue = getIndent();
65         oObj.incrementIndent();
66         int newValue = getIndent();
67         tRes.tested("incrementIndent()", oldValue < newValue) ;
68     }
69 
70     /**
71      * Calls the method. <p>
72      * Has <b>OK</b> status if the property 'ParaIndent' is decremented afterwards<p>
73      * requires 'incrementIndent()' to be executed first.
74      */
_decrementIndent()75     public void _decrementIndent() {
76         requiredMethod("incrementIndent()");
77         int oldValue = getIndent();
78         oObj.decrementIndent();
79         int newValue = getIndent();
80         tRes.tested("decrementIndent()", oldValue > newValue) ;
81     }
82 
getIndent()83     public short getIndent() {
84         short ret = 0;
85         try {
86             ret = ((Short) PropSet.getPropertyValue("ParaIndent")).shortValue();
87         } catch (com.sun.star.beans.UnknownPropertyException upe) {
88         } catch (com.sun.star.lang.WrappedTargetException wte) {
89         }
90         return ret;
91     }
92 
93 }  // finish class _XCancellable
94 
95