Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / mod / _fps / FilePicker.java
blob885bef0efeeecf8642db65daf19ade12b6d00e1e
1 /*
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 mod._fps;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
27 import com.sun.star.lang.XMultiServiceFactory;
28 import com.sun.star.uno.XInterface;
30 /**
31 * Test for object which is represented by service
32 * <code>com.sun.star.ui.FilePicker</code>. <p>
33 * Object implements the following interfaces :
34 * <ul>
35 * <li> <code>com::sun::star::ui::XFilePicker</code></li>
36 * <li> <code>com::sun::star::lang::XInitialization</code></li>
37 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
38 * <li> <code>com::sun::star::lang::XTypeProvider</code></li>
39 * <li> <code>com::sun::star::ui::XExecutableDialog</code></li>
40 * <li> <code>com::sun::star::ui::XFilePickerControlAccess</code></li>
41 * <li> <code>com::sun::star::ui::XFilterManager</code></li>
42 * <li> <code>com::sun::star::lang::XComponent</code></li>
43 * <li> <code>com::sun::star::ui::XFilePickerNotifier</code></li>
44 * </ul>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurrently.
47 * @see com.sun.star.ui.XFilePicker
48 * @see com.sun.star.lang.XInitialization
49 * @see com.sun.star.lang.XServiceInfo
50 * @see com.sun.star.lang.XTypeProvider
51 * @see com.sun.star.ui.XExecutableDialog
52 * @see com.sun.star.ui.XFilePickerControlAccess
53 * @see com.sun.star.ui.XFilterManager
54 * @see com.sun.star.lang.XComponent
55 * @see com.sun.star.ui.XFilePickerNotifier
56 * @see com.sun.star.ui.XFilePicker
57 * @see ifc.ui.dialogs._XFilePicker
58 * @see ifc.lang._XInitialization
59 * @see ifc.lang._XServiceInfo
60 * @see ifc.lang._XTypeProvider
61 * @see ifc.ui.dialogs._XExecutableDialog
62 * @see ifc.ui.dialogs._XFilePickerControlAccess
63 * @see ifc.ui.dialogs._XFilterManager
64 * @see ifc.lang._XComponent
65 * @see ifc.ui.dialogs._XFilePickerNotifier
67 public class FilePicker extends TestCase {
69 /**
70 * Creating a TestEnvironment for the interfaces to be tested.
71 * Creates an instance of the service
72 * <code>com.sun.star.ui.FilePicker</code>. <p>
73 * Object relations created :
74 * <ul>
75 * <li> <code>'XInitialization.args'</code> for
76 * {@link ifc.lang._XInitialization} : argument
77 * for creating dialog from template. </li>
78 * <li> <code>'XFilePickerControlAccess.ControlID'</code> for
79 * {@link ifc.ui.dialogs._XFilePickerControlAccess} : here
80 * it is identifier of check box.</li>
81 * <li> <code>'XFilePickerControlAccess.ControlValue'</code> for
82 * {@link ifc.ui.dialogs._XFilePickerControlAccess} :
83 * The value for control to set (since the initial value
84 * of the control is empty) .</li>
85 * </ul>
87 @Override
88 public TestEnvironment createTestEnvironment( TestParameters Param,
89 PrintWriter log )
90 throws Exception {
91 XInterface oObj = null;
92 Object oInterface = null;
93 XMultiServiceFactory xMSF = Param.getMSF();
95 Object[] iniArgs = new Object[] { Short.valueOf
96 (com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_READONLY_VERSION)};
97 short ctrlId =
98 com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_READONLY;
99 oInterface = xMSF.createInstance
100 ( "com.sun.star.ui.dialogs.FilePicker" );
102 oObj = (XInterface) oInterface;
104 TestEnvironment tEnv = new TestEnvironment( oObj );
106 // adding relation for XInitialization
107 tEnv.addObjRelation("XInitialization.args", iniArgs) ;
109 // adding relation for XFilePickerControlAccess
110 tEnv.addObjRelation("XFilePickerControlAccess.ControlID",
111 Short.valueOf(ctrlId)) ;
112 tEnv.addObjRelation("XFilePickerControlAccess.ControlValue",
113 Boolean.FALSE) ;
115 return tEnv;
116 } // finish method getTestEnvironment