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 ifc.sheet;
29 
30 import lib.MultiMethodTest;
31 
32 import com.sun.star.container.XEnumeration;
33 import com.sun.star.sheet.XSheetCellRanges;
34 import com.sun.star.table.CellRangeAddress;
35 
36 /**
37 * Testing <code>com.sun.star.sheet.XSheetCellRanges</code>
38 * interface methods :
39 * <ul>
40 *  <li><code> getCells()</code></li>
41 *  <li><code> getRangeAddressesAsString()</code></li>
42 *  <li><code> getRangeAddresses()</code></li>
43 * </ul> <p>
44 * @see com.sun.star.sheet.XSheetCellRanges
45 */
46 public class _XSheetCellRanges extends MultiMethodTest{
47 
48     public XSheetCellRanges oObj = null;
49 
50     /**
51     * Test calls the method, creates enumeration of returned value
52     * and checks that the enumeration has elements. <p>
53     * Has <b> OK </b> status if gained enumeration has elements. <p>
54     */
55     public void _getCells() {
56         log.println("Testing getCells ...");
57 
58         XEnumeration oEnum = oObj.getCells().createEnumeration();
59         boolean res = oEnum.hasMoreElements();
60         if (!res) {
61             log.println(
62                     "The Enumeration gained via getCells() has no Elements");
63         }
64         tRes.tested("getCells()", res);
65     }
66 
67     /**
68     * Test calls the method and checks length of returned array. <p>
69     * Has <b> OK </b> status if length of returned array is greater than 2.<p>
70     */
71     public void _getRangeAddresses() {
72         log.println("Testing getRangeAddresses ...");
73         CellRangeAddress[] oRanges = oObj.getRangeAddresses();
74         int howmuch = oRanges.length;
75         tRes.tested("getRangeAddresses()", (howmuch > 2) );
76     }
77 
78     /**
79     * Test calls the method and checks returned string. <p>
80     * Has <b> OK </b> status if returned string starts from 'Sheet'.<p>
81     */
82     public void _getRangeAddressesAsString() {
83         log.println("Testing getRangeAddressesAsString ...");
84         String oRanges = oObj.getRangeAddressesAsString();
85         tRes.tested("getRangeAddressesAsString()",oRanges.indexOf("C1:D4")>0);
86     }
87 
88 } // finished class _XSheetCellRanges
89 
90