Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / chart / _XDiagram.java
blobe91ba14cd61c98bb57700517b1c36016f3d38d00
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.chart;
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
34 import com.sun.star.beans.XPropertySet;
35 import com.sun.star.chart.XDiagram;
37 /**
38 * Testing <code>com.sun.star.chart.XDiagram</code>
39 * interface methods :
40 * <ul>
41 * <li><code> getDiagramType()</code></li>
42 * <li><code> getDataRowProperties()</code></li>
43 * <li><code> getDataPointProperties()</code></li>
44 * </ul> <p>
45 * This test needs the following object relations :
46 * <ul>
47 * <li> <code>'ROWAMOUNT'</code> (of type <code>Integer</code>):
48 * to have amount of rows </li>
49 * <li> <code>'COLAMOUNT'</code> (of type <code>Integer</code>):
50 * to have amount of columns </li>
51 * <ul> <p>
52 * @see com.sun.star.chart.XDiagram
54 public class _XDiagram extends MultiMethodTest {
56 public XDiagram oObj = null;
57 boolean result = true;
58 Integer rowamount = null;
59 Integer colamount = null;
61 /**
62 * Retrieves object relations.
63 * @throws StatusException If one of relations not found.
65 public void before() {
66 rowamount = (Integer)tEnv.getObjRelation("ROWAMOUNT");
67 if (rowamount == null) throw new StatusException(Status.failed
68 ("Relation 'ROWAMOUNT' not found"));
70 colamount = (Integer)tEnv.getObjRelation("COLAMOUNT");
71 if (colamount == null) throw new StatusException(Status.failed
72 ("Relation 'COLAMOUNT' not found"));
75 /**
76 * Test calls the method and checks returned value. <p>
77 * Has <b> OK </b> status if returned value start from 'com.sun.star.chart.' <p>
79 public void _getDiagramType() {
80 result = true;
82 String stype = oObj.getDiagramType();
83 log.println("Current Diagram Type is " + stype);
84 result = (stype.startsWith("com.sun.star.chart."));
86 tRes.tested("getDiagramType()", result);
89 /**
90 * Test calls the method for every row and checks returned value. <p>
91 * Has <b> OK </b> status if returned value for every row isn't null and
92 * no exceptions were thrown. <p>
94 public void _getDataRowProperties() {
95 result = true;
97 int rows = rowamount.intValue();
98 rows -= 1;
99 XPropertySet props = null;
101 log.println("There are " + rows + " rows.");
102 try {
103 for (int i = 0; i < rows; i++) {
104 props = oObj.getDataRowProperties(i);
105 if (props != null) {
106 log.println("Row " + i + " - OK");
107 } else {
108 log.println("Row " + i + " - FAILED");
109 result = false;
112 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
113 log.println("Exception while get data row properties");
114 e.printStackTrace(log);
115 result = false;
118 tRes.tested("getDataRowProperties()", result);
122 * Test calls the method for every point and checks returned value. <p>
123 * Has <b> OK </b> status if returned value for every point isn't null and
124 * no exceptions were thrown. <p>
126 public void _getDataPointProperties() {
127 result = true;
129 int rows = rowamount.intValue();
130 int cols = colamount.intValue();
131 XPropertySet props = null;
133 log.println("There are " + rows + " rows and " + cols + " cols.");
135 try {
136 for (int i = 0; i < rows; i++)
137 for (int j = 0; j < cols; j++) {
138 props = oObj.getDataPointProperties(i, j);
139 if (props != null) {
140 log.println("Row " + i + " Col " + j + " - OK");
141 } else {
142 log.println("Row " + i + " Col " + j + " - FAILED");
143 result = false;
146 } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
147 log.println("Exception while get data point properties");
148 e.printStackTrace(log);
149 result = false;
152 tRes.tested("getDataPointProperties()", result);