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.ui.dialogs;
25 
26 import lib.MultiMethodTest;
27 import lib.StatusException;
28 
29 import com.sun.star.ui.dialogs.XFilePreview;
30 
31 public class _XFilePreview extends MultiMethodTest {
32 
33     public XFilePreview oObj=null;
34 
35     /**
36      * _getSupportedImageFormats() gets all formats and
37      * stores them in an Array of short.<br>
38      * Is OK is the resulting Array isn't empty
39     */
_getSupportedImageFormats()40     public void _getSupportedImageFormats() {
41         short[] formats = oObj.getSupportedImageFormats();
42         tRes.tested("getSupportedImageFormats()", formats.length > 0);
43     }
44 
45     /**
46      * _getTargetColorDepth() gets the color depth
47      * and stores it in an int.<br>
48      * Is OK is the resulting int isn't 1
49     */
_getTargetColorDepth()50     public void _getTargetColorDepth() {
51         int CDepth = oObj.getTargetColorDepth();
52         tRes.tested("getTargetColorDepth()",CDepth != 1);
53     }
54 
55     /**
56      * _getAvailableWidth() gets the width
57      * and stores it in an int.<br>
58      * Is OK is the resulting int isn't 1
59     */
_getAvailableWidth()60     public void _getAvailableWidth() {
61         int the_width = oObj.getAvailableWidth();
62         tRes.tested("getAvailableWidth()", the_width != 1);
63     }
64 
65     /**
66      * _getAvailableHeight() gets the width
67      * and stores it in an int.<br>
68      * Is OK is the resulting int isn't 1
69     */
_getAvailableHeight()70     public void _getAvailableHeight() {
71         int the_height = oObj.getAvailableHeight();
72         tRes.tested("getAvailableHeight()", the_height != 1);
73     }
74 
75     /**
76     * sets the empty image.
77     * Is OK if no exception no exceptions were thrown.
78     */
_setImage()79     public void _setImage() {
80         boolean bOK = true;
81         try {
82             oObj.setImage
83                 (com.sun.star.ui.dialogs.FilePreviewImageFormats.BITMAP,null);
84         } catch(com.sun.star.lang.IllegalArgumentException e) {
85             bOK = false;
86             throw new StatusException( "Can't set empty image", e );
87         }
88         tRes.tested("setImage()", bOK);
89     }
90 
91     boolean prev_state;
92 
93     /**
94      * _setShowState() sets the state
95      * to the opposite value returned by getShowState.<br>
96      * Is OK is the returned result is false or if
97      * the value that was set is equal to the value
98      * that was returned by getShowState.
99     */
_setShowState()100     public void _setShowState() {
101         requiredMethod("getShowState()");
102         boolean success = oObj.setShowState(!prev_state);
103         boolean res_state = oObj.getShowState();
104         tRes.tested("setShowState()", !success || res_state != prev_state);
105     }
106 
107     /**
108      * _getShowState() gets the state
109      * and sets it to the opposite.<br>
110      * Is OK if no exceptions were thrown
111     */
_getShowState()112     public void _getShowState() {
113         prev_state = oObj.getShowState();
114         tRes.tested("getShowState()", true);
115     }
116 
117 }
118 
119