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 ifc.sheet; 25 26 import com.sun.star.sheet.XAreaLinks; 27 import com.sun.star.table.CellAddress; 28 import lib.MultiMethodTest; 29 30 /** 31 * Testing <code>com.sun.star.sheet.XAreaLinks</code> 32 * interface methods : 33 * <ul> 34 * <li><code> insertAtPosition()</code></li> 35 * <li><code> removeByIndex()</code></li> 36 * </ul> <p> 37 * Test is <b> NOT </b> multithread compilant. <p> 38 * @see com.sun.star.sheet.XAreaLinks 39 */ 40 public class _XAreaLinks extends MultiMethodTest { 41 42 public XAreaLinks oObj = null; 43 44 /** 45 * Inserts a new link into collection. Checks number of links 46 * before and after method call. <p> 47 * Has <b>OK</b> status if after method call number of 48 * links increased by 1. 49 */ _insertAtPosition()50 public void _insertAtPosition(){ 51 boolean bResult = true ; 52 int cnt = 0; 53 54 cnt = oObj.getCount() ; 55 CellAddress addr = new CellAddress ((short) 1,2,3) ; 56 String aSourceArea = util.utils.getFullTestURL("calcshapes.sxc"); 57 oObj.insertAtPosition (addr, aSourceArea, "a2:b5", "", "") ; 58 59 if (bResult) { 60 int new_cnt = oObj.getCount() ; 61 62 if (cnt + 1 != new_cnt) { 63 bResult = false ; 64 log.println("Number of links before insertAtPosition() call was " + cnt + 65 ", after call is " + new_cnt) ; 66 } 67 } 68 69 tRes.tested("insertAtPosition()", bResult) ; 70 } 71 72 73 /** 74 * Removes a link from collection. Checks number of links 75 * before and after method call. <p> 76 * Has <b>OK</b> status if after method call number of 77 * links decreases by 1. <p> 78 * The following method tests are to be completed successfully before : 79 * <ul> 80 * <li> <code> insertAtPosition </code> : to have at least one link. </li> 81 * </ul> 82 */ _removeByIndex()83 public void _removeByIndex(){ 84 requiredMethod("insertAtPosition()") ; 85 86 boolean bResult = true ; 87 int lcnt = 0; 88 89 lcnt = oObj.getCount() ; 90 oObj.removeByIndex(0) ; 91 92 int new_lcnt = oObj.getCount() ; 93 if (lcnt - 1 != new_lcnt) { 94 bResult = false ; 95 log.println(" # Number of links before removeByIndex() call was " + 96 lcnt + ", after call is " + new_lcnt) ; 97 } 98 tRes.tested("removeByIndex()", bResult) ; 99 } 100 101 } //EOC _XAreaLinks 102 103 104