1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 package ifc
.container
;
29 import com
.sun
.star
.container
.XNamed
;
31 import lib
.MultiMethodTest
;
37 * Testing <code>com.sun.star.container.XNamed</code>
40 * <li><code> getName()</code></li>
41 * <li><code> setName()</code></li>
43 * This test need the following object relations :
45 * <li> <code>'setName'</code> : of <code>Boolean</code>
46 * type. If it exists then <code>setName</code> method
47 * isn't to be tested and result of this test will be
48 * equal to relation value.</li>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.container.XNamed
53 public class _XNamed
extends MultiMethodTest
{
54 public XNamed oObj
= null; // oObj filled by MultiMethodTest
57 * Test calls the method and checks return value and that
58 * no exceptions were thrown. <p>
59 * Has <b> OK </b> status if the method returns non null value
60 * and no exceptions were thrown. <p>
62 public void _getName() {
63 // write to log what we try next
64 log
.println("test for getName()");
66 boolean result
= true;
67 boolean loc_result
= true;
70 loc_result
= ((name
= oObj
.getName()) != null);
71 log
.println("getting the name \"" + name
+ "\"");
74 log
.println("... getName() - OK");
76 log
.println("... getName() - FAILED");
80 tRes
.tested("getName()", result
);
84 * Sets a new name for object and checks if it was properly
85 * set. Special cases for the following objects :
87 * <li><code>ScSheetLinkObj</code> : name must be in form of URL.</li>
88 * <li><code>ScDDELinkObj</code> : name must contain link to cell in
89 * some external Sheet.</li>
91 * Has <b> OK </b> status if new name was successfully set, or if
92 * object environment contains relation <code>'setName'</code> with
93 * value <code>true</code>. <p>
94 * The following method tests are to be completed successfully before :
96 * <li> <code> getName() </code> : to be sure the method works</li>
99 public void _setName() {
100 String Oname
= tEnv
.getTestCase().getObjectName();
101 String nsn
= (String
) tEnv
.getObjRelation("NoSetName");
107 if ((Oname
.indexOf("Exporter") > 0) || (nsn
!= null)) {
108 log
.println("With " + Oname
+ " setName() doesn't work");
109 log
.println("see idl-file for further information");
110 tRes
.tested("setName()", true);
115 requiredMethod("getName()");
116 log
.println("testing setName() ... ");
118 String oldName
= oObj
.getName();
119 String NewName
= (oldName
== null) ?
"XNamed" : oldName
+ "X";
121 String testobjname
= tEnv
.getTestCase().getObjectName();
123 if (testobjname
.equals("ScSheetLinkObj")) {
124 // special case, here name is equals to links URL.
125 NewName
= "file:///c:/somename/from/XNamed";
126 } else if (testobjname
.equals("ScDDELinkObj")) {
127 String fileName
= utils
.getFullTestDocName("ScDDELinksObj.ods");
128 NewName
= "soffice|" + fileName
+ "!Sheet1.A2";
129 } else if (testobjname
.equals("SwXAutoTextGroup")) {
131 NewName
= "XNamed*1";
134 boolean result
= true;
135 boolean loc_result
= true;
136 Boolean sName
= (Boolean
) tEnv
.getObjRelation("setName");
139 log
.println("set the name of object to \"" + NewName
+ "\"");
140 oObj
.setName(NewName
);
141 log
.println("check that container has element with this name");
143 String name
= oObj
.getName();
144 log
.println("getting the name \"" + name
+ "\"");
145 loc_result
= name
.equals(NewName
);
148 log
.println("... setName() - OK");
150 log
.println("... setName() - FAILED");
153 result
&= loc_result
;
154 oObj
.setName(oldName
);
156 log
.println("The names for the object '" + testobjname
+
158 log
.println("It is not possible to rename.");
159 log
.println("So 'setName()' is always OK");
160 result
= sName
.booleanValue();
163 tRes
.tested("setName()", result
);