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.style;
25 
26 import lib.MultiMethodTest;
27 import lib.Status;
28 import lib.StatusException;
29 
30 import com.sun.star.style.XStyle;
31 
32 /**
33 * Testing <code>com.sun.star.style.XStyle</code>
34 * interface methods :
35 * <ul>
36 *  <li><code> isUserDefined()</code></li>
37 *  <li><code> isInUse()</code></li>
38 *  <li><code> getParentStyle()</code></li>
39 *  <li><code> setParentStyle()</code></li>
40 * </ul> <p>
41 * This test needs the following object relations :
42 * <ul>
43 *  <li> <code>'PoolStyle'</code> (of type <code>XStyle</code>):
44 *   some style from the SOffice collection (not user defined) </li>
45 * <ul> <p>
46 * Test is <b> NOT </b> multithread compilant. <p>
47 * @see com.sun.star.style.XStyle
48 */
49 public class _XStyle extends MultiMethodTest {
50 
51     public XStyle oObj = null;
52     XStyle oMyStyle = null;
53 
54     /**
55     * Retrieves object relations.
56     * @throws StatusException If one of relations not found.
57     */
before()58     public void before() {
59         oMyStyle = (XStyle) tEnv.getObjRelation("PoolStyle");
60         if (oMyStyle == null) throw new StatusException
61             (Status.failed("Relation not found")) ;
62     }
63 
64     /**
65     * Gets the parent style . <p>
66     * Has <b> OK </b> status if the name of style returned is
67     * equal to the name of style which was set before. <p>
68     * The following method tests are to be completed successfully before :
69     * <ul>
70     *  <li> <code> setParentStyle() </code> : to set the parent style </li>
71     * </ul>
72     */
_getParentStyle()73     public void _getParentStyle() {
74         requiredMethod("setParentStyle()");
75         tRes.tested("getParentStyle()",
76             oObj.getParentStyle().equals(oMyStyle.getName()));
77     }
78 
79     /**
80     * Test calls the method. <p>
81     * Has <b> OK </b> status if the method sreturns <code>true</code>. <p>
82     */
_isInUse()83     public void _isInUse() {
84         tRes.tested("isInUse()",oObj.isInUse());
85     }
86 
87     /**
88     * Test calls the method. <p>
89     * Has <b> OK </b> status if the method returns <code>true</code>. <p>
90     */
_isUserDefined()91     public void _isUserDefined() {
92         tRes.tested("isUserDefined()",
93             oObj.isUserDefined() && !oMyStyle.isUserDefined() );
94     }
95 
96     /**
97     * Sets the style name which was passed as relation. <p>
98     * Has <b> OK </b> status if the method successfully returns
99     * and no exceptions were thrown. <p>
100     */
_setParentStyle()101     public void _setParentStyle() {
102         boolean result = true ;
103         try {
104             oObj.setParentStyle(oMyStyle.getName());
105         } catch (com.sun.star.container.NoSuchElementException e) {
106             log.println("Exception occurred while method call: " + e);
107             result = false ;
108         }
109 
110         tRes.tested("setParentStyle()",result);
111     }
112 } //finish class _XStyle
113 
114