Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / style / _XStyle.java
blobce031f9f9e5aa81bb5f29abb87ff609fb98edeb3
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.style;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.style.XStyle;
27 /**
28 * Testing <code>com.sun.star.style.XStyle</code>
29 * interface methods :
30 * <ul>
31 * <li><code> isUserDefined()</code></li>
32 * <li><code> isInUse()</code></li>
33 * <li><code> getParentStyle()</code></li>
34 * <li><code> setParentStyle()</code></li>
35 * </ul> <p>
36 * This test needs the following object relations :
37 * <ul>
38 * <li> <code>'PoolStyle'</code> (of type <code>XStyle</code>):
39 * some style from the SOffice collection (not user defined) </li>
40 * <ul> <p>
41 * Test is <b> NOT </b> multithread compliant. <p>
42 * @see com.sun.star.style.XStyle
44 public class _XStyle extends MultiMethodTest {
46 public XStyle oObj = null;
47 XStyle oMyStyle = null;
49 /**
50 * Retrieves object relations.
51 * @throws StatusException If one of relations not found.
53 @Override
54 public void before() {
55 oMyStyle = (XStyle) tEnv.getObjRelation("PoolStyle");
56 if (oMyStyle == null) throw new StatusException
57 (Status.failed("Relation not found")) ;
60 /**
61 * Gets the parent style . <p>
62 * Has <b> OK </b> status if the name of style returned is
63 * equal to the name of style which was set before. <p>
64 * The following method tests are to be completed successfully before :
65 * <ul>
66 * <li> <code> setParentStyle() </code> : to set the parent style </li>
67 * </ul>
69 public void _getParentStyle() {
70 requiredMethod("setParentStyle()");
71 tRes.tested("getParentStyle()",
72 oObj.getParentStyle().equals(oMyStyle.getName()));
75 /**
76 * Test calls the method. <p>
77 * Has <b> OK </b> status if the method sreturns <code>true</code>. <p>
79 public void _isInUse() {
80 tRes.tested("isInUse()",oObj.isInUse());
83 /**
84 * Test calls the method. <p>
85 * Has <b> OK </b> status if the method returns <code>true</code>. <p>
87 public void _isUserDefined() {
88 tRes.tested("isUserDefined()",
89 oObj.isUserDefined() && !oMyStyle.isUserDefined() );
92 /**
93 * Sets the style name which was passed as relation. <p>
94 * Has <b> OK </b> status if the method successfully returns
95 * and no exceptions were thrown. <p>
97 public void _setParentStyle() {
98 boolean result = true ;
99 try {
100 oObj.setParentStyle(oMyStyle.getName());
101 } catch (com.sun.star.container.NoSuchElementException e) {
102 log.println("Exception occurred while method call: " + e);
103 result = false ;
106 tRes.tested("setParentStyle()",result);
108 } //finish class _XStyle