1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package ifc.chart;
29 
30 import lib.MultiMethodTest;
31 
32 import com.sun.star.beans.XPropertySet;
33 import com.sun.star.chart.XChartData;
34 import com.sun.star.chart.XChartDocument;
35 import com.sun.star.chart.XDiagram;
36 import com.sun.star.drawing.XShape;
37 
38 /**
39 * Testing <code>com.sun.star.chart.XChartDocument</code>
40 * interface methods :
41 * <ul>
42 *  <li><code> getTitle()</code></li>
43 *  <li><code> getSubTitle()</code></li>
44 *  <li><code> getLegend()</code></li>
45 *  <li><code> getArea()</code></li>
46 *  <li><code> getDiagram()</code></li>
47 *  <li><code> setDiagram()</code></li>
48 *  <li><code> getData()</code></li>
49 *  <li><code> attachData()</code></li>
50 * </ul> <p>
51 *
52 * This test needs the following object relations :
53 * <ul>
54 *  <li> <code>'DIAGRAM'</code> (of type <code>XDiagram</code>):
55 *  is used as parameter for method <code>setDiagram</code> </li>
56 *  <li> <code>'CHARTDATA'</code> (of type <code>XChartData</code>):
57 *  is used as parameter for method <code>attachData</code> </li>
58 * </ul>
59 *
60 * @see com.sun.star.chart.XChartDocument
61 */
62 public class _XChartDocument extends MultiMethodTest {
63 
64     public XChartDocument    oObj = null;
65     boolean                result = true;
66     XDiagram diagram = null;
67     XChartData ChartData = null;
68 
69     /**
70     * Test calls the method and checks returned value. <p>
71     * Has <b> OK </b> status if returned value isn't null. <p>
72     */
73     public void _getTitle() {
74         XShape title = oObj.getTitle();
75         tRes.tested("getTitle()", title != null);
76     }
77 
78     /**
79     * Test calls the method and checks returned value. <p>
80     * Has <b> OK </b> status if returned value isn't null. <p>
81     */
82     public void _getSubTitle() {
83         XShape subtitle = oObj.getSubTitle();
84         tRes.tested("getSubTitle()", subtitle != null);
85     }
86 
87     /**
88     * Test calls the method and checks returned value. <p>
89     * Has <b> OK </b> status if returned value isn't null. <p>
90     */
91     public void _getLegend() {
92         XShape legend = oObj.getLegend();
93         tRes.tested("getLegend()", legend != null);
94     }
95 
96     /**
97     * Test calls the method and checks returned value. <p>
98     * Has <b> OK </b> status if returned value isn't null. <p>
99     */
100     public void _getArea() {
101         XPropertySet area = oObj.getArea();
102         tRes.tested("getArea()", area != null);
103     }
104 
105     /**
106     * Test calls the method and checks returned value. <p>
107     * Has <b> OK </b> status if returned value isn't null. <p>
108     */
109     public void _getDiagram() {
110         diagram = oObj.getDiagram();
111         tRes.tested("getDiagram()", diagram != null);
112     }
113 
114     /**
115     * Test compares type of diagram before method call and after.<p>
116     * Has <b> OK </b> status if diagram types are not equal. <p>
117     *
118     * The following method tests are to be completed successfully before :
119     * <ul>
120     *  <li> <code> getDiagram </code> : to have diagram before method call</li>
121     * </ul>
122     *
123     * @see com.sun.star.chart.XDiagram
124     */
125     public void _setDiagram() {
126         requiredMethod("getDiagram()");
127         String oldType = diagram.getDiagramType();
128         XDiagram diag = (XDiagram)tEnv.getObjRelation("DIAGRAM");
129         oObj.setDiagram(diag);
130         String newType = oObj.getDiagram().getDiagramType();
131         tRes.tested("setDiagram()", !(oldType.equals(newType)));
132     }
133 
134     /**
135     * Test calls the method and checks returned value. <p>
136     * Has <b> OK </b> status if returned value isn't null. <p>
137     */
138     public void _getData() {
139         ChartData = oObj.getData();
140         tRes.tested("getData()", ChartData != null);
141     }
142 
143     /**
144     * Test compares data before method call and after. <p>
145     * Has <b> OK </b> status if the data before method call and
146     * after are not equal. <p>
147     * The following method tests are to be completed successfully before :
148     * <ul>
149     *  <li> <code> getData </code> : to have data before method call </li>
150     * </ul>
151     * @see com.sun.star.chart.XChartData
152     */
153     public void _attachData() {
154         requiredMethod("getData()");
155         XChartData data = (XChartData)tEnv.getObjRelation("CHARTDATA");
156         oObj.attachData(data);
157         XChartData newdata = oObj.getData();
158 
159         tRes.tested("attachData()", !(newdata.equals(ChartData)));
160     }
161 
162 }
163 
164 
165