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
;
32 import com
.sun
.star
.ui
.dialogs
.XFilePicker
;
35 * Testing <code>com.sun.star.ui.XFilePicker</code>
38 * <li><code> setMultiSelectionMode()</code></li>
39 * <li><code> setDefaultName()</code></li>
40 * <li><code> setDisplayDirectory()</code></li>
41 * <li><code> getDisplayDirectory()</code></li>
42 * <li><code> getPath()</code></li>
44 * The following predefined files needed to complete the test:
46 * <li> <code>'space-metal.jpg'</code> : just to exist. </li>
48 * Test is <b> NOT </b> multithread compilant. <p>
49 * @see com.sun.star.ui.XFolderPicker
51 public class _XFilePicker
extends MultiMethodTest
{
53 public XFilePicker oObj
= null;
54 private String dir
= null ;
55 private String fname
= "space-metal.jpg" ;
58 * Sets the current directory to the test document directory. <p>
59 * Has <b>OK</b> status if no exceptions occurred.
61 public void _setDisplayDirectory() {
62 boolean result
= true ;
63 dir
= util
.utils
.getFullTestURL("") ;
65 log
.println("Trying to set dir '" + dir
+ "'") ;
67 oObj
.setDisplayDirectory(dir
) ;
68 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
69 log
.println("Directory '" + dir
+ "' not found :" + e
) ;
73 tRes
.tested("setDisplayDirectory()", result
) ;
77 * Gets the current directory. <p>
78 * Has <b>OK</b> status if get value is equal to set value
79 * passed to <code>setDisplayDirectory</code> <p>
80 * The following method tests are to be completed successfully before :
82 * <li> <code> setDisplayDirectory </code> </li>
85 public void _getDisplayDirectory() {
86 requiredMethod("setDisplayDirectory()") ;
88 String gDir
= oObj
.getDisplayDirectory() ;
90 log
.println("Get dir '" + gDir
+ "'") ;
92 tRes
.tested("getDisplayDirectory()", dir
.equals(gDir
)) ;
96 * Sets default name to file name existing in test document
97 * directory ('space-metal.jpg'). <p>
98 * Has <b>OK</b> status if no exceptions occurred.
100 public void _setDefaultName() {
101 boolean result
= true ;
104 oObj
.setDefaultName(fname
) ;
105 } catch (Exception e
) {
106 log
.println("Exception setting default name :" + e
) ;
110 tRes
.tested("setDefaultName()", result
) ;
114 * Just switch object to MultiSelectionMode. There is no ways
115 * to check this method (only interactively). <p>
116 * Has <b>OK</b> status if no runtime exceptions occurred.
118 public void _setMultiSelectionMode() {
120 oObj
.setMultiSelectionMode(true) ;
122 tRes
.tested("setMultiSelectionMode()", true) ;
126 * Gets completed path from dialog. If <code>execute()</code>
127 * method was not called then zero length array is returned.
128 * So to check actual functionality of this method interactive
129 * testing is required. <p>
130 * Has <b>OK</b> status if zero length array returned (this
131 * occurs if <code>execute()</code>
132 * method was not called yet) or if array contains at least one
133 * element and it equals to <code>[Directory set] +
134 * [Default file name set]</code>. <p>
135 * The following method tests are to be completed successfully before :
137 * <li> <code> setDisplayDirectory </code> </li>
138 * <li> <code> setDefaultName </code> </li>
141 public void _getFiles() {
142 requiredMethod("setDisplayDirectory()");
143 requiredMethod("setDefaultName()");
145 String
[] files
= oObj
.getFiles();
147 if (files
.length
> 0) {
148 log
.println("Path get : '" + files
[0] + "'") ;
150 tRes
.tested("getFiles()", (dir
+ fname
).equals(files
[0])) ;
152 log
.println("No files were selected or execute() method was not called.") ;
154 tRes
.tested("getFiles()", true);