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: tools_customize.inc,v $
13 '* last change: $Author: jsk $ $Date: 2008-06-20 08:03:53 $
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 : joerg.skottke@sun.com
36 '* short description : Update Test for the Tools Customize Dialog
38 '\******************************************************************************
40 testcase tUpdtCustomize( cApp as string )
42 printlog( "Tools/Customize dialog" )
43 const CLOSE_METHOD = 1 ' 1 = Cancel button
45 if ( hCreateDocument() ) then
46 if ( hToolsCustomizeOpen() ) then
47 hUpdtToolsCustomizeKeyboard()
48 hUpdtToolsCustomizeMenu()
49 hUpdtToolsCustomizeToolbars()
50 hUpdtToolsCustomizeEvents()
51 hToolsCustomizeClose( CLOSE_METHOD )
53 warnlog( "Tools/Customize dialog did not open" )
57 warnlog( "Failed to create initial document" )
62 '*******************************************************************************
64 function hUpdtToolsCustomizeMenu()
66 '///<h3>Update test for the Tools/Customize - Menu-Tab</h3>
67 '///<i>Starting point: Tools/Customize dialog</i><br>
77 '///<u>Description</u>:
80 const CFN = "hUpdtToolsCustomizeMenu::"
81 const ITEMNAME = "tUpdtCustomize"
85 dim iCurrentItem as integer
86 dim iMenuListItems as integer
87 dim iEntriesListItems as integer
92 '///+<li>Access the Menu-Tabpage</li>
93 brc = hToolsCustomizeSelectTab( "Menu" )
94 call DialogTest( TabCustomizeMenu )
96 '///+<li>Click "New..." to add a new menu</li>
97 printlog( CFN & "Click New..." )
98 kontext "TabCustomizeMenu"
101 '///+<li>Have a look at the MenuOrganiser, close it</li>
102 Kontext "MenuOrganiser"
103 printlog( CFN & "MenuOrganiser" )
104 call DialogTest( MenuOrganiser )
106 '///+<li>Click "Down"</li>
107 printlog( CFN & "Down..." )
110 '///+<li>Click "Up"</li>
111 printlog( CFN & "Up..." )
114 '///+<li>Enter a name for a new menu</li>
115 printlog( CFN & "Name the new menu" )
116 MenuName.setText( "tUpdtCustomize" )
118 'qaerrorlog( "#i60609# Undeclared listbox in menu organiser" )
119 printlog( "TODO: Access the listbox in menuorganizer" )
121 '///+<li>Close the dialog with OK</li>
122 printlog( CFN & "Close the menu with ok" )
125 '///+<li>Click the Menu List-Button</li>
126 printlog( CFN & "Click the menu listbutton" )
127 kontext "TabCustomizeMenu"
128 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
130 '///+<li>Select the first entry (Move...) to open the Menu Organiser</li>
131 printlog( CFN & "Select Move..." )
134 '///+<li>Click the UP button</li>
135 kontext "MenuOrganiser"
136 printlog( CFN & "Click UP" )
139 '///+<li>Click the DOWN button</li>
140 kontext "MenuOrganiser"
141 printlog( CFN & "Click DOWN" )
144 '///+<li>Cancel the dialog</li>
145 printlog( CFN & "Cancel the dialog" )
146 MenuOrganiser.cancel()
148 '///+<li>Click the Menu List-Button</li>
149 printlog( CFN & "Click the menu listbutton" )
150 kontext "TabCustomizeMenu"
151 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
153 '///+<li>Select the second entry (Rename...) to open the Rename dialog</li>
154 printlog( CFN & "Select Rename..." )
157 '///+<li>Cancel the renaming dialog</li>
158 printlog( CFN & "Cancel the renaming-dialog" )
162 '///+<li>Click the Menu List-Button</li>
163 printlog( CFN & "Click the menu listbutton" )
164 kontext "TabCustomizeMenu"
165 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
167 '///+<li>Select the third entry (Delete) to delete the new menu<br>
168 '///+Note that there will be no warning as the menu is empty</li>
169 printlog( CFN & "Select Delete" )
172 '///+<li>Click the "Add Commands..." button</li>
173 '///+<li>Check that the dialog is open, close it</li>
174 kontext "TabCustomizeMenu"
175 hUpdtToolsCustomizeScriptSelector( 3 )
177 '///+<li>Check the number of entries in SaveIn-Listbox<br>
178 printlog( CFN & "Check itemcount in SaveIn List" )
179 kontext "TabCustomizeMenu"
180 select case gApplication
181 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( 1 )
182 case else : brc = hToolsCustomizeTestSaveIn( 2 )
185 warnlog( "Incorrect itemcount in listbox, see above" )
188 '///+<li>Click "Down"</li>
189 printlog( CFN & "Down..." )
192 '///+<li>Click "Up"</li>
193 printlog( CFN & "Up..." )
196 '///+<li>Click the "Modify"-button and select the first entry (Add submenu...)</li>
197 printlog( CFN & "Click the Modify-Button and select item 1 (Add submenu)" )
198 kontext "TabCustomizeMenu"
199 brc = hClickCommandButton( 1 )
201 warnlog( CFN & "Something went wrong when accessing the command button" )
205 '///+<li>Enter a name for the submenu, accept with OK</li>
206 printlog( CFN & "Give the submenu a name, accept with OK" )
207 kontext "CustomizeMenuName"
208 call dialogtest( CustomizeMenuName )
209 EingabeFeld.setText( ITEMNAME )
210 CustomizeMenuName.ok()
212 '///+<li>Find the submenu in the Entries-list and select it</li>
213 printlog( CFN & "Find the new submenu in the list and select it" )
215 kontext "TabCustomizeMenu"
216 iEntriesListItems = Entries.getItemCount()
217 for iCurrentItem = 1 to iEntriesListItems
219 Entries.select( iCurrentItem )
220 if ( Entries.getSelText() = ITEMNAME ) then
227 '///+<li>Click the "Modify"-button and select the third entry (Rename...)</li>
228 printlog( CFN & "Click the Modify-Button and select to rename the item" )
229 kontext "TabCustomizeMenu"
230 brc = hClickCommandButton( 3 )
232 warnlog( CFN & "Something went wrong when accessing the command button" )
236 '///+<li>Rename the the submenu, accept with ok</li>
237 printlog( CFN & "Rename the item, accept with OK" )
238 kontext "CustomizeMenuReName"
239 call dialogtest( CustomizeMenuReName )
240 EingabeFeld.setText( ITEMNAME & "1" )
241 CustomizeMenuReName.ok()
243 '///+<li>Verify that the name has been updated</li>
244 printlog( CFN & "Verify that the name has been updated" )
245 kontext "TabCustomizeMenu"
246 if ( Entries.getSelText() <> ( ITEMNAME & "1" ) ) then
247 warnlog( "Names do not match" )
250 '///+<li>Click the "Modify"-button and select the fourth entry (Delete)</li>
251 printlog( CFN & "Click the Modify-Button and delete the current item" )
252 kontext "TabCustomizeMenu"
253 brc = hClickCommandButton( 4 )
255 warnlog( CFN & "Something went wrong when accessing the command button" )
259 '///+<li>Click the "Modify"-button and select the second entry (Begin a group)</li>
260 printlog( CFN & "Click the Modify-Button and create a new group" )
261 kontext "TabCustomizeMenu"
262 brc = hClickCommandButton( 2 )
264 warnlog( CFN & "Something went wrong when accessing the command button" )
268 '///+<li>Click the "Modify"-button and select the fourth entry (Delete)</li>
269 ' Note: The current index for the delete-function is at pos 2.
270 printlog( CFN & "Click the Modify-Button and delete the new group" )
271 kontext "TabCustomizeMenu"
272 brc = hClickCommandButton( 2 )
274 warnlog( CFN & "Something went wrong when accessing the command button" )
281 '*******************************************************************************
283 function hUpdtToolsCustomizeToolbars()
285 '///<h3>Update test for the Tools/Customize - Toolbar-Tab</h3>
286 '///<i>Starting point: Tools/Customize dialog</i><br>
288 '///<u>Input</u>:<br>
290 '///+<li>Nothing</li>
293 '///<u>Returns</u>:<br>
295 '///+<li>Nothing</li>
298 '///<u>Description</u>:<br>
301 const CFN = "hUpdtToolsCustomizeToolbars::"
304 dim iCurrentItem as integer
307 printlog( "Toolbars" )
309 '///+<li>Access the toolbar tabpage</li>
310 brc = hToolsCustomizeSelectTab( "Toolbars" )
311 call DialogTest( TabCustomizeToolbars )
313 '///+<li>Click "New..." to add a new toolbar</li>
314 printlog( CFN & "Click New..." )
315 kontext "TabCustomizeToolbars"
318 '///+<li>Have a look at the New Toolbar dialog, close it</li>
320 if ( NewToolbar.exists( 2 ) ) then
321 printlog( CFN & "NewToolbar" )
322 call DialogTest( NewToolbar )
324 '///+<li>Check that the SaveIn control has the correct number of items</li>
325 select case gApplication
326 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( 1 )
327 case else : brc = hToolsCustomizeTestSaveIn( 2 )
330 warnlog( "Incorrect itemcount in listbox, see above" )
333 '///+<li>Name the toolbar (required to test the menubutton later)</li>
334 printlog( CFN & "Name the new toolbar for further usage" )
335 ToolbarName.setText( "tUpdtCustomize" )
337 '///+<li>Close the dialog with OK</li>
338 printlog( CFN & "Close NewToolbar dialog with OK" )
341 warnlog( CFN & "Could not access New Toolbar dialog" )
344 '///+<li>Access the "Toolbar"-Button and rename the toolbar</li>
345 printlog( CFN & "Rename the toolbar via Toolbar-Button" )
346 kontext "TabCustomizeToolbars"
347 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
349 printlog( "Select rename" )
352 '///+<li>Cancel the renaming-dialog</li>
353 printlog( CFN & "Cancel the dialog" )
354 kontext "RenameToolbar"
355 if ( RenameToolbar.exists( 2 ) ) then
356 call dialogtest( RenameToolbar )
357 RenameToolbar.Cancel()
359 warnlog( CFN & "Could not access Toolbar renaming dialog" )
362 '///+<li>Access the "Toolbar"-Button and delete the toolbar<br>
363 '///+Note that there will be no deletion warning</li>
364 printlog( CFN & "Delete the toolbar via Toolbar-Button" )
365 kontext "TabCustomizeToolbars"
366 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
368 printlog( "Select delete" )
371 '///+<li>Click the "Add Commands..." button</li>
372 '///+<li>Check that the dialog is open, close it</li>
373 kontext "TabCustomizeToolbars"
374 hUpdtToolsCustomizeScriptSelector( 2 )
376 '///+<li>Check that the SaveIn control has two items</li>
377 kontext "TabCustomizeToolbars"
378 select case gApplication
379 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( 1 )
380 case else : brc = hToolsCustomizeTestSaveIn( 2 )
383 warnlog( "Incorrect itemcount in listbox, see above" )
386 '///+<li>Click "Down"</li>
387 printlog( CFN & "Down..." )
388 if ( BtnDown.isEnabled() ) then
391 qaerrorlog( "BtnDown is not enabled" )
394 '///+<li>Click "Up"</li>
395 printlog( CFN & "Up..." )
396 if ( BtnUp.isEnabled() ) then
399 qaerrorlog( "BtnUp is not enabled" )
402 kontext "TabCustomizeToolbars"
403 '///+<li>Add a new item (click "Add...")</li>
404 printlog( CFN & "Add command" )
407 '///+<li>Accept the default item from the script selector ("Add")</li>
408 kontext "ScriptSelector"
409 if ( ScriptSelector.exists( 5 ) ) then
411 call dialogtest( ScriptSelector )
413 ' This is a workaround that applies when - for some reason - the menu
414 ' (menubutton: AddCommands) is not open. In this case the ScriptSelector
415 ' will not open. Before this hack the office was left in an unstable state
416 ' and the following tests would have failed. Now we get a warning
419 printlog( CFN & "Add the default item" )
421 kontext "ScriptSelector"
424 qaerrorlog( "#i79207# Could not access ok button on ScriptSelector" )
425 kontext "ScriptSelector"
426 if ( ScriptSelector.exists( 2 ) ) then
427 printlog( "Scriptselector is open" )
433 LibraryTreeList.typeKeys( "<HOME>" )
434 for iCurrentItem = 1 to 5
435 printlog( CFN & "LibraryTreeList: Moving down..." )
436 LibraryTreeList.typeKeys( "<DOWN>" )
437 if ( ScriptSelector.isEnabled() ) then
443 ' Note: The Customize dialog in the background is updated immediately. This
444 ' means that the cancel-button is active but blocked for a moment
447 '///+<li>Close the Script Selector</li>
448 printlog( CFN & "Close the Script Selector, back to ToolsCustomize dialog" )
449 ScriptSelector.cancel()
451 ' make sure the dialog is really closed. At times it just refuses to do so??
452 if ( ScriptSelector.exists( 1 ) ) then
453 ScriptSelector.close()
456 '///+<li>Click the "Modify" button</li>
457 '///+<li>Select the first item (Rename)</li>
458 kontext "TabCustomizeToolbars"
459 printlog( CFN & "Click the Modify-button" )
460 brc = hClickCommandButton( 1 )
462 warnlog( CFN & "Something went wrong when accessing the command button" )
466 '///+<li>Rename the item</li>
467 printlog( CFN & "Rename the item" )
468 kontext "CustomizeToolbarsRename"
469 if ( CustomizeToolbarsRename.exists( 2 ) ) then
470 call dialogtest( CustomizeToolbarsRename )
471 EingabeFeld.setText( "Renamed item" )
473 '///+<li>Close the dialog (with OK)</li>
474 printlog( CFN & "Close the dialog" )
475 CustomizeToolbarsRename.ok()
477 warnlog( CFN & "CustomizeToolbarsRename could not be accessed" )
480 '///+<li>Click the "Modify" button</li>
481 '///+<li>Select the second item (Delete)</li>
482 kontext "TabCustomizeToolbars"
483 brc = hClickCommandButton( 2 )
485 warnlog( CFN & "Something went wrong when accessing the command button" )
489 '///+<li>Select the first Toolbar and click the "Modify" button</li>
490 '///+<li>Select the third item (Restore)</li>
491 kontext "TabCustomizeToolbars"
493 printlog( CFN & "Click the Modify-button" )
494 printlog( "******************** 1 ********************" )
496 printlog( "******************** 2 ********************" )
497 brc = hClickCommandButton( 3 )
499 warnlog( CFN & "Something went wrong when accessing the command button" )
503 '///+<li>Click the "Modify" button</li>
504 '///+<li>Select the fourth item (Begin a group)</li>
505 kontext "TabCustomizeToolbars"
507 printlog( CFN & "Click the Modify-button" )
508 brc = hClickCommandButton( 4 )
510 warnlog( CFN & "Something went wrong when accessing the command button" )
514 '///+<li>Click the "Modify" button</li>
515 '///+<li>Select the second item (Delete the group)</li>
516 kontext "TabCustomizeToolbars"
518 printlog( CFN & "Click the Modify-button" )
519 brc = hClickCommandButton( 1 )
521 warnlog( CFN & "Something went wrong when accessing the command button" )
525 '///+<li>Click the "Modify" button</li>
526 '///+<li>Select the fifth item (Change Icon) to open the Change-Icon dialog</li>
527 kontext "TabCustomizeToolbars"
529 printlog( CFN & "Click the Modify-button" )
530 printlog( "******************** 3 ********************" )
532 printlog( "******************** 4 ********************" )
533 brc = hClickCommandButton( 5 )
535 warnlog( CFN & "Something went wrong when accessing the command button" )
539 '///+<li>On the Change Icon dialog: Click to import an icon</li>
540 printlog( CFN & "On the Change Icon dialog: Click to import an icon" )
542 if ( ChangeIcon.exists( 2 ) ) then
543 call dialogtest( ChangeIcon )
546 '///+<li>Cancel the FileOpen-dialog</li>
547 printlog( CFN & "Cancel the FileOpen-dialog" )
549 call dialogtest( OeffnenDlg )
552 '///+<li>Close the Change Icon dialog</li>
553 printlog( CFN & "Cancel the Change Icon dialog" )
557 warnlog( CFN & "Could not access Change Icon dialog" )
560 '///+<li>Click the "Modify" button</li>
561 '///+<li>Select the third item (Restore)</li>
562 kontext "TabCustomizeToolbars"
564 printlog( CFN & "Click the Modify-button" )
565 brc = hClickCommandButton( 3 )
567 warnlog( CFN & "Something went wrong when accessing the command button" )
575 '*******************************************************************************
577 function hUpdtToolsCustomizeEvents()
579 '///<h3>Update test for the Tools/Customize - Events-Tab</h3>
580 '///<i>Starting point: Tools/Customize dialog</i><br>
582 '///<u>Input</u>:<br>
584 '///+<li>Nothing</li>
587 '///<u>Returns</u>:<br>
589 '///+<li>Nothing</li>
592 '///<u>Description</u>:<br>
595 const CFN = "hUpdtToolsCustomizeEvents::"
601 '///+<li>Access the events tabpage</li>
602 brc = hToolsCustomizeSelectTab( "events" )
603 call DialogTest( TabCustomizeEvents )
605 '///+<li>Click to assign a macro, close dialog with cancel</li>
606 hUpdtToolsCustomizeScriptSelector( 1 )
608 '///+<li>Check that the SaveIn control has two items</li>
609 kontext "TabCustomizeEvents"
610 select case gApplication
611 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( 1 )
612 case else : brc = hToolsCustomizeTestSaveIn( 2 )
615 warnlog( "Incorrect itemcount in listbox, see above" )
621 '*******************************************************************************
623 function hUpdtToolsCustomizeKeyboard() as boolean
625 '///<h3>Update test for the Tools/Customize - Keyboard-Tab</h3>
626 '///<i>Starting point: Tools/Customize dialog</i><br>
628 '///<u>Input</u>:<br>
630 '///+<li>Nothing</li>
633 '///<u>Returns</u>:<br>
635 '///+<li>Nothing</li>
638 '///<u>Description</u>:<br>
641 const CFN = "hUpdtToolsCustomizeKeyboard::"
645 printlog( "Keyboard" )
647 '///+<li>Access the keyboard tabpage</li>
648 brc = hToolsCustomizeSelectTab( "keyboard" )
649 if ( not brc and gApplication = "BACKGROUND" ) then
650 qaerrorlog( "#i61765# TabTastatur is missing when called from Backing Window" )
654 call DialogTest( TabTastatur )
656 '///+<li>Assign an item to *second* Entry in OpenOffice.org/Tastatur</li>
657 ' no verification of functionality, this is an update test!
659 hSelectNode( Tastatur , 2 )
660 hSelectTopNode( bereich )
663 ' Workaround: It might still happen that the currently selected accelerator
664 ' is "fixed" so we need to find another one that can be modified.
665 do while ( not Aendern.isEnabled() )
666 printlog( "Moving selection down by one, Control is not enabled" )
667 Tastatur.TypeKeys( "<DOWN>" )
674 Zuruecksetzen.click()
676 '///+<li>Assign an item to *second* Entry in OpenOffice.org/Tastatur</li>
677 hSelectNode( Tastatur , 2 )
680 ' Workaround: It might still happen that the currently selected accelerator
681 ' is "fixed" so we need to find another one that can be modified.
682 do while ( not Aendern.isEnabled() )
683 printlog( "Moving selection down by one, Control is not enabled" )
684 Tastatur.TypeKeys( "<DOWN>" )
692 '///+<li>Click Save</li>
695 '///+<li>Close FileSave dialog</li>
696 kontext "SpeichernDlg"
697 SpeichernDlg.cancel()
699 '///+<li>Click Load</li>
700 kontext "TabTastatur"
703 '///+<li>Close Fileopen dialog</li>
711 '*******************************************************************************
713 function hUpdtToolsCustomizeScriptSelector( iBtn as integer ) as boolean
715 '///<h3>A brief look at the ScriptSelector via Tools/Customize</h3>
716 '///<i>Starting point: Tools/Customize dialog (AddMacro/BtnNew)</i><br>
717 '///<i>Uses: t_treelist_tools.inc</i><br>
721 '///+<li>Button identifier (integer)</li>
723 '///+<li>1: Click TabCustomizeEvents::AssignMacro</li>
724 '///+<li>2: Click TabCustomizeToolbars::AddCommands</li>
725 '///+<li>3: Click TabMenu::AddCommands</li>
731 '///+<li>Errorstatus</li>
733 '///+<li>TRUE: All ok</li>
734 '///+<li>FALSE: Any other error</li>
738 '///<u>Description</u>:
741 const CFN = "hUpdtToolsCustomizeScriptSelector::"
746 '///+<li>Select the correct button and context to execute</li>
749 '///+<li>Toolbars</li>
752 '///+<li>Open the ScriptSelector</li>
754 case 1 : kontext "TabCustomizeEvents"
755 printlog( CFN & "Assign Macro... (1)" )
757 case 2 : kontext "TabCustomizeToolbars"
758 printlog( CFN & "Add... (2)" )
760 case 3 : kontext "TabCustomizeMenu"
761 printlog( CFN & "Add... (3)" )
764 warnlog( CFN & "Invalid function parameter" )
768 '///+<li>Test the dialog (DialogTest)</li>
770 kontext "ScriptSelector"
771 call DialogTest( ScriptSelector )
773 '///+<li>Cancel the ScriptSelector</li>
774 kontext "ScriptSelector"
775 ScriptSelector.cancel()
779 '///+<li>Reset the context to the originating page</li>
781 case 1 : kontext "TabCustomizeEvents"
782 case 2 : kontext "TabCustomizeToolbars"
783 case 3 : kontext "TabCustomizeMenu"
786 hUpdtToolsCustomizeScriptSelector() = brc
791 '*******************************************************************************
793 function hToolsCustomizeTestSaveIn( iItems as integer ) as boolean
795 '///<h3>Test number of entries in SaveIn Listbox (Tools/Customize)</h3>
798 '///+<li>Expected number of items (integer)</li>
803 '///+<li>Errorstate (boolean)</li>
805 '///+<li>TRUE: Correct number of items is present</li>
806 '///+<li>FALSE: incorrect number of items is present</li>
810 '///<u>Description</u>:
813 const CFN = "hToolsCustomizeTestSaveIn::"
814 dim iPresentItems as integer
816 '///+<li>Get the number of items from the listbox</li>
817 iPresentItems = SaveIn.getItemCount()
819 '///+<li>Compare the number to the expected itemcount</li>
820 if ( iPresentItems <> iItems ) then
821 printlog( CFN & "Incorrect itemcount in SaveIn: " )
822 printlog( CFN & "Expected: " & iItems )
823 printlog( CFN & "Found...: " & iPresentItems )
824 hToolsCustomizeTestSaveIn() = false
826 printlog( CFN & "Correct itemcount in SaveIn: " & iItems )
827 hToolsCustomizeTestSaveIn() = true
833 '*******************************************************************************
835 function hOpenMenuButton( oControl as object ) as integer
837 ' This function is very evil.
838 ' It was written to hopefully workaround the infamous menubutton which is a button
839 ' that - when clicked - opens a menu. This feature is shaky and depends on
840 ' a lot of factors. There is a simple working implemantation in t_menu.inc
841 ' which has the drawback of being absolutely slow, costing the tools_customize
842 ' test a lot of time waiting for the control (30% of testtime spent waiting).
843 ' This approach tries to be dynamic: Machines that can do it the fast way
844 ' use it automatically, machines that are too slow get two retries with the
846 ' The menubutton is one of the last remaining places where none of the
847 ' speed optmizations and enhancements apply, so neither WaitSlot() nor
848 ' synchronous slot execution help here.
850 dim iClick as integer
851 dim bUseSlowMethod as boolean : bUseSlowMethod = false
853 const CFN = "hOpenMenuButton: "
855 hOpenMenuButton() = -1 ' this is the general failure returnvalue
859 if ( bUseSlowMethod ) then
868 hOpenMenuButton() = MenuGetItemCount
869 printlog( CFN & "Success on " & iClick & ". attempt" )
872 qaerrorlog( CFN & "#i96753 - Failed to retrieve itemcount from Menu-/Command-button" )
873 bUseSlowMethod = true
880 '*******************************************************************************
882 function hClickCommandButton( iItemToClick as integer ) as boolean
884 const CFN = "hClickCommandButton::"
885 printlog( CFN & "Enter" )
887 dim brc as boolean 'a multi purpose boolean returnvalue
888 dim iMenuItems as integer
890 iMenuItems = hOpenMenuButton( Command )
893 if ( iMenuItems < 0 ) then
894 warnlog( CFN & "Menu apparently not open, giving up." )
895 hClickCommandButton() = false
899 hMenuSelectNr( iItemToClick )
901 ' check for the rename dialog (menu)
902 kontext "CustomizeMenuReName"
903 if ( CustomizeMenuReName.exists() ) then
904 printlog( CFN & "Opened dialog: Rename Menu" )
905 hClickCommandButton() = true
909 ' check for the rename dialog (toolbar)
910 kontext "CustomizeToolbarsRename"
911 if ( CustomizeToolbarsRename.exists() ) then
912 printlog( CFN & "Opened dialog: Rename Toolbar" )
913 hClickCommandButton() = true
917 printlog( CFN & "Exit" )
918 hClickCommandButton() = true