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