1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDiagram.java,v $
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 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import lib
.StatusException
;
37 import com
.sun
.star
.beans
.XPropertySet
;
38 import com
.sun
.star
.chart
.XDiagram
;
41 * Testing <code>com.sun.star.chart.XDiagram</code>
44 * <li><code> getDiagramType()</code></li>
45 * <li><code> getDataRowProperties()</code></li>
46 * <li><code> getDataPointProperties()</code></li>
48 * This test needs the following object relations :
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>
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;
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"));
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() {
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
);
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() {
100 int rows
= rowamount
.intValue();
102 XPropertySet props
= null;
104 log
.println("There are " + rows
+ " rows.");
106 for (int i
= 0; i
< rows
; i
++) {
107 props
= oObj
.getDataRowProperties(i
);
109 log
.println("Row " + i
+ " - OK");
111 log
.println("Row " + i
+ " - FAILED");
115 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
116 log
.println("Exception while get data row properties");
117 e
.printStackTrace(log
);
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() {
132 int rows
= rowamount
.intValue();
133 int cols
= colamount
.intValue();
134 XPropertySet props
= null;
136 log
.println("There are " + rows
+ " rows and " + cols
+ " cols.");
139 for (int i
= 0; i
< rows
; i
++)
140 for (int j
= 0; j
< cols
; j
++) {
141 props
= oObj
.getDataPointProperties(i
, j
);
143 log
.println("Row " + i
+ " Col " + j
+ " - OK");
145 log
.println("Row " + i
+ " Col " + j
+ " - FAILED");
149 } catch(com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
150 log
.println("Exception while get data point properties");
151 e
.printStackTrace(log
);
155 tRes
.tested("getDataPointProperties()", result
);