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