bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _forms / OListBoxModel.java
blob5b0f054f91333461cbcc323b9e65da89155b1be8
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 .
18 package mod._forms;
20 import com.sun.star.beans.NamedValue;
21 import com.sun.star.beans.XPropertySet;
22 import com.sun.star.form.XBoundComponent;
23 import com.sun.star.form.XLoadable;
26 import com.sun.star.sdbc.SQLException;
27 import com.sun.star.sdbc.XResultSetUpdate;
28 import com.sun.star.uno.Exception;
29 import com.sun.star.uno.UnoRuntime;
30 import com.sun.star.uno.XInterface;
31 import ifc.form._XUpdateBroadcaster.UpdateChecker;
32 import java.io.PrintWriter;
33 import lib.TestEnvironment;
34 import lib.TestParameters;
35 import util.DBTools;
38 /**
39 * Test for object which is represented by service
40 * <code>com.sun.star.form.component.DatabaseListBox</code>. <p>
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>com::sun::star::io::XPersistObject</code></li>
44 * <li> <code>com::sun::star::awt::UnoControlListBoxModel</code></li>
45 * <li> <code>com::sun::star::form::XReset</code></li>
46 * <li> <code>com::sun::star::form::XBoundComponent</code></li>
47 * <li> <code>com::sun::star::form::FormComponent</code></li>
48 * <li> <code>com::sun::star::form::component::ListBox</code></li>
49 * <li> <code>com::sun::star::beans::XFastPropertySet</code></li>
50 * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li>
51 * <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li>
52 * <li> <code>com::sun::star::form::DataAwareControlModel</code></li>
53 * <li> <code>com::sun::star::beans::XPropertyState</code></li>
54 * <li> <code>com::sun::star::form::FormControlModel</code></li>
55 * <li> <code>com::sun::star::container::XNamed</code></li>
56 * <li> <code>com::sun::star::lang::XComponent</code></li>
57 * <li> <code>com::sun::star::lang::XEventListener</code></li>
58 * <li> <code>com::sun::star::beans::XPropertyAccess</code></li>
59 * <li> <code>com::sun::star::beans::XPropertyContainer</code></li>
60 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
61 * <li> <code>com::sun::star::form::XLoadListener</code></li>
62 * <li> <code>com::sun::star::form::component::DatabaseListBox</code></li>
63 * <li> <code>com::sun::star::container::XChild</code></li>
64 * </ul> <p>
65 * This object test <b> is NOT </b> designed to be run in several
66 * threads concurently.
67 * @see com.sun.star.io.XPersistObject
68 * @see com.sun.star.awt.UnoControlListBoxModel
69 * @see com.sun.star.form.XReset
70 * @see com.sun.star.form.XBoundComponent
71 * @see com.sun.star.form.FormComponent
72 * @see com.sun.star.form.component.ListBox
73 * @see com.sun.star.beans.XFastPropertySet
74 * @see com.sun.star.beans.XMultiPropertySet
75 * @see com.sun.star.form.XUpdateBroadcaster
76 * @see com.sun.star.form.DataAwareControlModel
77 * @see com.sun.star.beans.XPropertyState
78 * @see com.sun.star.form
79 * @see com.sun.star.container.XNamed
80 * @see com.sun.star.lang.XComponent
81 * @see com.sun.star.lang.XEventListener
82 * @see com.sun.star.beans.XPropertyAccess
83 * @see com.sun.star.beans.XPropertyContainer
84 * @see com.sun.star.beans.XPropertySet
85 * @see com.sun.star.form.XLoadListener
86 * @see com.sun.star.form.component.DatabaseListBox
87 * @see com.sun.star.container.XChild
88 * @see ifc.io._XPersistObject
89 * @see ifc.awt._UnoControlListBoxModel
90 * @see ifc.form._XReset
91 * @see ifc.form._XBoundComponent
92 * @see ifc.form._FormComponent
93 * @see ifc.form.component._ListBox
94 * @see ifc.beans._XFastPropertySet
95 * @see ifc.beans._XMultiPropertySet
96 * @see ifc.form._XUpdateBroadcaster
97 * @see ifc.form._DataAwareControlModel
98 * @see ifc.beans._XPropertyState
99 * @see ifc.form._FormControlModel
100 * @see ifc.container._XNamed
101 * @see ifc.lang._XComponent
102 * @see ifc.lang._XEventListener
103 * @see ifc.beans._XPropertySet
104 * @see ifc.form._XLoadListener
105 * @see ifc.form.component._DatabaseListBox
106 * @see ifc.container._XChild
108 public class OListBoxModel extends GenericModelTest {
110 * Set some member variable of the super class <CODE>GenericModelTest</CODE>:
111 * <pre>
112 * super.m_ChangePropertyName = "Date";
113 * super.m_kindOfControl="DateField";
114 * super.m_ObjectName = "stardiv.one.form.component.DateField";
115 * NamedValue DataField = new NamedValue();
116 * DataField.Name = "DataField";
117 * DataField.Value = DBTools.TST_DATE_F;
118 * super.m_propertiesToSet.add(DataField);
120 * NamedValue ListSource = new NamedValue();
121 * ListSource.Name = "ListSource";
122 * ListSource.Value = new String[] {
123 * "OListBoxModel1", "OListBoxModel2", "OListBoxModel3"};
124 * super.m_propertiesToSet.add(ListSource);
125 * super.m_LCShape_Type = "FixedText";
126 * </pre>
127 * Then <CODE>super.initialize()</CODE> was called.
128 * @param tParam the test parameter
129 * @param log the log writer
131 @Override
132 protected void initialize(TestParameters tParam, PrintWriter log) {
134 super.initialize(tParam, log);
136 super.m_ChangePropertyName = "SelectedItems";
138 super.m_kindOfControl="ListBox";
140 super.m_ObjectName = "stardiv.one.form.component.ListBox";
142 NamedValue DataField = new NamedValue();
143 DataField.Name = "DataField";
144 DataField.Value = DBTools.TST_STRING_F;
145 super.m_propertiesToSet.add(DataField);
147 NamedValue ListSource = new NamedValue();
148 ListSource.Name = "ListSource";
149 ListSource.Value = new String[] {
150 "OListBoxModel1", "OListBoxModel2", "OListBoxModel3"};
151 super.m_propertiesToSet.add(ListSource);
153 super.m_LCShape_Type = "FixedText";
158 * calls <CODE>createTestEnvironment()</CODE> from it's super class
159 * This test uses not the generic implementaion of <CODE>cecker()</CODE> of its
160 * super class. This tests uses its own implementation of <CODE>checker()</CODE>
161 * to test <CODE>com::sun::star::form::XUpdateBroadcaster</CODE>
162 * @param Param the test parameter
163 * @param log the log writer
164 * @return lib.TestEnvironment
166 @Override
167 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
168 PrintWriter log) {
169 TestEnvironment tEnv = super.createTestEnvironment(Param, log);
171 tEnv.addObjRelation("XUpdateBroadcaster.Checker",
172 new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName));
173 return tEnv;
176 private static class Checker implements UpdateChecker {
177 private short lastItem = (short) 0;
178 private XLoadable formLoaderF = null;
179 private XPropertySet ps = null;
180 private XInterface ctrl = null;
181 private String ChangePropertyName = null;
183 public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName) {
184 formLoaderF = xl;
185 this.ps = ps;
186 this.ctrl = ctrl;
187 this.ChangePropertyName=ChangePropertyName;
190 public void update() throws Exception {
191 if (!formLoaderF.isLoaded()) {
192 formLoaderF.load();
194 lastItem = (short) (1 - lastItem);
195 ps.setPropertyValue(ChangePropertyName, new short[] { lastItem });
198 public void commit() throws SQLException {
199 XBoundComponent bound = UnoRuntime.queryInterface(
200 XBoundComponent.class, ctrl);
201 XResultSetUpdate update = UnoRuntime.queryInterface(
202 XResultSetUpdate.class,
203 formLoaderF);
205 bound.commit();
206 update.updateRow();
209 public boolean wasCommited() throws Exception {
210 formLoaderF.reload();
212 short[] getS = (short[]) ps.getPropertyValue(ChangePropertyName);
214 return (getS.length > 0) && (lastItem == getS[0]);
218 } // finish class OListBoxModel