1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XFilePickerControlAccess.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc
.ui
.dialogs
;
33 import lib
.MultiMethodTest
;
35 import lib
.StatusException
;
36 import util
.ValueChanger
;
37 import util
.ValueComparer
;
39 import com
.sun
.star
.ui
.dialogs
.XFilePickerControlAccess
;
42 * Testing <code>com.sun.star.ui.XFilePickerControlAccess</code>
45 * <li><code> setValue()</code></li>
46 * <li><code> getValue()</code></li>
47 * <li><code> setLabel()</code></li>
48 * <li><code> getLabel()</code></li>
49 * <li><code> getFocused()</code></li>
50 * <li><code> enableControl()</code></li>
52 * This test needs the following object relations :
54 * <li> <code>'XFilePickerControlAccess.ControlID'</code> (of type
55 * <code>Short</code>) : control identifier in the extended
56 * FilePicker dialog. </li>
57 * <li> <code>'XFilePickerControlAccess.ControlValue'</code> (of type
58 * <code>Object</code>) <b>optional</b> (but mostly desireable
59 * since the control has emtpy initial value):
60 * the value which can set for the control . </li>
62 * Test is <b> NOT </b> multithread compilant. <p>
63 * @see com.sun.star.ui.XFilePickerControlAccess
65 public class _XFilePickerControlAccess
extends MultiMethodTest
{
67 public XFilePickerControlAccess oObj
= null;
68 private short cntlID
= -1 ;
69 private Object oldVal
= null ;
70 private String oldLab
= null ;
73 * Retrieves object relations.
74 * @throws StatusException If one of relations not found.
76 public void before() {
77 Short ID
= (Short
) tEnv
.getObjRelation
78 ("XFilePickerControlAccess.ControlID") ;
80 log
.println("!!! Relation not found !!!") ;
81 throw new StatusException(Status
.failed("Relation not found")) ;
84 cntlID
= ID
.shortValue() ;
88 * Gets the value of the control and stores it. <p>
89 * Has <b>OK</b> status if no runtime exceptions occured.
91 public void _getValue() {
92 boolean result
= true ;
95 oldVal
= oObj
.getValue(cntlID
,(short)0);
96 } catch (Exception e
) {
97 e
.printStackTrace(log
) ;
101 tRes
.tested("getValue()", result
) ;
105 * Changes the value gotten by <code>getValue</code> method,
106 * or gets the value from relation if it exits.
107 * Sets this value and then check if it was properly set. <p>
108 * Has <b>OK</b> status if <code>getValue</code> method returns
109 * the same value which was set. <p>
110 * The following method tests are to be completed successfully before :
112 * <li> <code> getValue </code> </li>
115 public void _setValue() {
116 requiredMethod("getValue()") ;
117 boolean result
= true ;
119 Object newVal
= tEnv
.getObjRelation
120 ("XFilePickerControlAccess.ControlValue");
121 if (newVal
== null) {
122 newVal
= ValueChanger
.changePValue(oldVal
) ;
125 Object getVal
= null ;
128 oObj
.setValue(cntlID
, (short)0 , newVal
) ;
129 getVal
= oObj
.getValue(cntlID
,(short)0) ;
130 } catch (Exception e
) {
131 e
.printStackTrace(log
) ;
135 result
&= ValueComparer
.equalValue(newVal
, getVal
) ;
137 tRes
.tested("setValue()", result
) ;
141 * Gets the label of the control and stores it. <p>
142 * Has <b>OK</b> status if no runtime exceptions occured.
144 public void _getLabel() {
147 oldLab
= oObj
.getLabel(cntlID
);
148 } catch (Exception e
) {
149 e
.printStackTrace(log
) ;
152 tRes
.tested("getLabel()", oldLab
!= null) ;
156 * Changes the label gotten by <code>getLabel</code> method,
157 * set this label and then check if it was properly set. <p>
158 * Has <b>OK</b> status if <code>getLael</code> method returns
159 * the same value which was set. <p>
160 * The following method tests are to be completed successfully before :
162 * <li> <code> getLabel </code> </li>
165 public void _setLabel() {
166 requiredMethod("getLabel()") ;
167 boolean result
= true ;
169 String newVal
= oldLab
+ "_" ;
170 String getVal
= null ;
173 oObj
.setLabel(cntlID
, newVal
) ;
174 getVal
= oObj
.getLabel(cntlID
) ;
175 } catch (Exception e
) {
176 e
.printStackTrace(log
) ;
180 result
&= newVal
.equals(getVal
) ;
182 tRes
.tested("setLabel()", result
) ;
186 * Disables and then enables the control. Can be checked only
188 * Has <b>OK</b> status if no runtime exceptions occured.
190 public void _enableControl() {
191 boolean result
= true ;
194 oObj
.enableControl(cntlID
, false) ;
195 oObj
.enableControl(cntlID
, true) ;
196 } catch (Exception e
) {
197 e
.printStackTrace(log
) ;
201 tRes
.tested("enableControl()", result
) ;