1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.chart;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.beans.XPropertySet;
29 import com.sun.star.chart.XChartData;
30 import com.sun.star.chart.XChartDocument;
31 import com.sun.star.chart.XDiagram;
32 import com.sun.star.drawing.XShape;
33 
34 /**
35 * Testing <code>com.sun.star.chart.XChartDocument</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> getTitle()</code></li>
39 *  <li><code> getSubTitle()</code></li>
40 *  <li><code> getLegend()</code></li>
41 *  <li><code> getArea()</code></li>
42 *  <li><code> getDiagram()</code></li>
43 *  <li><code> setDiagram()</code></li>
44 *  <li><code> getData()</code></li>
45 *  <li><code> attachData()</code></li>
46 * </ul> <p>
47 *
48 * This test needs the following object relations :
49 * <ul>
50 *  <li> <code>'DIAGRAM'</code> (of type <code>XDiagram</code>):
51 *  is used as parameter for method <code>setDiagram</code> </li>
52 *  <li> <code>'CHARTDATA'</code> (of type <code>XChartData</code>):
53 *  is used as parameter for method <code>attachData</code> </li>
54 * </ul>
55 *
56 * @see com.sun.star.chart.XChartDocument
57 */
58 public class _XChartDocument extends MultiMethodTest {
59 
60     public XChartDocument    oObj = null;
61     boolean                result = true;
62     XDiagram diagram = null;
63     XChartData ChartData = null;
64 
65     /**
66     * Test calls the method and checks returned value. <p>
67     * Has <b> OK </b> status if returned value isn't null. <p>
68     */
_getTitle()69     public void _getTitle() {
70         XShape title = oObj.getTitle();
71         tRes.tested("getTitle()", title != null);
72     }
73 
74     /**
75     * Test calls the method and checks returned value. <p>
76     * Has <b> OK </b> status if returned value isn't null. <p>
77     */
_getSubTitle()78     public void _getSubTitle() {
79         XShape subtitle = oObj.getSubTitle();
80         tRes.tested("getSubTitle()", subtitle != null);
81     }
82 
83     /**
84     * Test calls the method and checks returned value. <p>
85     * Has <b> OK </b> status if returned value isn't null. <p>
86     */
_getLegend()87     public void _getLegend() {
88         XShape legend = oObj.getLegend();
89         tRes.tested("getLegend()", legend != null);
90     }
91 
92     /**
93     * Test calls the method and checks returned value. <p>
94     * Has <b> OK </b> status if returned value isn't null. <p>
95     */
_getArea()96     public void _getArea() {
97         XPropertySet area = oObj.getArea();
98         tRes.tested("getArea()", area != null);
99     }
100 
101     /**
102     * Test calls the method and checks returned value. <p>
103     * Has <b> OK </b> status if returned value isn't null. <p>
104     */
_getDiagram()105     public void _getDiagram() {
106         diagram = oObj.getDiagram();
107         tRes.tested("getDiagram()", diagram != null);
108     }
109 
110     /**
111     * Test compares type of diagram before method call and after.<p>
112     * Has <b> OK </b> status if diagram types are not equal. <p>
113     *
114     * The following method tests are to be completed successfully before :
115     * <ul>
116     *  <li> <code> getDiagram </code> : to have diagram before method call</li>
117     * </ul>
118     *
119     * @see com.sun.star.chart.XDiagram
120     */
_setDiagram()121     public void _setDiagram() {
122         requiredMethod("getDiagram()");
123         String oldType = diagram.getDiagramType();
124         XDiagram diag = (XDiagram)tEnv.getObjRelation("DIAGRAM");
125         oObj.setDiagram(diag);
126         String newType = oObj.getDiagram().getDiagramType();
127         tRes.tested("setDiagram()", !(oldType.equals(newType)));
128     }
129 
130     /**
131     * Test calls the method and checks returned value. <p>
132     * Has <b> OK </b> status if returned value isn't null. <p>
133     */
_getData()134     public void _getData() {
135         ChartData = oObj.getData();
136         tRes.tested("getData()", ChartData != null);
137     }
138 
139     /**
140     * Test compares data before method call and after. <p>
141     * Has <b> OK </b> status if the data before method call and
142     * after are not equal. <p>
143     * The following method tests are to be completed successfully before :
144     * <ul>
145     *  <li> <code> getData </code> : to have data before method call </li>
146     * </ul>
147     * @see com.sun.star.chart.XChartData
148     */
_attachData()149     public void _attachData() {
150         requiredMethod("getData()");
151         XChartData data = (XChartData)tEnv.getObjRelation("CHARTDATA");
152         oObj.attachData(data);
153         XChartData newdata = oObj.getData();
154 
155         tRes.tested("attachData()", !(newdata.equals(ChartData)));
156     }
157 
158 }
159 
160 
161