Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / ui / dialogs / _XFilePickerControlAccess.java
blobcf205d267772af7911385d269760a5e3f18b5458
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.ui.dialogs;
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
33 import util.ValueChanger;
34 import util.ValueComparer;
36 import com.sun.star.ui.dialogs.XFilePickerControlAccess;
38 /**
39 * Testing <code>com.sun.star.ui.XFilePickerControlAccess</code>
40 * interface methods :
41 * <ul>
42 * <li><code> setValue()</code></li>
43 * <li><code> getValue()</code></li>
44 * <li><code> setLabel()</code></li>
45 * <li><code> getLabel()</code></li>
46 * <li><code> getFocused()</code></li>
47 * <li><code> enableControl()</code></li>
48 * </ul> <p>
49 * This test needs the following object relations :
50 * <ul>
51 * <li> <code>'XFilePickerControlAccess.ControlID'</code> (of type
52 * <code>Short</code>) : control identifier in the extended
53 * FilePicker dialog. </li>
54 * <li> <code>'XFilePickerControlAccess.ControlValue'</code> (of type
55 * <code>Object</code>) <b>optional</b> (but mostly desireable
56 * since the control has emtpy initial value):
57 * the value which can set for the control . </li>
58 * <ul> <p>
59 * Test is <b> NOT </b> multithread compilant. <p>
60 * @see com.sun.star.ui.XFilePickerControlAccess
62 public class _XFilePickerControlAccess extends MultiMethodTest {
64 public XFilePickerControlAccess oObj = null;
65 private short cntlID = -1 ;
66 private Object oldVal = null ;
67 private String oldLab = null ;
69 /**
70 * Retrieves object relations.
71 * @throws StatusException If one of relations not found.
73 public void before() {
74 Short ID = (Short) tEnv.getObjRelation
75 ("XFilePickerControlAccess.ControlID") ;
76 if (ID == null) {
77 log.println("!!! Relation not found !!!") ;
78 throw new StatusException(Status.failed("Relation not found")) ;
81 cntlID = ID.shortValue() ;
84 /**
85 * Gets the value of the control and stores it. <p>
86 * Has <b>OK</b> status if no runtime exceptions occurred.
88 public void _getValue() {
89 boolean result = true ;
91 try {
92 oldVal = oObj.getValue(cntlID,(short)0);
93 } catch (Exception e) {
94 e.printStackTrace(log) ;
95 result = false ;
98 tRes.tested("getValue()", result) ;
102 * Changes the value gotten by <code>getValue</code> method,
103 * or gets the value from relation if it exits.
104 * Sets this value and then check if it was properly set. <p>
105 * Has <b>OK</b> status if <code>getValue</code> method returns
106 * the same value which was set. <p>
107 * The following method tests are to be completed successfully before :
108 * <ul>
109 * <li> <code> getValue </code> </li>
110 * </ul>
112 public void _setValue() {
113 requiredMethod("getValue()") ;
114 boolean result = true ;
116 Object newVal = tEnv.getObjRelation
117 ("XFilePickerControlAccess.ControlValue");
118 if (newVal == null) {
119 newVal = ValueChanger.changePValue(oldVal) ;
122 Object getVal = null ;
124 try {
125 oObj.setValue(cntlID, (short)0 , newVal) ;
126 getVal = oObj.getValue(cntlID,(short)0) ;
127 } catch (Exception e) {
128 e.printStackTrace(log) ;
129 result = false ;
132 result &= ValueComparer.equalValue(newVal, getVal) ;
134 tRes.tested("setValue()", result) ;
138 * Gets the label of the control and stores it. <p>
139 * Has <b>OK</b> status if no runtime exceptions occurred.
141 public void _getLabel() {
143 try {
144 oldLab = oObj.getLabel(cntlID);
145 } catch (Exception e) {
146 e.printStackTrace(log) ;
149 tRes.tested("getLabel()", oldLab != null) ;
153 * Changes the label gotten by <code>getLabel</code> method,
154 * set this label and then check if it was properly set. <p>
155 * Has <b>OK</b> status if <code>getLael</code> method returns
156 * the same value which was set. <p>
157 * The following method tests are to be completed successfully before :
158 * <ul>
159 * <li> <code> getLabel </code> </li>
160 * </ul>
162 public void _setLabel() {
163 requiredMethod("getLabel()") ;
164 boolean result = true ;
166 String newVal = oldLab + "_" ;
167 String getVal = null ;
169 try {
170 oObj.setLabel(cntlID, newVal) ;
171 getVal = oObj.getLabel(cntlID) ;
172 } catch (Exception e) {
173 e.printStackTrace(log) ;
174 result = false ;
177 result &= newVal.equals(getVal) ;
179 tRes.tested("setLabel()", result) ;
183 * Disables and then enables the control. Can be checked only
184 * interactively. <p>
185 * Has <b>OK</b> status if no runtime exceptions occurred.
187 public void _enableControl() {
188 boolean result = true ;
190 try {
191 oObj.enableControl(cntlID, false) ;
192 oObj.enableControl(cntlID, true) ;
193 } catch (Exception e) {
194 e.printStackTrace(log) ;
195 result = false ;
198 tRes.tested("enableControl()", result) ;