bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _XDiagram.java
blobb1fbbf83ab97eb759360c7c2b705b0ca933ef19a
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.chart;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.beans.XPropertySet;
26 import com.sun.star.chart.XDiagram;
28 /**
29 * Testing <code>com.sun.star.chart.XDiagram</code>
30 * interface methods :
31 * <ul>
32 * <li><code> getDiagramType()</code></li>
33 * <li><code> getDataRowProperties()</code></li>
34 * <li><code> getDataPointProperties()</code></li>
35 * </ul> <p>
36 * This test needs the following object relations :
37 * <ul>
38 * <li> <code>'ROWAMOUNT'</code> (of type <code>Integer</code>):
39 * to have amount of rows </li>
40 * <li> <code>'COLAMOUNT'</code> (of type <code>Integer</code>):
41 * to have amount of columns </li>
42 * <ul> <p>
43 * @see com.sun.star.chart.XDiagram
45 public class _XDiagram extends MultiMethodTest {
47 public XDiagram oObj = null;
48 boolean result = true;
49 Integer rowamount = null;
50 Integer colamount = null;
52 /**
53 * Retrieves object relations.
54 * @throws StatusException If one of relations not found.
56 public void before() {
57 rowamount = (Integer)tEnv.getObjRelation("ROWAMOUNT");
58 if (rowamount == null) throw new StatusException(Status.failed
59 ("Relation 'ROWAMOUNT' not found"));
61 colamount = (Integer)tEnv.getObjRelation("COLAMOUNT");
62 if (colamount == null) throw new StatusException(Status.failed
63 ("Relation 'COLAMOUNT' not found"));
66 /**
67 * Test calls the method and checks returned value. <p>
68 * Has <b> OK </b> status if returned value start from 'com.sun.star.chart.' <p>
70 public void _getDiagramType() {
71 result = true;
73 String stype = oObj.getDiagramType();
74 log.println("Current Diagram Type is " + stype);
75 result = (stype.startsWith("com.sun.star.chart."));
77 tRes.tested("getDiagramType()", result);
80 /**
81 * Test calls the method for every row and checks returned value. <p>
82 * Has <b> OK </b> status if returned value for every row isn't null and
83 * no exceptions were thrown. <p>
85 public void _getDataRowProperties() {
86 result = true;
88 int rows = rowamount.intValue();
89 rows -= 1;
90 XPropertySet props = null;
92 log.println("There are " + rows + " rows.");
93 try {
94 for (int i = 0; i < rows; i++) {
95 props = oObj.getDataRowProperties(i);
96 if (props != null) {
97 log.println("Row " + i + " - OK");
98 } else {
99 log.println("Row " + i + " - FAILED");
100 result = false;
103 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
104 log.println("Exception while get data row properties");
105 e.printStackTrace(log);
106 result = false;
109 tRes.tested("getDataRowProperties()", result);
113 * Test calls the method for every point and checks returned value. <p>
114 * Has <b> OK </b> status if returned value for every point isn't null and
115 * no exceptions were thrown. <p>
117 public void _getDataPointProperties() {
118 result = true;
120 int rows = rowamount.intValue();
121 int cols = colamount.intValue();
122 XPropertySet props = null;
124 log.println("There are " + rows + " rows and " + cols + " cols.");
126 try {
127 for (int i = 0; i < rows; i++)
128 for (int j = 0; j < cols; j++) {
129 props = oObj.getDataPointProperties(i, j);
130 if (props != null) {
131 log.println("Row " + i + " Col " + j + " - OK");
132 } else {
133 log.println("Row " + i + " Col " + j + " - FAILED");
134 result = false;
137 } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
138 log.println("Exception while get data point properties");
139 e.printStackTrace(log);
140 result = false;
143 tRes.tested("getDataPointProperties()", result);