tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / sc / qa / complex / dataPilot / _XNamed.java
blob5f02077068574eb95e502ba4c4b0a948e82ac40b
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 complex.dataPilot;
21 import com.sun.star.container.XNamed;
22 import lib.TestParameters;
24 /**
25 * Testing <code>com.sun.star.container.XNamed</code>
26 * interface methods :
27 * <ul>
28 * <li><code> getName()</code></li>
29 * <li><code> setName()</code></li>
30 * </ul>
31 * This test need the following object relations :
32 * <ul>
33 * <li> <code>'setName'</code> : of <code>Boolean</code>
34 * type. If it exists then <code>setName</code> method
35 * isn't to be tested and result of this test will be
36 * equal to relation value.</li>
37 * <ul> <p>
38 * Test is <b> NOT </b> multithread compliant. <p>
39 * @see com.sun.star.container.XNamed
41 public class _XNamed {
43 /**
44 * The object that is tested.
46 private final XNamed oObj;
48 /**
49 * Constructor: gets the object to test, a logger and the test parameters
50 * @param xObj The test object
51 * @param param The test parameters
53 public _XNamed(XNamed xObj/*, LogWriter log*/, TestParameters param) {
54 oObj = xObj;
57 /**
58 * Test calls the method and checks return value and that
59 * no exceptions were thrown. <p>
60 * Has <b> OK </b> status if the method returns non null value
61 * and no exceptions were thrown. <p>
63 public boolean _getName() {
65 // write to log what we try next
66 System.out.println( "test for getName()" );
68 boolean result = true;
69 boolean loc_result = true;
70 String name = null;
72 loc_result = ((name = oObj.getName()) != null);
73 System.out.println("getting the name \"" + name + "\"");
75 if (loc_result)
77 System.out.println("... getName() - OK");
79 else
81 System.out.println("... getName() - FAILED");
83 result &= loc_result;
84 return result;
87 /**
88 * Sets a new name for object and checks if it was properly
89 * set. Special cases for the following objects :
90 * <ul>
91 * <li><code>ScSheetLinkObj</code> : name must be in form of URL.</li>
92 * <li><code>ScDDELinkObj</code> : name must contain link to cell in
93 * some external Sheet.</li>
94 * </ul>
95 * Has <b> OK </b> status if new name was successfully set, or if
96 * object environment contains relation <code>'setName'</code> with
97 * value <code>true</code>. <p>
98 * The following method tests are to be completed successfully before :
99 * <ul>
100 * <li> <code> getName() </code> : to be sure the method works</li>
101 * </ul>
103 public boolean _setName(){
104 System.out.println("testing setName() ... ");
106 String oldName = oObj.getName();
107 String NewName = oldName == null ? "XNamed" : oldName + "X" ;
109 boolean result = true;
110 boolean loc_result = true;
111 System.out.println("set the name of object to \"" + NewName + "\"");
112 oObj.setName(NewName);
113 System.out.println("check that container has element with this name");
115 String name = oObj.getName();
116 System.out.println("getting the name \"" + name + "\"");
117 loc_result = name.equals(NewName);
119 if (loc_result)
121 System.out.println("... setName() - OK");
123 else
125 System.out.println("... setName() - FAILED");
127 result &= loc_result;
128 oObj.setName(oldName);
129 return result;