1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 ' Copyright 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
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.
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).
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.
26 '/************************************************************************
28 '* owner : marc.neumann@oracle.com
30 '* short description : Helper Routines for Base tests.
32 '***************************************************************************************
35 ' #1 fOpenNewQueryDesign
36 ' #1 fStartQueryWizard
37 ' #1 fCloseQueryDesign
39 '\***********************************************************************************
40 '-------------------------------------------------------------------------
41 function fFindQueryInBeamer(sDSName1,sQueryName1)
42 '/// select a query with the given name in the beamer
43 '/// <u>parameter:</u>
44 '/// <b>sDSName1:</b> the name of the datasource
45 '/// <b>sQueryName1:</b> the name of the query
48 dim bfindQuery as boolean
50 dim iNoQuery as integer
53 Kontext "DatabaseBeamer"
54 Kontext "DatabaseSelection"
56 iNoDS = DatabaseSelection.getItemCount
58 DatabaseSelection.Select i
59 if DatabaseSelection.getText = sDSName1 then
65 DatabaseSelection.TypeKeys "<ADD>" , true
67 DatabaseSelection.TypeKeys "<DOWN>" , true
69 DatabaseSelection.TypeKeys "<DOWN>" , true
71 DatabaseSelection.TypeKeys "<ADD>" , true
73 DatabaseSelection.TypeKeys "<DOWN>" , true
77 iNoQuery = DatabaseSelection.getItemCount
79 ii = DatabaseSelection.GetSelIndex
80 for i = ii to iNoQuery
81 DatabaseSelection.Select i
82 if DatabaseSelection.getText = sQueryName1 then
89 fFindQuery = bfindQuery
92 '--------------------------------------------------------------------
93 function fOpenNewQueryDesign() as boolean
94 '/// open a new query design
95 '/// <u>parameter:</u>
98 Database.MouseDown(50,50)
99 Database.MouseUp(50,50)
101 if ( Database.NotExists(3) ) then
102 fOpenNewQueryDesign = false
103 warnlog "The database windows doesn't exists"
109 printlog "open new query design"
113 fOpenNewQueryDesign = true
116 '--------------------------------------------------------------------
117 function fOpenNewSQLQueryDesign() as boolean
118 '/// open a new query design in SQL mode
119 '/// <u>parameter:</u>
122 Database.MouseDown(50,50)
123 Database.MouseUp(50,50)
125 if ( Database.NotExists(3) ) then
126 fOpenNewSQLQueryDesign = false
127 warnlog "The database windows doesn't exists"
133 printlog "open new sql query design"
137 fOpenNewSQLQueryDesign = true
140 '-------------------------------------------------------------------------
141 function fStartQueryWizard()
142 '/// start the query wizard
143 '/// <u>parameter:</u>
146 if ( Database.NotExists(3) ) then
147 fStartQueryWizard = false
151 Database.MouseDown(50,50)
152 Database.MouseUp(50,50)
161 fStartQueryWizard = true
164 '-------------------------------------------------------------------------
165 function fCloseQueryDesign(optional bSave)
166 '/// close the query design
167 '/// <u>parameter:</u>
168 '/// <b><i>optional</i>bSave:</b> if true the query is saved if false then the changes are lost
172 Kontext "QueryDesignTable"
173 QueryDesignTable.UseMenu
174 ' bug file / close close the whole database
175 'hMenuSelectNr(1) ' the file menu
176 'hMenuSelectNr(4) ' the Close Window
178 hMenuSelectNr(6) ' the window menu
179 hMenuSelectNr(1) ' the Close Window
182 if Messagebox.Exists(3) then
183 if ( IsMissing( bSave ) ) then
197 '-------------------------------------------------------------------------
198 function fOpenQueryInSQLDesign(sQueryName as String)
199 '/// open a query in sql design
200 '/// <u>parameter:</u>
201 '/// <b>bQueryName:</b> the name of the query which should be open
203 if ( fFindQuery(sQueryName) = true ) then
204 printlog "Query " + sQueryName + " found -> open in sql design"
213 fOpenQueryInSQLDesign= true
215 fOpenQueryInSQLDesign = false
221 '-------------------------------------------------------------------------
222 function fCloseSQLQueryDesign(optional bSave)
223 '/// close the query design
224 '/// <u>parameter:</u>
225 '/// <b><i>optional</i>bSave:</b> if true the query is saved if false then the changes are lost
229 Kontext "QueryEditWindow"
230 QueryEditWindow.UseMenu
231 ' bug file / close close the whole database
232 'hMenuSelectNr(1) ' the file menu
233 'hMenuSelectNr(4) ' the Close Window
235 hMenuSelectNr(6) ' the window menu
236 hMenuSelectNr(1) ' the Close Window
239 if Messagebox.Exists(3) then
240 if ( IsMissing( bSave ) ) then
254 '-------------------------------------------------------------------------
255 function fSaveQueryDesign(sName as String)
256 '/// save an open Query Design
257 '/// <u>parameter:</u> the name of query
260 Kontext "QueryDesignTable"
261 QueryDesignTable.UseMenu
263 hMenuSelectNr(1) ' the file menu
264 hMenuSelectNr(6) ' the save
266 Kontext "DatabaseTableSaveAs"
267 TableName.setText(sName)
268 DatabaseTableSaveAs.OK
272 fSaveQueryDesign = true
275 '-------------------------------------------------------------------------
276 function fSaveSQLQueryDesign(sName as String)
277 '/// save an open SQL Query Design
278 '/// <u>parameter:</u> the name of query
281 Kontext "QueryEditWindow"
282 QueryEditWindow.UseMenu
284 hMenuSelectNr(1) ' the file menu
285 hMenuSelectNr(6) ' the save
287 Kontext "DatabaseTableSaveAs"
288 TableName.setText(sName)
289 DatabaseTableSaveAs.OK
293 fSaveSQLQueryDesign = true
297 '-------------------------------------------------------------------------
298 function fChooseTableInAddTableDialog(sTableName as string) as boolean
300 if ( not AddTables.exists(1) ) then
301 fChooseTableInQueryAddTableDialog = false
305 'TODO: add a test to click on the execute button, before the add table dialog is closed.
308 ix = TableName.getItemCount
311 TableName.TypeKeys "<ADD>"
312 'printlog "ix = " + ix
313 'printlog "TableName.getItemCount = " + TableName.getItemCount
314 if TableName.getItemCount > ix then
315 ix = TableName.getItemCount
316 'printlog "TableName.getItemCount > ix"
318 'printlog "TableName.getSeltext = " + TableName.getSeltext
319 if TableName.getSeltext = sTableName then
323 if TableName.getSeltext <> sTableName then
324 warnlog "Can find the table " + sTableName + "." + _
325 "Make sure that the table exists when starting this test."
329 if Messagebox.Exists(3) then
330 if Messagebox.getRT = 304 then
337 printlog "- Add " + sTableName +" table to query design"
338 '/// Add database table to Query.
341 if AddTables.exists(2) then
342 CloseDlg.Click ' When the AddTables dialog still exists then close him
345 fChooseTableInAddTableDialog = true
348 '--------------------------------------------------------------------
349 function fOpenQuery(sQueryName as string)
350 '/// open the query with the given name
351 '/// <u>parameter:</u>
352 '/// <b>squeryName:</b> the query which shall be opened
353 if ( fFindQuery(sQueryName) = true ) then
354 printlog "Query " + sQueryName + " found -> open"
355 Kontext "ContainerView"
356 OpenTable ' uno-Slot .uno:DB/Open
364 '--------------------------------------------------------------------
365 function fFindQuery(sQueryName as string)
366 '/// select the Query with the given name in the Query container
367 '/// <u>parameter:</u>
368 '/// <b>sQueryName:</b> the Query which shall be selected
370 Dim iNumbersOfQuerys as integer
373 Kontext "ContainerView"
379 if ( Not QueriesTree.exists(1) ) then
380 qaerrorlog "The Query tree doesn't exists"
381 ' May be a messagebox appear click OK to close it
383 if MessageBox.exists(1) then
384 qaerrorlog MessageBox.getText()
385 while MessageBox.exists() ' sometimes there are more then 1 message boxe
392 iNumbersOfQuerys = QueriesTree.getItemCount()
394 ' this select the first entry
395 QueriesTree.TypeKeys "<HOME>"
396 QueriesTree.TypeKeys "<UP>"
399 for i = 1 to iNumbersOfQuerys
401 QueriesTree.TypeKeys "<ADD>"
403 'printlog "QueryName.getItemCount = " + QueriesTree.getItemCount
404 if QueriesTree.getItemCount > iNumbersOfQuerys then
405 iNumbersOfQuerys = QueriesTree.getItemCount()
407 'printlog "QueryName.getSeltext = " + QueriesTree.getSeltext
408 if QueriesTree.getSeltext = sQueryName then
412 QueriesTree.TypeKeys "<DOWN>"
417 '-------------------------------------------------------------------------
418 function fCloseQueryView()
419 '/// close an open Query view
420 '/// <u>parameter:</u>
426 ' bug file / close close the whole database
427 'hMenuSelectNr(1) ' the file menu
428 'hMenuSelectNr(4) ' the Close Window
430 hMenuSelectNr(5) ' the window menu
431 hMenuSelectNr(1) ' the Close Window
432 ' if messages box appear because of unsaved record click no in the dialog
434 if Messagebox.Exists(3) then
438 fCloseQueryView = true