1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package mod._fps;
25 
26 import java.io.PrintWriter;
27 
28 import lib.StatusException;
29 import lib.TestCase;
30 import lib.TestEnvironment;
31 import lib.TestParameters;
32 
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.uno.XInterface;
35 
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.ui.FilePicker</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 *  <li> <code>com::sun::star::ui::XFilePicker</code></li>
42 *  <li> <code>com::sun::star::lang::XInitialization</code></li>
43 *  <li> <code>com::sun::star::lang::XServiceInfo</code></li>
44 *  <li> <code>com::sun::star::lang::XTypeProvider</code></li>
45 *  <li> <code>com::sun::star::ui::XExecutableDialog</code></li>
46 *  <li> <code>com::sun::star::ui::XFilePickerControlAccess</code></li>
47 *  <li> <code>com::sun::star::ui::XFilterManager</code></li>
48 *  <li> <code>com::sun::star::lang::XComponent</code></li>
49 *  <li> <code>com::sun::star::ui::XFilePickerNotifier</code></li>
50 * </ul>
51 * This object test <b> is NOT </b> designed to be run in several
52 * threads concurently.
53 * @see com.sun.star.ui.XFilePicker
54 * @see com.sun.star.lang.XInitialization
55 * @see com.sun.star.lang.XServiceInfo
56 * @see com.sun.star.lang.XTypeProvider
57 * @see com.sun.star.ui.XExecutableDialog
58 * @see com.sun.star.ui.XFilePickerControlAccess
59 * @see com.sun.star.ui.XFilterManager
60 * @see com.sun.star.lang.XComponent
61 * @see com.sun.star.ui.XFilePickerNotifier
62 * @see com.sun.star.ui.XFilePicker
63 * @see ifc.ui.dialogs._XFilePicker
64 * @see ifc.lang._XInitialization
65 * @see ifc.lang._XServiceInfo
66 * @see ifc.lang._XTypeProvider
67 * @see ifc.ui.dialogs._XExecutableDialog
68 * @see ifc.ui.dialogs._XFilePickerControlAccess
69 * @see ifc.ui.dialogs._XFilterManager
70 * @see ifc.lang._XComponent
71 * @see ifc.ui.dialogs._XFilePickerNotifier
72 */
73 public class FilePicker extends TestCase {
74 
75     /**
76     * Creating a Testenvironment for the interfaces to be tested.
77     * Creates an instance of the service
78     * <code>com.sun.star.ui.FilePicker</code>. <p>
79     *     Object relations created :
80     * <ul>
81     *  <li> <code>'XInitialization.args'</code> for
82     *      {@link ifc.lang._XInitialization} : argument
83     *    for creating dialog from teamplate. </li>
84     *  <li> <code>'XFilePickerControlAccess.ControlID'</code> for
85     *      {@link ifc.ui.dialogs._XFilePickerControlAccess} : here
86     *    it is identifier of check box.</li>
87     *  <li> <code>'XFilePickerControlAccess.ControlValue'</code> for
88     *      {@link ifc.ui.dialogs._XFilePickerControlAccess} :
89     *      The value for control to set (since the initial value
90     *      of the control is empty) .</li>
91     * </ul>
92     */
createTestEnvironment( TestParameters Param, PrintWriter log )93     public TestEnvironment createTestEnvironment( TestParameters Param,
94                                                   PrintWriter log )
95                                                     throws StatusException {
96         XInterface oObj = null;
97         Object oInterface = null;
98         XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
99 
100         Object[] iniArgs = new Object[] { new Short
101             (com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_READONLY_VERSION)};
102         short ctrlId =
103             com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_READONLY;
104         try {
105             oInterface = xMSF.createInstance
106                 ( "com.sun.star.ui.dialogs.FilePicker" );
107         } catch( com.sun.star.uno.Exception e ) {
108             log.println("Can't create an object." );
109             throw new StatusException( "Can't create an object", e );
110         }
111 
112         oObj = (XInterface) oInterface;
113 
114         TestEnvironment tEnv = new TestEnvironment( oObj );
115 
116         // adding relation for XInitialization
117         tEnv.addObjRelation("XInitialization.args", iniArgs) ;
118 
119         // adding relation for XFilePickerControlAccess
120         tEnv.addObjRelation("XFilePickerControlAccess.ControlID",
121             new Short(ctrlId)) ;
122         tEnv.addObjRelation("XFilePickerControlAccess.ControlValue",
123             Boolean.FALSE) ;
124 
125         return tEnv;
126     } // finish method getTestEnvironment
127 
128 }
129 
130