xref: /trunk/main/sc/qa/complex/dataPilot/_XNamed.java (revision 15ab5183)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package complex.dataPilot;
25 
26 import com.sun.star.container.XNamed;
27 import lib.TestParameters;
28 // import share.LogWriter;
29 // import util.utils;
30 
31 /**
32 * Testing <code>com.sun.star.container.XNamed</code>
33 * interface methods :
34 * <ul>
35 *  <li><code> getName()</code></li>
36 *  <li><code> setName()</code></li>
37 * </ul>
38 * This test need the following object relations :
39 * <ul>
40 *  <li> <code>'setName'</code> : of <code>Boolean</code>
41 *    type. If it exists then <code>setName</code> method
42 *    isn't to be tested and result of this test will be
43 *    equal to relation value.</li>
44 * <ul> <p>
45 * Test is <b> NOT </b> multithread compilant. <p>
46 * @see com.sun.star.container.XNamed
47 */
48 public class _XNamed {
49 
50     /**
51      * The object that is testsed.
52      */
53     public XNamed oObj = null;
54 
55     /**
56      * The test parameters
57      */
58     private TestParameters param = null;
59 
60     /**
61      * The log writer
62      */
63     // private LogWriter log = null;
64 
65     /**
66      * Constructor: gets the object to test, a logger and the test parameters
67      * @param xObj The test object
68      * @param log A log writer
69      * @param param The test parameters
70      */
_XNamed(XNamed xObj , TestParameters param)71     public _XNamed(XNamed xObj/*, LogWriter log*/, TestParameters param) {
72         oObj = xObj;
73         // this.log = log;
74         this.param = param;
75     }
76 
77     /**
78     * Test calls the method and checks return value and that
79     * no exceptions were thrown. <p>
80     * Has <b> OK </b> status if the method returns non null value
81     * and no exceptions were thrown. <p>
82     */
_getName()83     public boolean _getName() {
84 
85         // write to log what we try next
86         System.out.println( "test for getName()" );
87 
88         boolean result = true;
89         boolean loc_result = true;
90         String name = null;
91         String NewName = null;
92 
93         loc_result = ((name = oObj.getName()) != null);
94         System.out.println("getting the name \"" + name + "\"");
95 
96         if (loc_result)
97         {
98             System.out.println("... getName() - OK");
99         }
100         else
101         {
102             System.out.println("... getName() - FAILED");
103         }
104         result &= loc_result;
105         return result;
106     }
107 
108     /**
109     * Sets a new name for object and checks if it was properly
110     * set. Special cases for the following objects :
111     * <ul>
112     *  <li><code>ScSheetLinkObj</code> : name must be in form of URL.</li>
113     *  <li><code>ScDDELinkObj</code> : name must contain link to cell in
114     *     some external Sheet.</li>
115     * </ul>
116     * Has <b> OK </b> status if new name was successfully set, or if
117     * object environment contains relation <code>'setName'</code> with
118     * value <code>true</code>. <p>
119     * The following method tests are to be completed successfully before :
120     * <ul>
121     *  <li> <code> getName() </code> : to be sure the method works</li>
122     * </ul>
123     */
_setName()124     public boolean _setName(){
125 //        requiredMethod("getName()");
126         System.out.println("testing setName() ... ");
127 
128         String oldName = oObj.getName();
129         String NewName = oldName == null ? "XNamed" : oldName + "X" ;
130 
131         boolean result = true;
132         boolean loc_result = true;
133         System.out.println("set the name of object to \"" + NewName + "\"");
134         oObj.setName(NewName);
135         System.out.println("check that container has element with this name");
136 
137         String name = oObj.getName();
138         System.out.println("getting the name \"" + name + "\"");
139         loc_result = name.equals(NewName);
140 
141         if (loc_result)
142         {
143             System.out.println("... setName() - OK");
144         }
145         else
146         {
147             System.out.println("... setName() - FAILED");
148         }
149         result &= loc_result;
150         oObj.setName(oldName);
151         return result;
152     }
153 }
154 
155 
156