1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XNamed.java,v $
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 complex
.dataPilot
.interfaceTests
.container
;
33 import com
.sun
.star
.container
.XNamed
;
34 import lib
.TestParameters
;
35 import share
.LogWriter
;
39 * Testing <code>com.sun.star.container.XNamed</code>
42 * <li><code> getName()</code></li>
43 * <li><code> setName()</code></li>
45 * This test need the following object relations :
47 * <li> <code>'setName'</code> : of <code>Boolean</code>
48 * type. If it exists then <code>setName</code> method
49 * isn't to be tested and result of this test will be
50 * equal to relation value.</li>
52 * Test is <b> NOT </b> multithread compilant. <p>
53 * @see com.sun.star.container.XNamed
55 public class _XNamed
{
58 * The object that is testsed.
60 public XNamed oObj
= null;
65 private TestParameters param
= null;
70 private LogWriter log
= null;
73 * Constructor: gets the object to test, a logger and the test parameters
74 * @param xObj The test object
75 * @param log A log writer
76 * @param param The test parameters
78 public _XNamed(XNamed xObj
, LogWriter log
, TestParameters param
) {
85 * Test calls the method and checks return value and that
86 * no exceptions were thrown. <p>
87 * Has <b> OK </b> status if the method returns non null value
88 * and no exceptions were thrown. <p>
90 public boolean _getName() {
92 // write to log what we try next
93 log
.println( "test for getName()" );
95 boolean result
= true;
96 boolean loc_result
= true;
98 String NewName
= null;
100 loc_result
= ((name
= oObj
.getName()) != null);
101 log
.println("getting the name \"" + name
+ "\"");
103 if (loc_result
) log
.println("... getName() - OK");
104 else log
.println("... getName() - FAILED");
105 result
&= loc_result
;
110 * Sets a new name for object and checks if it was properly
111 * set. Special cases for the following objects :
113 * <li><code>ScSheetLinkObj</code> : name must be in form of URL.</li>
114 * <li><code>ScDDELinkObj</code> : name must contain link to cell in
115 * some external Sheet.</li>
117 * Has <b> OK </b> status if new name was successfully set, or if
118 * object environment contains relation <code>'setName'</code> with
119 * value <code>true</code>. <p>
120 * The following method tests are to be completed successfully before :
122 * <li> <code> getName() </code> : to be sure the method works</li>
125 public boolean _setName(){
126 // requiredMethod("getName()");
127 log
.println("testing setName() ... ");
129 String oldName
= oObj
.getName();
130 String NewName
= oldName
== null ?
"XNamed" : oldName
+ "X" ;
132 boolean result
= true;
133 boolean loc_result
= true;
134 log
.println("set the name of object to \"" + NewName
+ "\"");
135 oObj
.setName(NewName
);
136 log
.println("check that container has element with this name");
138 String name
= oObj
.getName();
139 log
.println("getting the name \"" + name
+ "\"");
140 loc_result
= name
.equals(NewName
);
142 if (loc_result
) log
.println("... setName() - OK");
143 else log
.println("... setName() - FAILED");
144 result
&= loc_result
;
145 oObj
.setName(oldName
);