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 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: Query.inc,v $
13 '* last change: $Author: obo $ $Date: 2008-07-22 12:34:44 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* owner : marc.neumann@sun.com
36 '* short description : test the Main Query Application Window
38 '************************************************************************
56 '\***********************************************************************************
59 printlog "------------------ Query.inc ---------------------"
61 printlog "-------------------- main menu -------------------------"
64 printlog "--------------------- toolbar --------------------------"
81 '-------------------------------------------------------------------------
84 dim sTableName as String
89 if not AddTables.Exists(5) then
90 warnlog "The Add Table dialog doesn't appear."
93 sTableName = TableName.GetSelText
94 printlog "- Add 'biblio' table to query design"
95 if sTableName <> "biblio" then
96 warnlog "It should be the 'biblio'-database table but it is the '" + sTableName + "' database table?!"
103 printlog "- Deleting query"
107 if ClearQuery.IsEnabled = TRUE then
108 warnlog "'Delete Query' button should be disabled after using it!"
111 call fCloseQueryDesign
115 '-------------------------------------------------------------------------
118 dim sTableName as String
123 '/// close the add table dialog
124 printlog "close the add table dialog"
125 if AddTables.Exists(5) then
128 '/// switch to the SQL View and turn on the native SQL mode
129 printlog "switch to the SQL View and turn on the native SQL mode"
134 Kontext "Sqlobjectbar"
136 '/// check if the design view icon is disabled
138 if DesignView.isEnabled then
139 warnlog "The designview icon is enabled, but in Native SQL it mustn't"
143 Kontext "Sqlobjectbar"
149 call fCloseQueryDesign
153 '-------------------------------------------------------------------------
154 testcase tSwitchDesign
156 dim sTableName as String
161 if AddTables.Exists(5) then
162 sTableName = TableName.GetSelText
163 printlog "- Add 'biblio' table to query design"
164 if sTableName <> "biblio" then
165 warnlog "It should be the 'biblio'-database table but it is the '" & SelEntry & "' database table?!"
172 printlog "- Design view clicked"
175 Kontext "QueryEditWindow"
176 if QueryEditWindow.IsVisible = FALSE then
177 warnlog "The design window has not been disabled by clicking 'Design view' button!"
180 printlog "- Design view cliecked to switch back"
182 Kontext "QueryDesignTable"
183 if QueryDesignTable.IsVisible = FALSE then
184 warnlog "Switching back to 'design view' failed!"
189 call fCloseQueryDesign
193 '-------------------------------------------------------------------------
199 if AddTables.Exists(5) then
203 warnlog "AddTables doesn't exists"
206 Kontext "QueryDesignCriterion"
207 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
209 QueryDesignCriterion.TypeKeys "Type" , true
211 QueryDesignCriterion.TypeKeys "<DOWN>" , 6 , true
213 QueryDesignCriterion.TypeKeys "test" , true
215 QueryDesignCriterion.TypeKeys "<DOWN>" , true
217 '/// turn off the table name field
218 printlog "turn off the table name field"
219 Kontext "Designobjectbar"
220 if Designobjectbar.exists(1) then
221 DBViewTableNames.Click
224 warnlog "The Designobjectbar toolbar isn't visible."
226 '/// check if the table field still there
227 printlog "check if the table field still there"
229 Kontext "QueryDesignCriterion"
230 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
232 QueryDesignCriterion.TypeKeys "<DOWN>" , 6 , true
234 QueryDesignCriterion.TypeKeys "<HOME>" , true
236 QueryDesignCriterion.TypeKeys "<SHIFT END>" , true
238 QueryDesignCriterion.TypeKeys "<MOD1 C>" , true
240 if getClipboard = "'test'" then
241 warnlog "TableName still there but I have switch them off"
244 call fCloseQueryDesign
248 '-------------------------------------------------------------------------
249 '-------------------------------------------------------------------------
252 dim sTableName as String
257 if AddTables.Exists(5) then
258 '/// Adding biblio table to query design.
259 printlog "Adding biblio table to query design."
260 sTableName = TableName.GetSelText
261 printlog "- Add 'biblio' table to query design"
262 if sTableName <> "biblio" then
263 warnlog "It should be the 'biblio'-database table but it is the '" + sTableName + "' database table?!"
270 Kontext "QueryDesignTable"
271 printlog "- Changing window"
272 '/// Switching with <b><F6></b> to <i>criterion</i> window (<a href="http://so-web4.germany.sun.com/eis/servlet/qa.FeatureEditServlet?Id=1168">feature 1168</a>) .
273 QueryDesignTable.TypeKeys "<F6>" , TRUE
274 Kontext "QueryDesignCriterion"
275 printlog "- Selecting 'field' as criteria"
276 '/// Selecting field as criteria.
280 '/// Typing <b><TAB></b> to switch to the <i>tool bar</i>.
281 QueryDesignCriterion.TypeKeys "<TAB>" , TRUE
284 printlog "- Executing query"
285 '/// Ececuting query.
289 '/// Verifying that <i>database beamer</i> (=result) is available.
290 if NOT TableView.Exists(3) then
291 warnlog "Execution of a query failed!"
294 call fCloseQueryDesign
298 '-------------------------------------------------------------------------
301 dim sTableName as String
305 '/// close the add table dialog
306 printlog "close the add table dialog"
308 if AddTables.Exists(5) then
311 '/// click on the add table icon in the toolbar of the query design
312 printlog "click on the add table icon in the toolbar of the query design"
313 Kontext "Designobjectbar"
315 if Designobjectbar.exists(1) then
319 warnlog "The Designobjectbar toolbar isn't visible."
321 '/// check if the dialog opens
322 printlog "check if the dialog opens"
324 if AddTables.Exists(5) then
327 warnlog "The AddTable dialog doesn't open"
330 call fCloseQueryDesign
334 '-------------------------------------------------------------------------
340 if AddTables.Exists(5) then
345 Kontext "QueryDesignCriterion"
346 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
348 QueryDesignCriterion.TypeKeys "Type" , true
350 QueryDesignCriterion.TypeKeys "<DOWN>" , 6 , true
352 QueryDesignCriterion.TypeKeys "test" , true
354 QueryDesignCriterion.TypeKeys "<DOWN>" , true
356 '/// turn off the function field
357 printlog "turn off the function field"
358 Kontext "Designobjectbar"
359 if Designobjectbar.exists(1) then
360 DBViewFunctions.Click
363 warnlog "The Designobjectbar toolbar isn't visible."
367 '/// check if the function field still there
368 printlog "check if the function field still there"
370 Kontext "QueryDesignCriterion"
371 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
373 QueryDesignCriterion.TypeKeys "<DOWN>" , 6 , true
375 QueryDesignCriterion.TypeKeys "<HOME>" , true
377 QueryDesignCriterion.TypeKeys "<SHIFT END>" , true
379 QueryDesignCriterion.TypeKeys "<MOD1 C>" , true
381 if getClipboard = "'test'" then
382 warnlog "Functions still there but I have switch them off"
385 call fCloseQueryDesign
389 '-------------------------------------------------------------------------
395 if AddTables.Exists(5) then
398 '/// insert any aliasname into the alias field
399 printlog "insert any aliasname into the alias field"
401 Kontext "QueryDesignCriterion"
402 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
404 QueryDesignCriterion.TypeKeys "<DOWN>" , true
406 QueryDesignCriterion.TypeKeys "test" , true
408 '/// turn off the alias field
409 printlog "turn off the alias field"
410 Kontext "Designobjectbar"
411 if Designobjectbar.exists(1) then
415 warnlog "The Designobjectbar toolbar isn't visible."
418 '/// check if the alias field still there
419 printlog "check if the alias field still there"
421 Kontext "QueryDesignCriterion"
422 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
424 QueryDesignCriterion.TypeKeys "<DOWN>" , true
426 QueryDesignCriterion.TypeKeys "<HOME>" , true
428 QueryDesignCriterion.TypeKeys "<SHIFT END>" , true
430 QueryDesignCriterion.TypeKeys "<MOD1 C>" , true
432 if getClipboard = "test" then
433 warnlog "Alias still there but I have switch them off"
436 call fCloseQueryDesign
439 '-------------------------------------------------------------------------
440 testcase tDistinctValues
445 if AddTables.Exists(5) then
448 '/// turn on the distinct vales
449 printlog "turn on the distinct vales"
450 Kontext "Designobjectbar"
452 if Designobjectbar.exists(1) then
453 DBDistinctValues.Click
455 DBDistinctValues.Click
458 warnlog "The Designobjectbar toolbar isn't visible."
460 call fCloseQueryDesign
464 '-------------------------------------------------------------------------
470 if AddTables.Exists(5) then
473 '/// turn off the edit mode
474 printlog "turn off the edit mode"
479 Kontext "Designobjectbar"
480 if Designobjectbar.exists(1) then
481 if DBDistinctValues.isEnabled then warnlog "DistincValues icon is enable, but when Edit is turn off, it mustn't."
482 if AddTables.isEnabled then warnlog "AddTables icon is enable, but when Edit is turn off, it mustn't."
484 warnlog "The Designobjectbar toolbar isn't visible."
488 if ClearQuery.isEnabled then warnlog "ClearQuery icon is enable, but when Edit is turn off, it mustn't."
490 call fCloseQueryDesign
494 '-------------------------------------------------------------------------
499 '/// add any table ans select any field
500 printlog "add any table ans select any field"
502 if AddTables.Exists(5) then
508 if Cut.isenabled then warnlog "The cut icon is enabled but it is nothing selected."
509 '/// select the fieldname and check if the cut button works
510 printlog "select the fieldname and check if the cut button works"
512 Kontext "QueryDesignCriterion"
513 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
515 QueryDesignCriterion.TypeKeys "Type" , true
517 QueryDesignCriterion.TypeKeys "<DOWN>" , true
519 QueryDesignCriterion.TypeKeys "<UP>" , true
521 QueryDesignCriterion.TypeKeys "<SHIFT END>" , true
525 if Cut.isenabled then
528 warnlog "The Cut icon is not enabled but I have select something"
531 if Messagebox.Exists(3) then
534 warnlog "There should be a message box because the query has been changed!"
542 '/// check if the text is in the clipboard
543 printlog "check if the text is in the clipboard"
544 if getClipboard <> "Type" then
545 warnlog "The Cut button doesn't work"
548 call fCloseQueryDesign
552 '-------------------------------------------------------------------------
557 '/// add any table ans select any field
558 printlog "add any table ans select any field"
560 if AddTables.Exists(5) then
566 if Copy.isenabled then warnlog "The copy icon is enabled but it is nothing selected.Bug 107845"
567 '/// select the fieldname and check if the copy button works
568 printlog "select the fieldname and check if the copy button works"
570 Kontext "QueryDesignCriterion"
571 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
573 QueryDesignCriterion.TypeKeys "Type" , true
575 QueryDesignCriterion.TypeKeys "<DOWN>" , true
577 QueryDesignCriterion.TypeKeys "<UP>" , true
579 QueryDesignCriterion.TypeKeys "<SHIFT END>" , true
583 if Copy.isenabled then
586 warnlog "The Copy icon is not enabled but I have select something"
589 if Messagebox.Exists(3) then
592 warnlog "There should be a message box because the query has been changed!"
600 '/// check if the text is in the clipboard
601 printlog "check if the text is in the clipboard"
602 if getClipboard <> "Type" then
603 warnlog "The Cut button doesn't work"
606 call fCloseQueryDesign
610 '-------------------------------------------------------------------------
615 '/// add any table and select any field
616 printlog "add any table and select any field"
618 if AddTables.Exists(5) then
622 warnlog "The AddTable dialog doesn't appear."
623 printlog "TEST STOPPED"
624 call fCloseQueryDesign
628 '/// select the fieldname and check if the paste button works
629 printlog "select the fieldname and check if the paste button works"
631 Kontext "QueryDesignCriterion"
632 QueryDesignCriterion.TypeKeys "<MOD1 PAGEUP>" , true
634 QueryDesignCriterion.TypeKeys "Type" , true
636 QueryDesignCriterion.TypeKeys "<DOWN>" , true
638 QueryDesignCriterion.TypeKeys "<UP>" , true
640 QueryDesignCriterion.TypeKeys "<SHIFT END>" , true
644 if Copy.isenabled then
647 warnlog "The Copy icon is not enabled but I have select something"
648 printlog "TEST STOPPED"
649 call fCloseQueryDesign
655 '/// check if the text is in the clipboard
656 printlog "check if the text is in the clipboard"
657 if getClipboard <> "Type" then
658 warnlog "The Copy button doesn't work"
659 printlog "TEST STOPPED"
660 call fCloseQueryDesign
665 Kontext "QueryDesignCriterion"
666 QueryDesignCriterion.TypeKeys "<RIGHT>" , 2 , true
670 if Paste.isenabled then
673 warnlog "The Paste icon is not enabled but I have copy something"
674 printlog "TEST STOPPED"
675 call fCloseQueryDesign
680 Kontext "QueryDesignCriterion"
681 QueryDesignCriterion.TypeKeys "1" , true
683 QueryDesignCriterion.TypeKeys "<HOME>" , true
685 QueryDesignCriterion.TypeKeys "<SHIFT END>" , true
687 QueryDesignCriterion.TypeKeys "<MOD1 C>" , true
690 if getClipboard <> "Type1" then
691 warnlog "The Paste button doesn't work"
694 call fCloseQueryDesign
699 '-------------------------------------------------------------------------
704 '/// close the add table dialog
705 printlog "close the add table dialog"
707 if AddTables.Exists(5) then
710 '/// click on the add table icon in the toolbar of the query design
711 printlog "click on the add table icon in the toolbar of the query design"
714 if Undo.isenabled then warnlog "The undo icon is enabled but I have nothing done"
716 '/// check if the dialog opens
717 printlog "check if the dialog opens"
718 Kontext "Designobjectbar"
719 if Designobjectbar.exists(1) then
723 warnlog "The Designobjectbar toolbar isn't visible."
726 if AddTables.Exists(5) then
730 warnlog "The AddTable dialog doesn't open"
733 if Undo.isenabled then
735 Kontext "Designobjectbar"
736 if Designobjectbar.exists(1) then
737 if not AddTables.isenabled then warnlog "The undo button doesn't work"
740 warnlog "The Designobjectbar toolbar isn't visible."
743 warnlog "The undo icon is disabled but I have insert a table"
746 call fCloseQueryDesign
750 '-------------------------------------------------------------------------
755 '/// close the add table dialog
756 printlog "close the add table dialog"
758 if AddTables.Exists(5) then
760 printlog "The AddTables dialog exists, I close it."
762 printlog "The AddTables dialog doesn't exists, thats OK."
764 '/// click on the add table icon in the toolbar of the query design
765 printlog "click on the add table icon in the toolbar of the query design"
768 if Redo.isenabled then warnlog "The redo icon is enabled but I have nothing done"
769 '/// check if the dialog opens
770 printlog "check if the dialog opens"
775 if AddTables.Exists(5) then
779 warnlog "The AddTable dialog doesn't open"
782 if Undo.isenabled then
787 if AddTables.isenabled then warnlog "The redo button doesn't work"
789 warnlog "The undo icon is disabled but I have insert a table"
794 call fCloseQueryDesign
798 '-------------------------------------------------------------------------
799 '-------------------------------------------------------------------------
800 testcase tMainMenuBar
802 dim iCount as integer ' the numbers of the items in the menu.
805 '/// close the add table dialog
806 printlog "close the add table dialog"
808 if AddTables.Exists(5) then
810 printlog "The AddTables dialog exists, I close it."
813 Kontext "QueryDesignTable"
814 QueryDesignTable.UseMenu
816 '/// check if there are between 8 and 12 items in the file menu.
817 printlog "check if there are between 8 and 12 items in the file menu."
818 '/// + there different count related to the file pick list.
819 printlog "+ there different count related to the file pick list."
820 hMenuSelectNr(1) ' the file menu
821 iCount = getMenuItemCount()
822 if ( lcase( gPlatform ) = "osx" ) then
823 if ( iCount <> 7 ) then
824 warnlog( "File menu: 7 items expected, found " & iCount )
827 if (iCount <> 8 ) then
828 warnlog "There should between 8 and 12 items in the file menu but there are " + iCount + " items."
832 '/// check if there are 12 items in the FILE/NEW menu.
833 printlog "check if there are 12 items in the FILE/NEW menu."
834 hMenuSelectNr(1) ' FILE/NEW menu
835 iCount = hMenuItemGetCount()
836 if (iCount <> 12) then
837 warnlog "There should 12 items in the FILE/NEW menu but there are " + iCount + " items."
839 call hMenuClose() ' close the FILE menu
841 '/// check the FILE/AUTOPILOTS
842 printlog "check the FILE/AUTOPILOTS"
843 QueryDesignTable.UseMenu
844 hMenuSelectNr(1) ' the file menu
845 hMenuSelectNr(3) ' the autopilots menu
846 iCount = hMenuItemGetCount()
847 if (iCount <> 8) then
848 warnlog "There should 8 items in the FILE/AUTOPILOTS menu but there are " + iCount + " items."
852 '/// check if there are 9 items in the edit menu.
853 printlog "check if there are 9 items in the edit menu."
854 QueryDesignTable.UseMenu
856 iCount = hMenuItemGetCount()
857 if (iCount <> 9) then
858 warnlog "There should 9 items in the edit menu but there are " + iCount + " items."
862 '/// check if there are 7 items in the view menu.
863 printlog "check if there are 7 items in the view menu."
864 QueryDesignTable.UseMenu
866 iCount = hMenuItemGetCount()
867 if (iCount <> 7) then
868 warnlog "There should 7 items in the view menu but there are " + iCount + " items."
872 '/// check if there are 2 items in the insert menu.
873 printlog "check if there are 2 items in the insert menu."
874 QueryDesignTable.UseMenu
876 iCount = hMenuItemGetCount()
877 if (iCount <> 2) then
878 warnlog "There should 2 items in the insert menu but there are " + iCount + " items."
882 '/// check if there are 4 items in the tools menu.
883 printlog "check if there are 4 items in the tools menu."
884 QueryDesignTable.UseMenu
886 iCount = hMenuItemGetCount()
887 if ( lcase( gPlatform ) = "osx" ) then
888 if ( iCount <> 3 ) then
889 warnlog( "Tools menu: 3 items expected, found " & iCount )
892 if (iCount <> 4) then
893 warnlog "There should 4 items in the tools menu but there are " + iCount + " items."
898 '/// check if there are 4 items in the TOOLS/MACRO menu.
899 printlog "check if there are 4 items in the TOOLS/MACRO menu."
900 QueryDesignTable.UseMenu
903 iCount = hMenuItemGetCount()
904 if (iCount <> 4) then
905 warnlog "There should 4 items in the TOOLS/MACRO menu but there are " + iCount + " items."
909 call fCloseQueryDesign
913 '-------------------------------------------------------------------------
914 '-------------------------------------------------------------------------
915 '-------------------------------------------------------------------------
916 function getMenuItemCount as Integer
917 'use this function becasue this doesn't count the pick list
918 Dim i, j, Ende, nID as Integer
921 for i=1 to MenuGetItemCount
922 if NOT MenuIsSeperator ( i ) then
924 s = Mid(MenuGetItemText( MenuGetItemID(i)),3,1)
926 'printlog "MenuGetItemText( MenuGetItemID(i)) = " + MenuGetItemText( MenuGetItemID(i))
934 '-------------------------------------------------------------------------
937 hFileOpen( gOfficePath & "user/database/biblio.odb" )
941 Insight.MouseDown(50,50)
942 Insight.MouseUp(50,50)
948 ' if not InsightSwapIconView.exists(1) then
949 ' warnlog "InsightSwapIconView doesn't exists"
953 ' '/// display Queries View
954 ' printlog "display Queries View"
956 ' if InsightQueriesView.exists(1) then
957 ' printlog "InsightQueriesView appear"
959 ' warnlog "InsightQueriesView doesn't appear"
964 ' CreationList.select(1)
966 ' Insight.TypeKeys "<TAB>" , true
967 ' Insight.TypeKeys "<RETURN>" , true