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 com
.sun
.star
.ui
.dialogs
.XFilePicker
;
26 * Testing <code>com.sun.star.ui.XFilePicker</code>
29 * <li><code> setMultiSelectionMode()</code></li>
30 * <li><code> setDefaultName()</code></li>
31 * <li><code> setDisplayDirectory()</code></li>
32 * <li><code> getDisplayDirectory()</code></li>
33 * <li><code> getPath()</code></li>
35 * The following predefined files needed to complete the test:
37 * <li> <code>'space-metal.jpg'</code> : just to exist. </li>
39 * Test is <b> NOT </b> multithread compliant. <p>
40 * @see com.sun.star.ui.XFolderPicker
42 public class _XFilePicker
extends MultiMethodTest
{
44 public XFilePicker oObj
= null;
45 private String dir
= null ;
46 private static final String fname
= "space-metal.jpg" ;
49 * Sets the current directory to the test document directory. <p>
50 * Has <b>OK</b> status if no exceptions occurred.
52 public void _setDisplayDirectory() {
53 boolean result
= true ;
54 dir
= util
.utils
.getFullTestURL("") ;
56 log
.println("Trying to set dir '" + dir
+ "'") ;
58 oObj
.setDisplayDirectory(dir
) ;
59 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
60 log
.println("Directory '" + dir
+ "' not found :" + e
) ;
64 tRes
.tested("setDisplayDirectory()", result
) ;
68 * Gets the current directory. <p>
69 * Has <b>OK</b> status if get value is equal to set value
70 * passed to <code>setDisplayDirectory</code> <p>
71 * The following method tests are to be completed successfully before :
73 * <li> <code> setDisplayDirectory </code> </li>
76 public void _getDisplayDirectory() {
77 requiredMethod("setDisplayDirectory()") ;
79 String gDir
= oObj
.getDisplayDirectory() ;
81 log
.println("Get dir '" + gDir
+ "'") ;
83 tRes
.tested("getDisplayDirectory()", dir
.equals(gDir
)) ;
87 * Sets default name to file name existing in test document
88 * directory ('space-metal.jpg'). <p>
89 * Has <b>OK</b> status if no exceptions occurred.
91 public void _setDefaultName() {
92 boolean result
= true ;
95 oObj
.setDefaultName(fname
) ;
96 } catch (Exception e
) {
97 log
.println("Exception setting default name :" + e
) ;
101 tRes
.tested("setDefaultName()", result
) ;
105 * Just switch object to MultiSelectionMode. There is no ways
106 * to check this method (only interactively). <p>
107 * Has <b>OK</b> status if no runtime exceptions occurred.
109 public void _setMultiSelectionMode() {
111 oObj
.setMultiSelectionMode(true) ;
113 tRes
.tested("setMultiSelectionMode()", true) ;
117 * Gets completed path from dialog. If <code>execute()</code>
118 * method was not called then zero length array is returned.
119 * So to check actual functionality of this method interactive
120 * testing is required. <p>
121 * Has <b>OK</b> status if zero length array returned (this
122 * occurs if <code>execute()</code>
123 * method was not called yet) or if array contains at least one
124 * element and it equals to <code>[Directory set] +
125 * [Default file name set]</code>. <p>
126 * The following method tests are to be completed successfully before :
128 * <li> <code> setDisplayDirectory </code> </li>
129 * <li> <code> setDefaultName </code> </li>
132 public void _getFiles() {
133 requiredMethod("setDisplayDirectory()");
134 requiredMethod("setDefaultName()");
136 String
[] files
= oObj
.getFiles();
138 if (files
.length
> 0) {
139 log
.println("Path get : '" + files
[0] + "'") ;
141 tRes
.tested("getFiles()", (dir
+ fname
).equals(files
[0])) ;
143 log
.println("No files were selected or execute() method was not called.") ;
145 tRes
.tested("getFiles()", true);