1 /*
2  * This file is part of the LibreOffice project.
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  *
8  * This file incorporates work covered by the following license notice:
9  *
10  *   Licensed to the Apache Software Foundation (ASF) under one or more
11  *   contributor license agreements. See the NOTICE file distributed
12  *   with this work for additional information regarding copyright
13  *   ownership. The ASF licenses this file to you under the Apache
14  *   License, Version 2.0 (the "License"); you may not use this file
15  *   except in compliance with the License. You may obtain a copy of
16  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
17  */
18 
19 package ifc.sheet;
20 
21 import lib.MultiMethodTest;
22 import util.ValueComparer;
23 
24 import com.sun.star.sheet.XCellRangeData;
25 
26 public class _XCellRangeData extends MultiMethodTest {
27 
28     public XCellRangeData oObj = null;
29     private Object[][] maCRData = null;
30 
31     /**
32     * Test calls the method
33     * state is OK if the resulting Object array
34     * isn't empty
35     */
_getDataArray()36     public void _getDataArray() {
37         maCRData = oObj.getDataArray();
38         boolean bResult = (maCRData.length > 0);
39         tRes.tested("getDataArray()", bResult);
40     }
41 
42     /**
43     * Test creates an Array and calls the method
44     * with this Array as argument
45     * Then the method getDataArray is called
46     * and the resulting Array is compared with the
47     * one formerly set.
48     */
_setDataArray()49     public void _setDataArray() {
50         Object[][] newData = (Object[][]) tEnv.getObjRelation("NewData");
51         if (newData == null) {
52             newData = new Object[maCRData.length][maCRData[0].length];
53             for (int i=0; i<newData.length; i++) {
54                 for (int j=0; j<newData[i].length; j++) {
55                     newData[i][j] = new Double(10*i +j);
56                 }
57             }
58         }
59         oObj.setDataArray(newData);
60         Object[][] oCRData = oObj.getDataArray();
61         boolean res = ValueComparer.equalValue(oCRData[0][0],newData[0][0]);
62         res &= ValueComparer.equalValue(oCRData[0][1],newData[0][1]);
63         res &= ValueComparer.equalValue(oCRData[1][0],newData[1][0]);
64         res &= ValueComparer.equalValue(oCRData[1][1],newData[1][1]);
65         // delete values
66         Object[][] emptyData = new Object[newData.length][newData[0].length];
67         for (int i=0; i<emptyData.length; i++) {
68             for (int j=0; j<emptyData[i].length; j++) {
69                 emptyData[i][j] = "";
70             }
71         }
72         oObj.setDataArray(emptyData);
73         tRes.tested("setDataArray()", res);
74     }
75 }
76 
77