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.sheet.XViewPane;
33 import com.sun.star.table.CellRangeAddress;
34 
35 /**
36 * Testing <code>com.sun.star.sheet.XViewPane</code>
37 * interface methods :
38 * <ul>
39 *  <li><code> getFirstVisibleColumn()</code></li>
40 *  <li><code> setFirstVisibleColumn()</code></li>
41 *  <li><code> getFirstVisibleRow()</code></li>
42 *  <li><code> setFirstVisibleRow()</code></li>
43 *  <li><code> getVisibleRange()</code></li>
44 * </ul> <p>
45 * @see com.sun.star.sheet.XViewPane
46 */
47 public class _XViewPane extends MultiMethodTest {
48 
49     public XViewPane oObj = null;
50     int row = 3;
51     int col = 5;
52 
53     /**
54     * Test calls the method and checks returned value. <p>
55     * Has <b> OK </b> status if returned value is equal to value that was set
56     * by method <code>setFirstVisibleColumn()</code>. <p>
57     * The following method tests are to be completed successfully before :
58     * <ul>
59     *  <li> <code> setFirstVisibleColumn() </code> : to set specific value
60     *  of the first column that is visible in the pane </li>
61     * </ul>
62     */
63     public void _getFirstVisibleColumn() {
64         requiredMethod("setFirstVisibleColumn()");
65         boolean result = col == oObj.getFirstVisibleColumn();
66         tRes.tested("getFirstVisibleColumn()", result);
67     }
68 
69     /**
70     * Test calls the method and checks returned value. <p>
71     * Has <b> OK </b> status if returned value is equal to value that was set
72     * by method <code>setFirstVisibleRow()</code>. <p>
73     * The following method tests are to be completed successfully before :
74     * <ul>
75     *  <li> <code> setFirstVisibleRow() </code> : to set specific value of
76     *  the first row that is visible in the pane </li>
77     * </ul>
78     */
79     public void _getFirstVisibleRow() {
80         requiredMethod("setFirstVisibleRow()");
81         boolean result = row == oObj.getFirstVisibleRow();
82         tRes.tested("getFirstVisibleRow()", result);
83     }
84 
85     /**
86     * Test just calls the method. <p>
87     * Has <b> OK </b> status if the method successfully returns. <p>
88     */
89     public void _setFirstVisibleColumn() {
90         oObj.setFirstVisibleColumn(col);
91         tRes.tested("setFirstVisibleColumn()", true);
92     }
93 
94     /**
95     * Test just calls the method. <p>
96     * Has <b> OK </b> status if the method successfully returns. <p>
97     */
98     public void _setFirstVisibleRow() {
99         oObj.setFirstVisibleRow(row);
100         tRes.tested("setFirstVisibleRow()", true);
101     }
102 
103     /**
104     * Test calls the method, checks returned value and adds object relation
105     * 'DATAAREA' to test environment. <p>
106     * Has <b> OK </b> status if returned value isn't null and if start row and
107     * start column are equal to values that was set by methods
108     * <code>setFirstVisibleRow</code> and <code>setFirstVisibleColumn</code>.<p>
109     * The following method tests are to be completed successfully before :
110     * <ul>
111     *  <li> <code> setFirstVisibleRow() </code> : to set specific value of
112     *  the first row that is visible in the pane </li>
113     *  <li> <code> setFirstVisibleColumn() </code> : to set specific value of
114     *  the first column that is visible in the pane </li>
115     * </ul>
116     */
117     public void _getVisibleRange() {
118         requiredMethod("setFirstVisibleRow()");
119         requiredMethod("setFirstVisibleColumn()");
120 
121         CellRangeAddress RA = oObj.getVisibleRange();
122         boolean result = RA != null;
123         if (result) {
124             result &= RA.Sheet == 0;
125             result &= RA.StartRow == row;
126             result &= RA.StartColumn == col;
127             tEnv.addObjRelation("DATAAREA", RA);
128         }
129 
130         tRes.tested("getVisibleRange()", result);
131     }
132 }
133 
134