1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package mod._fps;
29 
30 import java.io.PrintWriter;
31 
32 import lib.StatusException;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
36 
37 import com.sun.star.lang.XMultiServiceFactory;
38 import com.sun.star.uno.XInterface;
39 
40 /**
41 * Test for object which is represented by service
42 * <code>com.sun.star.ui.FilePicker</code>. <p>
43 * Object implements the following interfaces :
44 * <ul>
45 *  <li> <code>com::sun::star::ui::XFilePicker</code></li>
46 *  <li> <code>com::sun::star::lang::XInitialization</code></li>
47 *  <li> <code>com::sun::star::lang::XServiceInfo</code></li>
48 *  <li> <code>com::sun::star::lang::XTypeProvider</code></li>
49 *  <li> <code>com::sun::star::ui::XExecutableDialog</code></li>
50 *  <li> <code>com::sun::star::ui::XFilePickerControlAccess</code></li>
51 *  <li> <code>com::sun::star::ui::XFilterManager</code></li>
52 *  <li> <code>com::sun::star::lang::XComponent</code></li>
53 *  <li> <code>com::sun::star::ui::XFilePickerNotifier</code></li>
54 * </ul>
55 * This object test <b> is NOT </b> designed to be run in several
56 * threads concurently.
57 * @see com.sun.star.ui.XFilePicker
58 * @see com.sun.star.lang.XInitialization
59 * @see com.sun.star.lang.XServiceInfo
60 * @see com.sun.star.lang.XTypeProvider
61 * @see com.sun.star.ui.XExecutableDialog
62 * @see com.sun.star.ui.XFilePickerControlAccess
63 * @see com.sun.star.ui.XFilterManager
64 * @see com.sun.star.lang.XComponent
65 * @see com.sun.star.ui.XFilePickerNotifier
66 * @see com.sun.star.ui.XFilePicker
67 * @see ifc.ui._XFilePicker
68 * @see ifc.lang._XInitialization
69 * @see ifc.lang._XServiceInfo
70 * @see ifc.lang._XTypeProvider
71 * @see ifc.ui._XExecutableDialog
72 * @see ifc.ui._XFilePickerControlAccess
73 * @see ifc.ui._XFilterManager
74 * @see ifc.lang._XComponent
75 * @see ifc.ui._XFilePickerNotifier
76 */
77 public class FilePicker extends TestCase {
78 
79     /**
80     * Creating a Testenvironment for the interfaces to be tested.
81     * Creates an instance of the service
82     * <code>com.sun.star.ui.FilePicker</code>. <p>
83     *     Object relations created :
84     * <ul>
85     *  <li> <code>'XInitialization.args'</code> for
86     *      {@link ifc.lang._XInitialization} : argument
87     *    for creating dialog from teamplate. </li>
88     *  <li> <code>'XFilePickerControlAccess.ControlID'</code> for
89     *      {@link ifc.ui._XFilePickerControlAccess} : here
90     *    it is identifier of check box.</li>
91     *  <li> <code>'XFilePickerControlAccess.ControlValue'</code> for
92     *      {@link ifc.ui._XFilePickerControlAccess} :
93     *      The value for control to set (since the initial value
94     *      of the control is empty) .</li>
95     * </ul>
96     */
97     public TestEnvironment createTestEnvironment( TestParameters Param,
98                                                   PrintWriter log )
99                                                     throws StatusException {
100         XInterface oObj = null;
101         Object oInterface = null;
102         XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
103 
104         Object[] iniArgs = new Object[] { new Short
105             (com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_READONLY_VERSION)};
106         short ctrlId =
107             com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_READONLY;
108         try {
109             oInterface = xMSF.createInstance
110                 ( "com.sun.star.ui.dialogs.FilePicker" );
111         } catch( com.sun.star.uno.Exception e ) {
112             log.println("Can't create an object." );
113             throw new StatusException( "Can't create an object", e );
114         }
115 
116         oObj = (XInterface) oInterface;
117 
118         TestEnvironment tEnv = new TestEnvironment( oObj );
119 
120         // adding relation for XInitialization
121         tEnv.addObjRelation("XInitialization.args", iniArgs) ;
122 
123         // adding relation for XFilePickerControlAccess
124         tEnv.addObjRelation("XFilePickerControlAccess.ControlID",
125             new Short(ctrlId)) ;
126         tEnv.addObjRelation("XFilePickerControlAccess.ControlValue",
127             Boolean.FALSE) ;
128 
129         return tEnv;
130     } // finish method getTestEnvironment
131 
132 }
133 
134