xref: /AOO41X/main/qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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.CellFlags;
33 import com.sun.star.sheet.GeneralFunction;
34 import com.sun.star.sheet.XSheetOperation;
35 
36 /**
37 * Testing <code>com.sun.star.sheet.XSheetOperation</code>
38 * interface methods :
39 * <ul>
40 *  <li><code> computeFunction()</code></li>
41 *  <li><code> clearContents()</code></li>
42 * </ul> <p>
43 * @see com.sun.star.sheet.XSheetOperation
44 */
45 public class _XSheetOperation extends MultiMethodTest {
46 
47     public XSheetOperation oObj = null;
48 
49     /**
50     * Test clears formula and value contents, calls the method
51     * <code>computeFunction</code> and checks returned value. <p>
52     * Has <b> OK </b> status if returned value is equal to zero
53     * and no exceptions were thrown. <p>
54     */
55     public void _clearContents() {
56         boolean result = true;
57         double resultVal = -1;
58 
59         log.println("Testing clearContents() ...");
60 
61         int allFlags;
62         allFlags = CellFlags.VALUE | CellFlags.FORMULA;
63 
64         oObj.clearContents (allFlags) ;
65 
66         try {
67             resultVal = oObj.computeFunction(GeneralFunction.SUM);
68             result &= (resultVal == 0.0) || (resultVal == 0);
69         } catch (com.sun.star.uno.Exception e) {
70             result &= false ;
71             log.println(
72                     "Exception occured while checking results of method");
73             e.printStackTrace(log);
74         }
75 
76         tRes.tested("clearContents()", result);
77 
78     } // finished clearContents
79 
80     /**
81     * Test calls the method and checks returned value. <p>
82     * Has <b> OK </b> status if returned value is equal or greate than zero
83     * and no exceptions were thrown. <p>
84     */
85     public void _computeFunction() {
86 
87         log.println("Testing computeFunction() ...");
88         double resultVal = -1;
89         boolean result = true;
90 
91         try {
92             resultVal = oObj.computeFunction (GeneralFunction.COUNT) ;
93             result = resultVal >= 0;
94         } catch (com.sun.star.uno.Exception e) {
95             result = false;
96             log.println("Exception occured in method computeFunction.");
97             e.printStackTrace(log);
98         }
99 
100         tRes.tested("computeFunction()", result);
101     } // finished computeFunction
102 
103 } // finished class _XSheetOperation
104 
105