tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / table / _XTableRows.java
blob2f997860c6090b6d2db922fd4d5762bd33278c40
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.table;
21 import com.sun.star.table.XCellRange;
22 import lib.MultiMethodTest;
24 import com.sun.star.table.XTableRows;
25 import lib.Status;
26 import lib.StatusException;
28 /**
29 * Testing <code>com.sun.star.table.XTableRows</code>
30 * interface methods :
31 * <ul>
32 * <li><code> insertByIndex()</code></li>
33 * <li><code> removeByIndex()</code></li>
34 * </ul>
36 public class _XTableRows extends MultiMethodTest {
38 public XTableRows oObj = null;
39 public XCellRange range = null;
41 @Override
42 public void before() {
43 range = (XCellRange) tEnv.getObjRelation("XTableRows.XCellRange");
44 if (range==null) {
45 throw new StatusException(Status.failed("ObjectRelation missing"));
47 try {
48 range.getCellByPosition(0,0).setValue(17);
49 range.getCellByPosition(0,1).setValue(15);
50 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
51 log.println("Couldn't set value for Cell A1");
55 /**
56 * First a row inserted to valid position, then to invalid. <p>
57 * Has <b> OK </b> status if in the first case number of rows increases
58 * by 1, and in the second an exception is thrown. <p>
60 public void _insertByIndex() {
62 boolean result = true;
64 requiredMethod("removeByIndex()");
66 oObj.getCount();
67 log.println("Inserting row before first row");
68 oObj.insertByIndex(0,1);
69 result &= checkCell(1,15);
70 if (checkCell(1,15)) log.println("... successful");
72 try {
73 oObj.insertByIndex(-1,1);
74 log.println("No Exception occurred while inserting row at -1");
75 result &= false;
76 } catch (Exception e) {
77 log.println("Inserting row at Index -1 ... OK");
78 result &= true;
81 tRes.tested( "insertByIndex()", result );
83 } // end insertByIndex()
85 /**
86 * First a row removed from valid position, then from invalid. <p>
88 * Has <b> OK </b> status if in the first case number of columns decreases
89 * by 1, and in the second an exception is thrown. <p>
91 public void _removeByIndex() {
93 boolean result = true;
95 oObj.removeByIndex(0,1);
96 log.println("Removing first row");
97 result &= checkCell(0,15);
98 if (checkCell(0,15)) log.println("... successful");
100 try {
101 oObj.removeByIndex(-1,1);
102 log.println("No Exception occurred while Removing row at -1");
103 result &= false;
104 } catch (Exception e) {
105 log.println("Removing row at Index -1 ... OK");
106 result &= true;
109 tRes.tested( "removeByIndex()", result );
110 } // end removeByIndex()
112 public boolean checkCell(int row,double expected) {
113 double getting=0;
114 try {
115 getting = range.getCellByPosition(0,row).getValue();
116 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
117 log.println("Couldn't set value for Cell A1");
120 boolean res = (getting==expected);
121 if (!res) {
122 log.println("Expected for row "+row+" was "+expected);
123 log.println("Getting for row "+row+" - "+getting);
124 log.println("=> FAILED");
126 return res;
129 } //finish class _XTableRows