merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / style / _XStyle.java
blobcd5baeb070e98c9cbbff3b6297bd8dcffa3dac61
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XStyle.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.style;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.style.XStyle;
39 /**
40 * Testing <code>com.sun.star.style.XStyle</code>
41 * interface methods :
42 * <ul>
43 * <li><code> isUserDefined()</code></li>
44 * <li><code> isInUse()</code></li>
45 * <li><code> getParentStyle()</code></li>
46 * <li><code> setParentStyle()</code></li>
47 * </ul> <p>
48 * This test needs the following object relations :
49 * <ul>
50 * <li> <code>'PoolStyle'</code> (of type <code>XStyle</code>):
51 * some style from the SOffice collection (not user defined) </li>
52 * <ul> <p>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.style.XStyle
56 public class _XStyle extends MultiMethodTest {
58 public XStyle oObj = null;
59 XStyle oMyStyle = null;
61 /**
62 * Retrieves object relations.
63 * @throws StatusException If one of relations not found.
65 public void before() {
66 oMyStyle = (XStyle) tEnv.getObjRelation("PoolStyle");
67 if (oMyStyle == null) throw new StatusException
68 (Status.failed("Relation not found")) ;
71 /**
72 * Gets the parent style . <p>
73 * Has <b> OK </b> status if the name of style returned is
74 * equal to the name of style which was set before. <p>
75 * The following method tests are to be completed successfully before :
76 * <ul>
77 * <li> <code> setParentStyle() </code> : to set the parent style </li>
78 * </ul>
80 public void _getParentStyle() {
81 requiredMethod("setParentStyle()");
82 tRes.tested("getParentStyle()",
83 oObj.getParentStyle().equals(oMyStyle.getName()));
86 /**
87 * Test calls the method. <p>
88 * Has <b> OK </b> status if the method sreturns <code>true</code>. <p>
90 public void _isInUse() {
91 tRes.tested("isInUse()",oObj.isInUse());
94 /**
95 * Test calls the method. <p>
96 * Has <b> OK </b> status if the method returns <code>true</code>. <p>
98 public void _isUserDefined() {
99 tRes.tested("isUserDefined()",
100 oObj.isUserDefined() && !oMyStyle.isUserDefined() );
104 * Sets the style name which was passed as relation. <p>
105 * Has <b> OK </b> status if the method successfully returns
106 * and no exceptions were thrown. <p>
108 public void _setParentStyle() {
109 boolean result = true ;
110 try {
111 oObj.setParentStyle(oMyStyle.getName());
112 } catch (com.sun.star.container.NoSuchElementException e) {
113 log.println("Exception occured while method call: " + e);
114 result = false ;
117 tRes.tested("setParentStyle()",result);
119 } //finish class _XStyle