1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import lib
.StatusException
;
34 import com
.sun
.star
.style
.XStyle
;
37 * Testing <code>com.sun.star.style.XStyle</code>
40 * <li><code> isUserDefined()</code></li>
41 * <li><code> isInUse()</code></li>
42 * <li><code> getParentStyle()</code></li>
43 * <li><code> setParentStyle()</code></li>
45 * This test needs the following object relations :
47 * <li> <code>'PoolStyle'</code> (of type <code>XStyle</code>):
48 * some style from the SOffice collection (not user defined) </li>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.style.XStyle
53 public class _XStyle
extends MultiMethodTest
{
55 public XStyle oObj
= null;
56 XStyle oMyStyle
= null;
59 * Retrieves object relations.
60 * @throws StatusException If one of relations not found.
62 public void before() {
63 oMyStyle
= (XStyle
) tEnv
.getObjRelation("PoolStyle");
64 if (oMyStyle
== null) throw new StatusException
65 (Status
.failed("Relation not found")) ;
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 :
74 * <li> <code> setParentStyle() </code> : to set the parent style </li>
77 public void _getParentStyle() {
78 requiredMethod("setParentStyle()");
79 tRes
.tested("getParentStyle()",
80 oObj
.getParentStyle().equals(oMyStyle
.getName()));
84 * Test calls the method. <p>
85 * Has <b> OK </b> status if the method sreturns <code>true</code>. <p>
87 public void _isInUse() {
88 tRes
.tested("isInUse()",oObj
.isInUse());
92 * Test calls the method. <p>
93 * Has <b> OK </b> status if the method returns <code>true</code>. <p>
95 public void _isUserDefined() {
96 tRes
.tested("isUserDefined()",
97 oObj
.isUserDefined() && !oMyStyle
.isUserDefined() );
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>
105 public void _setParentStyle() {
106 boolean result
= true ;
108 oObj
.setParentStyle(oMyStyle
.getName());
109 } catch (com
.sun
.star
.container
.NoSuchElementException e
) {
110 log
.println("Exception occurred while method call: " + e
);
114 tRes
.tested("setParentStyle()",result
);
116 } //finish class _XStyle