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