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