Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XSheetOperation.java
blob222f60bd6e7802d50f44b8c30b467af5db3e8a66
1 /*
2 * This file is part of the LibreOffice project.
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/.
8 * This file incorporates work covered by the following license notice:
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 .
19 package ifc.sheet;
21 import lib.MultiMethodTest;
23 import com.sun.star.sheet.CellFlags;
24 import com.sun.star.sheet.GeneralFunction;
25 import com.sun.star.sheet.XSheetOperation;
27 /**
28 * Testing <code>com.sun.star.sheet.XSheetOperation</code>
29 * interface methods :
30 * <ul>
31 * <li><code> computeFunction()</code></li>
32 * <li><code> clearContents()</code></li>
33 * </ul> <p>
34 * @see com.sun.star.sheet.XSheetOperation
36 public class _XSheetOperation extends MultiMethodTest {
38 public XSheetOperation oObj = null;
40 /**
41 * Test clears formula and value contents, calls the method
42 * <code>computeFunction</code> and checks returned value. <p>
43 * Has <b> OK </b> status if returned value is equal to zero
44 * and no exceptions were thrown. <p>
46 public void _clearContents() {
47 boolean result = true;
48 double resultVal = -1;
50 log.println("Testing clearContents() ...");
52 int allFlags;
53 allFlags = CellFlags.VALUE | CellFlags.FORMULA;
55 oObj.clearContents (allFlags) ;
57 try {
58 resultVal = oObj.computeFunction(GeneralFunction.SUM);
59 result &= (resultVal == 0.0) || (resultVal == 0);
60 } catch (com.sun.star.uno.Exception e) {
61 result &= false ;
62 log.println(
63 "Exception occurred while checking results of method");
64 e.printStackTrace(log);
67 tRes.tested("clearContents()", result);
69 } // finished clearContents
71 /**
72 * Test calls the method and checks returned value. <p>
73 * Has <b> OK </b> status if returned value is equal or greate than zero
74 * and no exceptions were thrown. <p>
76 public void _computeFunction() {
78 log.println("Testing computeFunction() ...");
79 double resultVal = -1;
80 boolean result = true;
82 try {
83 resultVal = oObj.computeFunction (GeneralFunction.COUNT) ;
84 result = resultVal >= 0;
85 } catch (com.sun.star.uno.Exception e) {
86 result = false;
87 log.println("Exception occurred in method computeFunction.");
88 e.printStackTrace(log);
91 tRes.tested("computeFunction()", result);
92 } // finished computeFunction
94 } // finished class _XSheetOperation