1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.ui.dialogs; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.ui.dialogs.XFilePicker; 29cdf0e10cSrcweir 30cdf0e10cSrcweir /** 31cdf0e10cSrcweir * Testing <code>com.sun.star.ui.XFilePicker</code> 32cdf0e10cSrcweir * interface methods : 33cdf0e10cSrcweir * <ul> 34cdf0e10cSrcweir * <li><code> setMultiSelectionMode()</code></li> 35cdf0e10cSrcweir * <li><code> setDefaultName()</code></li> 36cdf0e10cSrcweir * <li><code> setDisplayDirectory()</code></li> 37cdf0e10cSrcweir * <li><code> getDisplayDirectory()</code></li> 38cdf0e10cSrcweir * <li><code> getPath()</code></li> 39cdf0e10cSrcweir * </ul> <p> 40cdf0e10cSrcweir * The following predefined files needed to complete the test: 41cdf0e10cSrcweir * <ul> 42cdf0e10cSrcweir * <li> <code>'space-metal.jpg'</code> : just to exist. </li> 43cdf0e10cSrcweir * <ul> <p> 44cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 45cdf0e10cSrcweir * @see com.sun.star.ui.XFolderPicker 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir public class _XFilePicker extends MultiMethodTest { 48cdf0e10cSrcweir 49cdf0e10cSrcweir public XFilePicker oObj = null; 50cdf0e10cSrcweir private String dir = null ; 51cdf0e10cSrcweir private String fname = "space-metal.jpg" ; 52cdf0e10cSrcweir 53cdf0e10cSrcweir /** 54cdf0e10cSrcweir * Sets the current directory to the test document directory. <p> 55cdf0e10cSrcweir * Has <b>OK</b> status if no exceptions occured. 56cdf0e10cSrcweir */ _setDisplayDirectory()57cdf0e10cSrcweir public void _setDisplayDirectory() { 58cdf0e10cSrcweir boolean result = true ; 59cdf0e10cSrcweir dir = util.utils.getFullTestURL("") ; 60cdf0e10cSrcweir 61cdf0e10cSrcweir log.println("Trying to set dir '" + dir + "'") ; 62cdf0e10cSrcweir try { 63cdf0e10cSrcweir oObj.setDisplayDirectory(dir) ; 64cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 65cdf0e10cSrcweir log.println("Directory '" + dir + "' not found :" + e) ; 66cdf0e10cSrcweir result = false ; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir tRes.tested("setDisplayDirectory()", result) ; 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir /** 73cdf0e10cSrcweir * Gets the current directory. <p> 74cdf0e10cSrcweir * Has <b>OK</b> status if get value is equal to set value 75cdf0e10cSrcweir * passed to <code>setDisplayDirectory</code> <p> 76cdf0e10cSrcweir * The following method tests are to be completed successfully before : 77cdf0e10cSrcweir * <ul> 78cdf0e10cSrcweir * <li> <code> setDisplayDirectory </code> </li> 79cdf0e10cSrcweir * </ul> 80cdf0e10cSrcweir */ _getDisplayDirectory()81cdf0e10cSrcweir public void _getDisplayDirectory() { 82cdf0e10cSrcweir requiredMethod("setDisplayDirectory()") ; 83cdf0e10cSrcweir 84cdf0e10cSrcweir String gDir = oObj.getDisplayDirectory() ; 85cdf0e10cSrcweir 86cdf0e10cSrcweir log.println("Get dir '" + gDir + "'") ; 87cdf0e10cSrcweir 88cdf0e10cSrcweir tRes.tested("getDisplayDirectory()", dir.equals(gDir)) ; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir /** 92cdf0e10cSrcweir * Sets default name to file name existing in test document 93cdf0e10cSrcweir * directory ('space-metal.jpg'). <p> 94cdf0e10cSrcweir * Has <b>OK</b> status if no exceptions occured. 95cdf0e10cSrcweir */ _setDefaultName()96cdf0e10cSrcweir public void _setDefaultName() { 97cdf0e10cSrcweir boolean result = true ; 98cdf0e10cSrcweir 99cdf0e10cSrcweir try { 100cdf0e10cSrcweir oObj.setDefaultName(fname) ; 101cdf0e10cSrcweir } catch (Exception e) { 102cdf0e10cSrcweir log.println("Exception setting default name :" + e) ; 103cdf0e10cSrcweir result = false ; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir tRes.tested("setDefaultName()", result) ; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir /** 110cdf0e10cSrcweir * Just switch object to MultiSelectionMode. There is no ways 111cdf0e10cSrcweir * to check this method (only interactively). <p> 112cdf0e10cSrcweir * Has <b>OK</b> status if no runtime exceptions occured. 113cdf0e10cSrcweir */ _setMultiSelectionMode()114cdf0e10cSrcweir public void _setMultiSelectionMode() { 115cdf0e10cSrcweir 116cdf0e10cSrcweir oObj.setMultiSelectionMode(true) ; 117cdf0e10cSrcweir 118cdf0e10cSrcweir tRes.tested("setMultiSelectionMode()", true) ; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir /** 122cdf0e10cSrcweir * Gets completed path from dialog. If <code>execute()</code> 123cdf0e10cSrcweir * method was not called then zero length array is returned. 124cdf0e10cSrcweir * So to check actual functionality of this method interactive 125cdf0e10cSrcweir * testing is required. <p> 126cdf0e10cSrcweir * Has <b>OK</b> status if zero length array returned (this 127cdf0e10cSrcweir * occurs if <code>execute()</code> 128cdf0e10cSrcweir * method was not called yet) or if array contains at least one 129cdf0e10cSrcweir * element and it equals to <code>[Directory set] + 130cdf0e10cSrcweir * [Default file name set]</code>. <p> 131cdf0e10cSrcweir * The following method tests are to be completed successfully before : 132cdf0e10cSrcweir * <ul> 133cdf0e10cSrcweir * <li> <code> setDisplayDirectory </code> </li> 134cdf0e10cSrcweir * <li> <code> setDefaultName </code> </li> 135cdf0e10cSrcweir * </ul> 136cdf0e10cSrcweir */ _getFiles()137cdf0e10cSrcweir public void _getFiles() { 138cdf0e10cSrcweir requiredMethod("setDisplayDirectory()"); 139cdf0e10cSrcweir requiredMethod("setDefaultName()"); 140cdf0e10cSrcweir 141cdf0e10cSrcweir String[] files = oObj.getFiles(); 142cdf0e10cSrcweir 143cdf0e10cSrcweir if (files.length > 0) { 144cdf0e10cSrcweir log.println("Path get : '" + files[0] + "'") ; 145cdf0e10cSrcweir 146cdf0e10cSrcweir tRes.tested("getFiles()", (dir + fname).equals(files[0])) ; 147cdf0e10cSrcweir } else { 148cdf0e10cSrcweir log.println("No files were selected or execute() method was not called.") ; 149cdf0e10cSrcweir 150cdf0e10cSrcweir tRes.tested("getFiles()", true); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir 157