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 
28 import com.sun.star.lang.XMultiServiceFactory;
29 import com.sun.star.ui.dialogs.XFolderPicker;
30 
31 /**
32 * Testing <code>com.sun.star.ui.XFolderPicker</code>
33 * interface methods :
34 * <ul>
35 *  <li><code> setDisplayDirectory()</code></li>
36 *  <li><code> getDisplayDirectory()</code></li>
37 * </ul> <p>
38 * Test is <b> NOT </b> multithread compilant. <p>
39 * @see com.sun.star.ui.XFolderPicker
40 */
41 public class _XFolderPicker extends MultiMethodTest {
42 
43     public XFolderPicker oObj = null;
44     private String dir = null ;
45 
46     /**
47     * Sets the current directory to SOffice temp dir. <p>
48     * Has <b>OK</b> status if no exceptions occured.
49     */
_setDisplayDirectory()50     public void _setDisplayDirectory() {
51         boolean result = true ;
52         dir = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) ;
53 
54         log.println("Trying to set dir '" + dir + "'") ;
55         try {
56             oObj.setDisplayDirectory(dir) ;
57         } catch (com.sun.star.lang.IllegalArgumentException e) {
58             log.println("Directory '" + dir + "' not found :" + e) ;
59             result = false ;
60         }
61 
62         tRes.tested("setDisplayDirectory()", result) ;
63     }
64 
65     /**
66     * Gets the current directory. <p>
67     * Has <b>OK</b> status if get value is equal to set value
68     * passed to <code>setDisplayDirectory</code> <p>
69     * The following method tests are to be completed successfully before :
70     * <ul>
71     *  <li> <code> setDisplayDirectory </code>  </li>
72     * </ul>
73     */
_getDisplayDirectory()74     public void _getDisplayDirectory() {
75         requiredMethod("setDisplayDirectory()") ;
76 
77         String gDir = oObj.getDisplayDirectory() ;
78 
79         log.println("Get dir '" + gDir + "'") ;
80 
81         tRes.tested("getDisplayDirectory()", dir.equals(gDir)) ;
82     }
83 
84     /**
85     * Gets the directory chosen by the user. <p>
86     * Has <b>OK</b> status if get value is not NULL <p>
87     */
_getDirectory()88     public void _getDirectory() {
89 
90         String gDir = oObj.getDirectory() ;
91 
92         log.println("Get dir '" + gDir + "'") ;
93 
94         tRes.tested("getDirectory()", gDir != null) ;
95     }
96 
97     /**
98     * Sets the Description for the dialog. <p>
99     * Has <b>OK</b> status if no error occurs <p>
100     */
_setDescription()101     public void _setDescription() {
102 
103         oObj.setDescription("XFolderPicker") ;
104         //to visually check if the method works
105         //oObj.execute();
106         tRes.tested("setDescription()", true) ;
107     }
108 
109 }
110 
111 
112