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.MultiPropertyTest;
27 import lib.StatusException;
28 import util.ValueChanger;
29 
30 /**
31 * Testing <code>com.sun.star.chart.ChartAxis</code>
32 * service properties:
33 * <ul>
34 *  <li><code> ArrangeOrder</code></li>
35 *  <li><code> AutoMax</code></li>
36 *  <li><code> AutoMin</code></li>
37 *  <li><code> AutoOrigin</code></li>
38 *  <li><code> AutoStepHelp</code></li>
39 *  <li><code> AutoStepMain</code></li>
40 *  <li><code> DisplayLabels</code></li>
41 *  <li><code> GapWidth</code></li>
42 *  <li><code> HelpMarks</code></li>
43 *  <li><code> Logarithmic</code></li>
44 *  <li><code> Marks</code></li>
45 *  <li><code> Max</code></li>
46 *  <li><code> Min</code></li>
47 *  <li><code> NumberFormat</code></li>
48 *  <li><code> Origin</code></li>
49 *  <li><code> Overlap</code></li>
50 *  <li><code> StepHelp</code></li>
51 *  <li><code> StepMain</code></li>
52 *  <li><code> TextBreak</code></li>
53 *  <li><code> TextRotation</code></li>
54 *  <li><code> TextCanOverlap</code></li>
55 * </ul> <p>
56 * @see com.sun.star.chart.ChartAxis
57 */
58 public class _ChartAxis extends MultiPropertyTest {
59 
60     /**
61     * Tests property 'Max'.
62     * Property 'AutoOrigin' sets to true and property 'AutoMax'
63     * sets to false before test.
64     */
_Max()65     public void _Max() {
66         try {
67             //if AutoOrigin isn't true then this property works only when
68             //current Origin is less then new value of Max
69             oObj.setPropertyValue("AutoOrigin", new Boolean(true));
70             oObj.setPropertyValue("AutoMax",new Boolean(false));
71         } catch(com.sun.star.lang.WrappedTargetException e) {
72             log.println("Couldn't set property value");
73             e.printStackTrace(log);
74             throw new StatusException("Couldn't set property value", e);
75         } catch(com.sun.star.lang.IllegalArgumentException e) {
76             log.println("Couldn't set property value");
77             e.printStackTrace(log);
78             throw new StatusException("Couldn't set property value", e);
79         } catch(com.sun.star.beans.PropertyVetoException e) {
80             log.println("Couldn't set property value");
81             e.printStackTrace(log);
82             throw new StatusException("Couldn't set property value", e);
83         } catch(com.sun.star.beans.UnknownPropertyException e) {
84             log.println("Couldn't set property value");
85             e.printStackTrace(log);
86             throw new StatusException("Couldn't set property value", e);
87         }
88 
89         testProperty("Max");
90     }
91 
92     /**
93     * Tests property 'Min'.
94     * Property 'AutoOrigin' sets to true and property 'AutoMin'
95     * sets to false before test.
96     */
_Min()97     public void _Min() {
98         try {
99             //if AutoOrigin isn't true then this property works only when
100             //current Origin is greater then new value of Min
101             oObj.setPropertyValue("AutoOrigin", new Boolean(true));
102             oObj.setPropertyValue("AutoMin", new Boolean(false));
103         } catch(com.sun.star.lang.WrappedTargetException e) {
104             log.println("Couldn't set property value");
105             e.printStackTrace(log);
106             throw new StatusException("Couldn't set property value", e);
107         } catch(com.sun.star.lang.IllegalArgumentException e) {
108             log.println("Couldn't set property value");
109             e.printStackTrace(log);
110             throw new StatusException("Couldn't set property value", e);
111         } catch(com.sun.star.beans.PropertyVetoException e) {
112             log.println("Couldn't set property value");
113             e.printStackTrace(log);
114             throw new StatusException("Couldn't set property value", e);
115         } catch(com.sun.star.beans.UnknownPropertyException e) {
116             log.println("Couldn't set property value");
117             e.printStackTrace(log);
118             throw new StatusException("Couldn't set property value", e);
119         }
120 
121         testProperty("Min");
122     }
123 
124     /**
125     * Tests property 'Origin'.
126     * Property 'Logarithmic' sets to false before test.
127     */
_Origin()128     public void _Origin() {
129         try {
130             oObj.setPropertyValue("Logarithmic",new Boolean(false));
131         } catch(com.sun.star.lang.WrappedTargetException e) {
132             log.println("Couldn't set property value");
133             e.printStackTrace(log);
134             throw new StatusException("Couldn't set property value", e);
135         } catch(com.sun.star.lang.IllegalArgumentException e) {
136             log.println("Couldn't set property value");
137             e.printStackTrace(log);
138             throw new StatusException("Couldn't set property value", e);
139         } catch(com.sun.star.beans.PropertyVetoException e) {
140             log.println("Couldn't set property value");
141             e.printStackTrace(log);
142             throw new StatusException("Couldn't set property value", e);
143         } catch(com.sun.star.beans.UnknownPropertyException e) {
144             log.println("Couldn't set property value");
145             e.printStackTrace(log);
146             throw new StatusException("Couldn't set property value", e);
147         }
148 
149         testProperty("Origin");
150     }
151 
152     protected PropertyTester StepMainTester = new PropertyTester() {
153         protected Object getNewValue(String propName, Object oldValue)
154                 throws java.lang.IllegalArgumentException {
155             Double ValueToSet = (Double) ValueChanger.changePValue(oldValue);
156             double stm = ValueToSet.doubleValue();
157             stm = stm / 5;
158             return new Double(stm);
159         }
160     };
161 
162     /**
163     * Tests property 'StepMain'.
164     * Property 'Logarithmic' and 'AutoStepMain' sets
165     * to false before test.
166     */
_StepMain()167     public void _StepMain() {
168         try {
169             oObj.setPropertyValue("AutoStepMain", new Boolean(false));
170             oObj.setPropertyValue("Logarithmic",new Boolean(false));
171         } catch(com.sun.star.lang.WrappedTargetException e) {
172             log.println("Couldn't set property value");
173             e.printStackTrace(log);
174             throw new StatusException("Couldn't set property value", e);
175         } catch(com.sun.star.lang.IllegalArgumentException e) {
176             log.println("Couldn't set property value");
177             e.printStackTrace(log);
178             throw new StatusException("Couldn't set property value", e);
179         } catch(com.sun.star.beans.PropertyVetoException e) {
180             log.println("Couldn't set property value");
181             e.printStackTrace(log);
182             throw new StatusException("Couldn't set property value", e);
183         } catch(com.sun.star.beans.UnknownPropertyException e) {
184             log.println("Couldn't set property value");
185             e.printStackTrace(log);
186             throw new StatusException("Couldn't set property value", e);
187         }
188 
189         testProperty("StepMain", StepMainTester);
190     }
191 }  // finish class _ChartAxis
192 
193