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
;
23 // import share.LogWriter;
27 * Testing <code>com.sun.star.container.XNamed</code>
30 * <li><code> getName()</code></li>
31 * <li><code> setName()</code></li>
33 * This test need the following object relations :
35 * <li> <code>'setName'</code> : of <code>Boolean</code>
36 * type. If it exists then <code>setName</code> method
37 * isn't to be tested and result of this test will be
38 * equal to relation value.</li>
40 * Test is <b> NOT </b> multithread compilant. <p>
41 * @see com.sun.star.container.XNamed
43 public class _XNamed
{
46 * The object that is testsed.
48 public XNamed oObj
= null;
53 private TestParameters param
= null;
58 // private LogWriter log = null;
61 * Constructor: gets the object to test, a logger and the test parameters
62 * @param xObj The test object
63 * @param log A log writer
64 * @param param The test parameters
66 public _XNamed(XNamed xObj
/*, LogWriter log*/, TestParameters param
) {
73 * Test calls the method and checks return value and that
74 * no exceptions were thrown. <p>
75 * Has <b> OK </b> status if the method returns non null value
76 * and no exceptions were thrown. <p>
78 public boolean _getName() {
80 // write to log what we try next
81 System
.out
.println( "test for getName()" );
83 boolean result
= true;
84 boolean loc_result
= true;
86 String NewName
= null;
88 loc_result
= ((name
= oObj
.getName()) != null);
89 System
.out
.println("getting the name \"" + name
+ "\"");
93 System
.out
.println("... getName() - OK");
97 System
.out
.println("... getName() - FAILED");
104 * Sets a new name for object and checks if it was properly
105 * set. Special cases for the following objects :
107 * <li><code>ScSheetLinkObj</code> : name must be in form of URL.</li>
108 * <li><code>ScDDELinkObj</code> : name must contain link to cell in
109 * some external Sheet.</li>
111 * Has <b> OK </b> status if new name was successfully set, or if
112 * object environment contains relation <code>'setName'</code> with
113 * value <code>true</code>. <p>
114 * The following method tests are to be completed successfully before :
116 * <li> <code> getName() </code> : to be sure the method works</li>
119 public boolean _setName(){
120 // requiredMethod("getName()");
121 System
.out
.println("testing setName() ... ");
123 String oldName
= oObj
.getName();
124 String NewName
= oldName
== null ?
"XNamed" : oldName
+ "X" ;
126 boolean result
= true;
127 boolean loc_result
= true;
128 System
.out
.println("set the name of object to \"" + NewName
+ "\"");
129 oObj
.setName(NewName
);
130 System
.out
.println("check that container has element with this name");
132 String name
= oObj
.getName();
133 System
.out
.println("getting the name \"" + name
+ "\"");
134 loc_result
= name
.equals(NewName
);
138 System
.out
.println("... setName() - OK");
142 System
.out
.println("... setName() - FAILED");
144 result
&= loc_result
;
145 oObj
.setName(oldName
);