2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc
.ui
.dialogs
;
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
24 import util
.ValueChanger
;
25 import util
.ValueComparer
;
27 import com
.sun
.star
.ui
.dialogs
.XFilePickerControlAccess
;
30 * Testing <code>com.sun.star.ui.XFilePickerControlAccess</code>
33 * <li><code> setValue()</code></li>
34 * <li><code> getValue()</code></li>
35 * <li><code> setLabel()</code></li>
36 * <li><code> getLabel()</code></li>
37 * <li><code> getFocused()</code></li>
38 * <li><code> enableControl()</code></li>
40 * This test needs the following object relations :
42 * <li> <code>'XFilePickerControlAccess.ControlID'</code> (of type
43 * <code>Short</code>) : control identifier in the extended
44 * FilePicker dialog. </li>
45 * <li> <code>'XFilePickerControlAccess.ControlValue'</code> (of type
46 * <code>Object</code>) <b>optional</b> (but mostly desirable
47 * since the control has emtpy initial value):
48 * the value which can set for the control . </li>
50 * Test is <b> NOT </b> multithread compliant. <p>
51 * @see com.sun.star.ui.XFilePickerControlAccess
53 public class _XFilePickerControlAccess
extends MultiMethodTest
{
55 public XFilePickerControlAccess oObj
= null;
56 private short cntlID
= -1 ;
57 private Object oldVal
= null ;
58 private String oldLab
= null ;
61 * Retrieves object relations.
62 * @throws StatusException If one of relations not found.
65 public void before() {
66 Short ID
= (Short
) tEnv
.getObjRelation
67 ("XFilePickerControlAccess.ControlID") ;
69 log
.println("!!! Relation not found !!!") ;
70 throw new StatusException(Status
.failed("Relation not found")) ;
73 cntlID
= ID
.shortValue() ;
77 * Gets the value of the control and stores it. <p>
78 * Has <b>OK</b> status if no runtime exceptions occurred.
80 public void _getValue() {
81 boolean result
= true ;
84 oldVal
= oObj
.getValue(cntlID
,(short)0);
85 } catch (Exception e
) {
86 e
.printStackTrace(log
) ;
90 tRes
.tested("getValue()", result
) ;
94 * Changes the value gotten by <code>getValue</code> method,
95 * or gets the value from relation if it exits.
96 * Sets this value and then check if it was properly set. <p>
97 * Has <b>OK</b> status if <code>getValue</code> method returns
98 * the same value which was set. <p>
99 * The following method tests are to be completed successfully before :
101 * <li> <code> getValue </code> </li>
104 public void _setValue() {
105 requiredMethod("getValue()") ;
106 boolean result
= true ;
108 Object newVal
= tEnv
.getObjRelation
109 ("XFilePickerControlAccess.ControlValue");
110 if (newVal
== null) {
111 newVal
= ValueChanger
.changePValue(oldVal
) ;
114 Object getVal
= null ;
117 oObj
.setValue(cntlID
, (short)0 , newVal
) ;
118 getVal
= oObj
.getValue(cntlID
,(short)0) ;
119 } catch (Exception e
) {
120 e
.printStackTrace(log
) ;
124 result
&= ValueComparer
.equalValue(newVal
, getVal
) ;
126 tRes
.tested("setValue()", result
) ;
130 * Gets the label of the control and stores it. <p>
131 * Has <b>OK</b> status if no runtime exceptions occurred.
133 public void _getLabel() {
136 oldLab
= oObj
.getLabel(cntlID
);
137 } catch (Exception e
) {
138 e
.printStackTrace(log
) ;
141 tRes
.tested("getLabel()", oldLab
!= null) ;
145 * Changes the label gotten by <code>getLabel</code> method,
146 * set this label and then check if it was properly set. <p>
147 * Has <b>OK</b> status if <code>getLael</code> method returns
148 * the same value which was set. <p>
149 * The following method tests are to be completed successfully before :
151 * <li> <code> getLabel </code> </li>
154 public void _setLabel() {
155 requiredMethod("getLabel()") ;
156 boolean result
= true ;
158 String newVal
= oldLab
+ "_" ;
159 String getVal
= null ;
162 oObj
.setLabel(cntlID
, newVal
) ;
163 getVal
= oObj
.getLabel(cntlID
) ;
164 } catch (Exception e
) {
165 e
.printStackTrace(log
) ;
169 result
&= newVal
.equals(getVal
) ;
171 tRes
.tested("setLabel()", result
) ;
175 * Disables and then enables the control. Can be checked only
177 * Has <b>OK</b> status if no runtime exceptions occurred.
179 public void _enableControl() {
180 boolean result
= true ;
183 oObj
.enableControl(cntlID
, false) ;
184 oObj
.enableControl(cntlID
, true) ;
185 } catch (Exception e
) {
186 e
.printStackTrace(log
) ;
190 tRes
.tested("enableControl()", result
) ;