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
;
25 * Testing <code>com.sun.star.container.XNamed</code>
28 * <li><code> getName()</code></li>
29 * <li><code> setName()</code></li>
31 * This test need the following object relations :
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>
38 * Test is <b> NOT </b> multithread compliant. <p>
39 * @see com.sun.star.container.XNamed
41 public class _XNamed
{
44 * The object that is testsed.
46 private final XNamed oObj
;
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
) {
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;
72 loc_result
= ((name
= oObj
.getName()) != null);
73 System
.out
.println("getting the name \"" + name
+ "\"");
77 System
.out
.println("... getName() - OK");
81 System
.out
.println("... getName() - FAILED");
88 * Sets a new name for object and checks if it was properly
89 * set. Special cases for the following objects :
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>
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 :
100 * <li> <code> getName() </code> : to be sure the method works</li>
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
);
121 System
.out
.println("... setName() - OK");
125 System
.out
.println("... setName() - FAILED");
127 result
&= loc_result
;
128 oObj
.setName(oldName
);