merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XDatabaseRanges.java
blobbcf254bfb1094e4c5c4a0cd1c6a77cddd80f5bbc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDatabaseRanges.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.sheet;
33 import lib.MultiMethodTest;
35 import com.sun.star.sheet.XDatabaseRanges;
36 import com.sun.star.table.CellRangeAddress;
38 /**
39 * Testing <code>com.sun.star.sheet.XDatabaseRanges</code>
40 * interface methods :
41 * <ul>
42 * <li><code> addNewByName()</code></li>
43 * <li><code> removeByName()</code></li>
44 * </ul> <p>
45 * @see com.sun.star.sheet.XDatabaseRanges
47 public class _XDatabaseRanges extends MultiMethodTest {
49 public XDatabaseRanges oObj = null;
50 CellRangeAddress CRA = null;
51 String name = null;
53 /**
54 * Test adds a new database range to the collection, checks that range with
55 * this name exist in collection and then tries to add range with the same
56 * name. <p>
57 * Has <b> OK </b> status if the added range exists in collection and
58 * exception was thrown when trying to add range with name that is same as name
59 * of existent range. <p>
61 public void _addNewByName() {
62 boolean bResult = true;
63 log.println("Trying to add range with proper name.");
65 CRA = new CellRangeAddress((short)0, 1, 2, 3, 4);
66 name = "_XDatabaseRanges_addNewByRange";
68 oObj.addNewByName(name, CRA);
70 bResult &= oObj.hasByName(name);
72 if (bResult) log.println("Ok");
73 log.println("Trying to add existing element.");
75 try {
76 oObj.addNewByName(name, CRA);
77 log.println("Exception expected... Test failed.");
78 bResult = false;
79 } catch(com.sun.star.uno.RuntimeException e) {
80 log.println("Exception occured while testing addNewByName() : " + e);
81 bResult = true;
84 tRes.tested("addNewByName()", bResult);
87 /**
88 * Test removes the database range with name that exist exactly and then
89 * tries to remove the range with name that doesn't exist exactly. <p>
90 * Has <b> OK </b> status if first range was succesfully removed and
91 * exception was thrown when trying to remove non-existent database range.<p>
92 * The following method tests are to be completed successfully before :
93 * <ul>
94 * <li> <code> addNewByName() </code> : to have definitely existed database
95 * range </li>
96 * </ul>
98 public void _removeByName(){
99 boolean bResult = true;
100 requiredMethod("addNewByName()");
102 log.println("Remove inserted element.");
104 try {
105 oObj.removeByName(name);
106 bResult &= !oObj.hasByName(name);
107 } catch (com.sun.star.uno.RuntimeException e) {
108 log.println("Exception occured while testing removeByName() : " + e);
109 bResult = false;
112 log.println("OK.\nTrying to remove unexistant element.");
114 try {
115 oObj.removeByName(name);
116 log.println("Exception expected... - FAILED");
117 bResult = false;
118 } catch (com.sun.star.uno.RuntimeException e) {
119 log.println("Expected exception. - OK : " + e);
121 tRes.tested("removeByName()", bResult);