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: _XFilePicker.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 com
.sun
.star
.ui
.dialogs
.XFilePicker
;
38 * Testing <code>com.sun.star.ui.XFilePicker</code>
41 * <li><code> setMultiSelectionMode()</code></li>
42 * <li><code> setDefaultName()</code></li>
43 * <li><code> setDisplayDirectory()</code></li>
44 * <li><code> getDisplayDirectory()</code></li>
45 * <li><code> getPath()</code></li>
47 * The following predefined files needed to complete the test:
49 * <li> <code>'space-metal.jpg'</code> : just to exist. </li>
51 * Test is <b> NOT </b> multithread compilant. <p>
52 * @see com.sun.star.ui.XFolderPicker
54 public class _XFilePicker
extends MultiMethodTest
{
56 public XFilePicker oObj
= null;
57 private String dir
= null ;
58 private String fname
= "space-metal.jpg" ;
61 * Sets the current directory to the test document directory. <p>
62 * Has <b>OK</b> status if no exceptions occured.
64 public void _setDisplayDirectory() {
65 boolean result
= true ;
66 dir
= util
.utils
.getFullTestURL("") ;
68 log
.println("Trying to set dir '" + dir
+ "'") ;
70 oObj
.setDisplayDirectory(dir
) ;
71 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
72 log
.println("Directory '" + dir
+ "' not found :" + e
) ;
76 tRes
.tested("setDisplayDirectory()", result
) ;
80 * Gets the current directory. <p>
81 * Has <b>OK</b> status if get value is equal to set value
82 * passed to <code>setDisplayDirectory</code> <p>
83 * The following method tests are to be completed successfully before :
85 * <li> <code> setDisplayDirectory </code> </li>
88 public void _getDisplayDirectory() {
89 requiredMethod("setDisplayDirectory()") ;
91 String gDir
= oObj
.getDisplayDirectory() ;
93 log
.println("Get dir '" + gDir
+ "'") ;
95 tRes
.tested("getDisplayDirectory()", dir
.equals(gDir
)) ;
99 * Sets default name to file name existing in test document
100 * directory ('space-metal.jpg'). <p>
101 * Has <b>OK</b> status if no exceptions occured.
103 public void _setDefaultName() {
104 boolean result
= true ;
107 oObj
.setDefaultName(fname
) ;
108 } catch (Exception e
) {
109 log
.println("Exception setting default name :" + e
) ;
113 tRes
.tested("setDefaultName()", result
) ;
117 * Just switch object to MultiSelectionMode. There is no ways
118 * to check this method (only interactively). <p>
119 * Has <b>OK</b> status if no runtime exceptions occured.
121 public void _setMultiSelectionMode() {
123 oObj
.setMultiSelectionMode(true) ;
125 tRes
.tested("setMultiSelectionMode()", true) ;
129 * Gets completed path from dialog. If <code>execute()</code>
130 * method was not called then zero length array is returned.
131 * So to check actual functionality of this method interactive
132 * testing is required. <p>
133 * Has <b>OK</b> status if zero length array returned (this
134 * occurs if <code>execute()</code>
135 * method was not called yet) or if array contains at least one
136 * element and it equals to <code>[Directory set] +
137 * [Default file name set]</code>. <p>
138 * The following method tests are to be completed successfully before :
140 * <li> <code> setDisplayDirectory </code> </li>
141 * <li> <code> setDefaultName </code> </li>
144 public void _getFiles() {
145 requiredMethod("setDisplayDirectory()");
146 requiredMethod("setDefaultName()");
148 String
[] files
= oObj
.getFiles();
150 if (files
.length
> 0) {
151 log
.println("Path get : '" + files
[0] + "'") ;
153 tRes
.tested("getFiles()", (dir
+ fname
).equals(files
[0])) ;
155 log
.println("No files were selected or execute() method was not called.") ;
157 tRes
.tested("getFiles()", true);