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