Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / chart / _XDiagram.java
blobd43a0ca1153bfd6b09e47328092dcddd0d0e1a02
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: _XDiagram.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.chart;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.beans.XPropertySet;
38 import com.sun.star.chart.XDiagram;
40 /**
41 * Testing <code>com.sun.star.chart.XDiagram</code>
42 * interface methods :
43 * <ul>
44 * <li><code> getDiagramType()</code></li>
45 * <li><code> getDataRowProperties()</code></li>
46 * <li><code> getDataPointProperties()</code></li>
47 * </ul> <p>
48 * This test needs the following object relations :
49 * <ul>
50 * <li> <code>'ROWAMOUNT'</code> (of type <code>Integer</code>):
51 * to have amount of rows </li>
52 * <li> <code>'COLAMOUNT'</code> (of type <code>Integer</code>):
53 * to have amount of columns </li>
54 * <ul> <p>
55 * @see com.sun.star.chart.XDiagram
57 public class _XDiagram extends MultiMethodTest {
59 public XDiagram oObj = null;
60 boolean result = true;
61 Integer rowamount = null;
62 Integer colamount = null;
64 /**
65 * Retrieves object relations.
66 * @throws StatusException If one of relations not found.
68 public void before() {
69 rowamount = (Integer)tEnv.getObjRelation("ROWAMOUNT");
70 if (rowamount == null) throw new StatusException(Status.failed
71 ("Relation 'ROWAMOUNT' not found"));
73 colamount = (Integer)tEnv.getObjRelation("COLAMOUNT");
74 if (colamount == null) throw new StatusException(Status.failed
75 ("Relation 'COLAMOUNT' not found"));
78 /**
79 * Test calls the method and checks returned value. <p>
80 * Has <b> OK </b> status if returned value start from 'com.sun.star.chart.' <p>
82 public void _getDiagramType() {
83 result = true;
85 String stype = oObj.getDiagramType();
86 log.println("Current Diagram Type is " + stype);
87 result = (stype.startsWith("com.sun.star.chart."));
89 tRes.tested("getDiagramType()", result);
92 /**
93 * Test calls the method for every row and checks returned value. <p>
94 * Has <b> OK </b> status if returned value for every row isn't null and
95 * no exceptions were thrown. <p>
97 public void _getDataRowProperties() {
98 result = true;
100 int rows = rowamount.intValue();
101 rows -= 1;
102 XPropertySet props = null;
104 log.println("There are " + rows + " rows.");
105 try {
106 for (int i = 0; i < rows; i++) {
107 props = oObj.getDataRowProperties(i);
108 if (props != null) {
109 log.println("Row " + i + " - OK");
110 } else {
111 log.println("Row " + i + " - FAILED");
112 result = false;
115 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
116 log.println("Exception while get data row properties");
117 e.printStackTrace(log);
118 result = false;
121 tRes.tested("getDataRowProperties()", result);
125 * Test calls the method for every point and checks returned value. <p>
126 * Has <b> OK </b> status if returned value for every point isn't null and
127 * no exceptions were thrown. <p>
129 public void _getDataPointProperties() {
130 result = true;
132 int rows = rowamount.intValue();
133 int cols = colamount.intValue();
134 XPropertySet props = null;
136 log.println("There are " + rows + " rows and " + cols + " cols.");
138 try {
139 for (int i = 0; i < rows; i++)
140 for (int j = 0; j < cols; j++) {
141 props = oObj.getDataPointProperties(i, j);
142 if (props != null) {
143 log.println("Row " + i + " Col " + j + " - OK");
144 } else {
145 log.println("Row " + i + " Col " + j + " - FAILED");
146 result = false;
149 } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
150 log.println("Exception while get data point properties");
151 e.printStackTrace(log);
152 result = false;
155 tRes.tested("getDataPointProperties()", result);