Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XDataPilotField.java
blob54ed131a5c52897d56e6cf0044e7e483a763e0b8
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 .
18 package ifc.sheet;
20 import com.sun.star.container.XIndexAccess;
21 import com.sun.star.sheet.XDataPilotField;
23 import lib.MultiMethodTest;
26 public class _XDataPilotField extends MultiMethodTest {
27 public XDataPilotField oObj = null;
29 public void _getItems() {
30 XIndexAccess xIA = oObj.getItems();
31 tRes.tested("getItems()", checkIndexAccess(xIA));
34 /**
35 * calls the method getCount at the IndexAccess, returns true is it is >0
36 * and getByIndex() doesn't throw an exception for Indexes between 0 and count
38 protected boolean checkIndexAccess(XIndexAccess xIA) {
39 boolean res = true;
40 int count = xIA.getCount();
41 log.println("Found " + count + " Elements");
42 res &= (count > 0);
44 for (int k = 0; k < count; k++) {
45 try {
46 Object element = xIA.getByIndex(k);
47 log.println("Element " + k + " = " + element);
48 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
49 log.println("Unexpected Exception while getting by Index (" + k +
50 ")" + e.getMessage());
51 res &= false;
52 } catch (com.sun.star.lang.WrappedTargetException e) {
53 log.println("Unexpected Exception while getting by Index (" + k +
54 ")" + e.getMessage());
55 res &= false;
59 return res;