xref: /aoo41x/main/sc/qa/complex/dataPilot/_XNamed.java (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package complex.dataPilot;
29 
30 import com.sun.star.container.XNamed;
31 import lib.TestParameters;
32 // import share.LogWriter;
33 // import util.utils;
34 
35 /**
36 * Testing <code>com.sun.star.container.XNamed</code>
37 * interface methods :
38 * <ul>
39 *  <li><code> getName()</code></li>
40 *  <li><code> setName()</code></li>
41 * </ul>
42 * This test need the following object relations :
43 * <ul>
44 *  <li> <code>'setName'</code> : of <code>Boolean</code>
45 *    type. If it exists then <code>setName</code> method
46 *    isn't to be tested and result of this test will be
47 *    equal to relation value.</li>
48 * <ul> <p>
49 * Test is <b> NOT </b> multithread compilant. <p>
50 * @see com.sun.star.container.XNamed
51 */
52 public class _XNamed {
53 
54     /**
55      * The object that is testsed.
56      */
57     public XNamed oObj = null;
58 
59     /**
60      * The test parameters
61      */
62     private TestParameters param = null;
63 
64     /**
65      * The log writer
66      */
67     // private LogWriter log = null;
68 
69     /**
70      * Constructor: gets the object to test, a logger and the test parameters
71      * @param xObj The test object
72      * @param log A log writer
73      * @param param The test parameters
74      */
75     public _XNamed(XNamed xObj/*, LogWriter log*/, TestParameters param) {
76         oObj = xObj;
77         // this.log = log;
78         this.param = param;
79     }
80 
81     /**
82     * Test calls the method and checks return value and that
83     * no exceptions were thrown. <p>
84     * Has <b> OK </b> status if the method returns non null value
85     * and no exceptions were thrown. <p>
86     */
87     public boolean _getName() {
88 
89         // write to log what we try next
90         System.out.println( "test for getName()" );
91 
92         boolean result = true;
93         boolean loc_result = true;
94         String name = null;
95         String NewName = null;
96 
97         loc_result = ((name = oObj.getName()) != null);
98         System.out.println("getting the name \"" + name + "\"");
99 
100         if (loc_result)
101         {
102             System.out.println("... getName() - OK");
103         }
104         else
105         {
106             System.out.println("... getName() - FAILED");
107         }
108         result &= loc_result;
109         return result;
110     }
111 
112     /**
113     * Sets a new name for object and checks if it was properly
114     * set. Special cases for the following objects :
115     * <ul>
116     *  <li><code>ScSheetLinkObj</code> : name must be in form of URL.</li>
117     *  <li><code>ScDDELinkObj</code> : name must contain link to cell in
118     *     some external Sheet.</li>
119     * </ul>
120     * Has <b> OK </b> status if new name was successfully set, or if
121     * object environment contains relation <code>'setName'</code> with
122     * value <code>true</code>. <p>
123     * The following method tests are to be completed successfully before :
124     * <ul>
125     *  <li> <code> getName() </code> : to be sure the method works</li>
126     * </ul>
127     */
128     public boolean _setName(){
129 //        requiredMethod("getName()");
130         System.out.println("testing setName() ... ");
131 
132         String oldName = oObj.getName();
133         String NewName = oldName == null ? "XNamed" : oldName + "X" ;
134 
135         boolean result = true;
136         boolean loc_result = true;
137         System.out.println("set the name of object to \"" + NewName + "\"");
138         oObj.setName(NewName);
139         System.out.println("check that container has element with this name");
140 
141         String name = oObj.getName();
142         System.out.println("getting the name \"" + name + "\"");
143         loc_result = name.equals(NewName);
144 
145         if (loc_result)
146         {
147             System.out.println("... setName() - OK");
148         }
149         else
150         {
151             System.out.println("... setName() - FAILED");
152         }
153         result &= loc_result;
154         oObj.setName(oldName);
155         return result;
156     }
157 }
158 
159 
160