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 ************************************************************************/
30 import lib
.MultiMethodTest
;
32 import lib
.StatusException
;
34 import com
.sun
.star
.beans
.XPropertySet
;
35 import com
.sun
.star
.chart
.XDiagram
;
38 * Testing <code>com.sun.star.chart.XDiagram</code>
41 * <li><code> getDiagramType()</code></li>
42 * <li><code> getDataRowProperties()</code></li>
43 * <li><code> getDataPointProperties()</code></li>
45 * This test needs the following object relations :
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>
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;
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"));
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() {
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
);
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() {
97 int rows
= rowamount
.intValue();
99 XPropertySet props
= null;
101 log
.println("There are " + rows
+ " rows.");
103 for (int i
= 0; i
< rows
; i
++) {
104 props
= oObj
.getDataRowProperties(i
);
106 log
.println("Row " + i
+ " - OK");
108 log
.println("Row " + i
+ " - FAILED");
112 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
113 log
.println("Exception while get data row properties");
114 e
.printStackTrace(log
);
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() {
129 int rows
= rowamount
.intValue();
130 int cols
= colamount
.intValue();
131 XPropertySet props
= null;
133 log
.println("There are " + rows
+ " rows and " + cols
+ " cols.");
136 for (int i
= 0; i
< rows
; i
++)
137 for (int j
= 0; j
< cols
; j
++) {
138 props
= oObj
.getDataPointProperties(i
, j
);
140 log
.println("Row " + i
+ " Col " + j
+ " - OK");
142 log
.println("Row " + i
+ " Col " + j
+ " - FAILED");
146 } catch(com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
147 log
.println("Exception while get data point properties");
148 e
.printStackTrace(log
);
152 tRes
.tested("getDataPointProperties()", result
);