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 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.beans
.XPropertySet
;
26 import com
.sun
.star
.chart
.XDiagram
;
29 * Testing <code>com.sun.star.chart.XDiagram</code>
32 * <li><code> getDiagramType()</code></li>
33 * <li><code> getDataRowProperties()</code></li>
34 * <li><code> getDataPointProperties()</code></li>
36 * This test needs the following object relations :
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>
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;
53 * Retrieves object relations.
54 * @throws StatusException If one of relations not found.
57 public void before() {
58 rowamount
= (Integer
)tEnv
.getObjRelation("ROWAMOUNT");
59 if (rowamount
== null) throw new StatusException(Status
.failed
60 ("Relation 'ROWAMOUNT' not found"));
62 colamount
= (Integer
)tEnv
.getObjRelation("COLAMOUNT");
63 if (colamount
== null) throw new StatusException(Status
.failed
64 ("Relation 'COLAMOUNT' not found"));
68 * Test calls the method and checks returned value. <p>
69 * Has <b> OK </b> status if returned value start from 'com.sun.star.chart.' <p>
71 public void _getDiagramType() {
74 String stype
= oObj
.getDiagramType();
75 log
.println("Current Diagram Type is " + stype
);
76 result
= stype
.startsWith("com.sun.star.chart.");
78 tRes
.tested("getDiagramType()", result
);
82 * Test calls the method for every row and checks returned value. <p>
83 * Has <b> OK </b> status if returned value for every row isn't null and
84 * no exceptions were thrown. <p>
86 public void _getDataRowProperties() {
89 int rows
= rowamount
.intValue();
91 XPropertySet props
= null;
93 log
.println("There are " + rows
+ " rows.");
95 for (int i
= 0; i
< rows
; i
++) {
96 props
= oObj
.getDataRowProperties(i
);
98 log
.println("Row " + i
+ " - OK");
100 log
.println("Row " + i
+ " - FAILED");
104 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
105 log
.println("Exception while get data row properties");
106 e
.printStackTrace(log
);
110 tRes
.tested("getDataRowProperties()", result
);
114 * Test calls the method for every point and checks returned value. <p>
115 * Has <b> OK </b> status if returned value for every point isn't null and
116 * no exceptions were thrown. <p>
118 public void _getDataPointProperties() {
121 int rows
= rowamount
.intValue();
122 int cols
= colamount
.intValue();
123 XPropertySet props
= null;
125 log
.println("There are " + rows
+ " rows and " + cols
+ " cols.");
128 for (int i
= 0; i
< rows
; i
++)
129 for (int j
= 0; j
< cols
; j
++) {
130 props
= oObj
.getDataPointProperties(i
, j
);
132 log
.println("Row " + i
+ " Col " + j
+ " - OK");
134 log
.println("Row " + i
+ " Col " + j
+ " - FAILED");
138 } catch(com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
139 log
.println("Exception while get data point properties");
140 e
.printStackTrace(log
);
144 tRes
.tested("getDataPointProperties()", result
);