summaryrefslogtreecommitdiff
path: root/testautomation/framework/required/includes/tools_customize.inc
blob: 6bf31e391f99390a93aab9d336f47db0a0700fd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU Lesser General Public License version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org.  If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
'/******************************************************************************
'*
'*  owner : joerg.skottke@sun.com
'*
'*  short description : Update Test for the Tools Customize Dialog
'*
'\******************************************************************************

testcase tUpdtCustomize( cApp as string )

    printlog( "Tools/Customize dialog" )

    if ( hCreateDocument() ) then    
        if ( hToolsCustomizeOpen() ) then
            hUpdtToolsCustomizeKeyboard()
            hUpdtToolsCustomizeMenu()
            hUpdtToolsCustomizeToolbars()
            hUpdtToolsCustomizeEvents()
            hCloseDialog( TabCustomizeEvents, "cancel" )
        else
            warnlog( "Tools/Customize dialog did not open" )
        endif
        hDestroyDocument
    else
        warnlog( "Failed to create initial document" )
    endif
    
endcase

'*******************************************************************************

function hUpdtToolsCustomizeMenu()

    const CFN = "hUpdtToolsCustomizeMenu::"

    const MENUITEM_MOVE              = 1
    const MENUITEM_ADDSUBMENU        = 1
    const MENUITEM_RENAME            = 2
    const MENUITEM_DELETE            = 3
    const MENUITEM_MODIFY            = 2
    const MENUITEM_MODIFY_LARGE_MENU = 4

    const APPLICATION_ONLY = 1
    const APPLICATION_AND_DOCUMENT    = 2
    const ITEMNAME = "tUpdtCustomize"

    dim brc as boolean

    dim iItems as integer
    dim iCurrentItem as integer
    dim iMenuListItems as integer
    dim iEntriesListItems as integer    
    
    printlog( "" )
    printlog( "Menu" )

    hToolsCustomizeSelectTab( "Menu" )
    call DialogTest( TabCustomizeMenu )
    
    printlog( CFN & "Click New..." )
    kontext "TabCustomizeMenu"
    BtnNew.click()
    
    Kontext "MenuOrganiser"
    if ( MenuOrganiser.exists( 2 ) ) then
        printlog( CFN & "MenuOrganiser" )
        call DialogTest( MenuOrganiser )

        printlog( CFN & "Down..." )
        ButtonDown.click()

        printlog( CFN & "Up..." )
        ButtonUp.click()

        printlog( CFN & "Name the new menu" )
        MenuName.setText( "tUpdtCustomize" )

        'qaerrorlog( "#i60609# Undeclared listbox in menu organiser" )
        printlog( "TODO: Access the listbox in menuorganizer" )

        printlog( CFN & "Close the menu with ok" )
        hCloseDialog( MenuOrganiser, "ok" )
    else
        warnlog( "Dialog <MenuOrganiser> did not open" )
    endif
    
    printlog( CFN & "Click the menu listbutton" )
    kontext "TabCustomizeMenu"
    hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
    
    printlog( CFN & "Select Move..." )
    hMenuSelectNr( MENUITEM_MOVE )
    
    kontext "MenuOrganiser"
    if ( MenuOrganiser.exists( 2 ) ) then
        printlog( CFN & "Click UP" )
        ButtonUp.click()

        kontext "MenuOrganiser"
        printlog( CFN & "Click DOWN" )
        ButtonDown.click()

        printlog( CFN & "Cancel the dialog" )
        hCloseDialog( MenuOrganiser, "cancel" )
    else
        warnlog( "Dialog <MenuOrganizer> did not open" )
    endif
    
    printlog( CFN & "Click the menu listbutton" )
    kontext "TabCustomizeMenu"
    hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
    
    printlog( CFN & "Select Rename..." )
    hMenuSelectNr( MENUITEM_RENAME )

    printlog( CFN & "Cancel the renaming-dialog" )
    kontext "RenameMenu"
    RenameMenu.cancel()
    
    printlog( CFN & "Click the menu listbutton" )
    kontext "TabCustomizeMenu"
    hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
    
    printlog( CFN & "Select Delete" )
    hMenuSelectNr( MENUITEM_DELETE )
    
    kontext "TabCustomizeMenu"
    hUpdtToolsCustomizeScriptSelector( 3 )
    
    printlog( CFN & "Check itemcount in SaveIn List" )
    kontext "TabCustomizeMenu"
    select case gApplication
    case "BACKGROUND"   :   brc = hToolsCustomizeTestSaveIn( APPLICATION_ONLY )
    case else           :   brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
    end select
    if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )
    
    printlog( CFN & "Down..." )
    BtnDown.click()
    
    printlog( CFN & "Up..." )
    BtnUp.click()
    
    printlog( CFN & "Click the Modify-Button and select item 1 (Add submenu)" )
    kontext "TabCustomizeMenu"

    if ( not hClickCommandButton( MENUITEM_ADDSUBMENU ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    printlog( CFN & "Give the submenu a name, accept with OK" )
    kontext "CustomizeMenuName"
    call dialogtest( CustomizeMenuName )
    EingabeFeld.setText( ITEMNAME )
    CustomizeMenuName.ok()
    
    printlog( CFN & "Find the new submenu in the list and select it" )
    WaitSlot()
    kontext "TabCustomizeMenu"
    iEntriesListItems = Entries.getItemCount()
    for iCurrentItem = 1 to iEntriesListItems
    
        Entries.select( iCurrentItem )
        if ( Entries.getSelText() = ITEMNAME ) then
            exit for
        endif
        
    next iCurrentItem
    
    
    printlog( CFN & "Click the Modify-Button and select to rename the item" )
    kontext "TabCustomizeMenu"
    
    if ( not hClickCommandButton( 3 ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    printlog( CFN & "Rename the item, accept with OK" )
    kontext "CustomizeMenuReName" 
    call dialogtest( CustomizeMenuReName )
    EingabeFeld.setText( ITEMNAME & "1" )
    CustomizeMenuReName.ok()
    
    printlog( CFN & "Verify that the name has been updated" )
    kontext "TabCustomizeMenu"
    if ( Entries.getSelText() <> ( ITEMNAME & "1" ) ) then
        warnlog( "Names do not match" )
    endif
    
    printlog( CFN & "Click the Modify-Button and delete the current item" )
    kontext "TabCustomizeMenu"

    if ( not hClickCommandButton( MENUITEM_MODIFY_LARGE_MENU ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    printlog( CFN & "Click the Modify-Button and create a new group" )
    kontext "TabCustomizeMenu"

    if ( not hClickCommandButton( MENUITEM_MODIFY ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    ' Note: The current index for the delete-function is at pos 2.
    printlog( CFN & "Click the Modify-Button and delete the new group" )
    kontext "TabCustomizeMenu"

    if ( not hClickCommandButton( MENUITEM_MODIFY ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
end function

'*******************************************************************************

function hUpdtToolsCustomizeToolbars()

    const CFN = "hUpdtToolsCustomizeToolbars::"

    const DOCUMENT_ONLY = 1
    const APPLICATION_AND_DOCUMENT = 2

    const MENUITEM_RENAME = 1
    const MENUITEM_DELETE = 2
    const MENUITEM_MODIFY = 4

    const DIALOG_DELAY = 3

    dim brc as boolean
    dim iCurrentItem as integer
        
    printlog( "" )
    printlog( "Toolbars" )

    brc = hToolsCustomizeSelectTab( "Toolbars" )
    call DialogTest( TabCustomizeToolbars )
    
    printlog( CFN & "Click New..." )
    kontext "TabCustomizeToolbars"
    BtnNew.click()
    
    kontext "NewToolbar"
    if ( NewToolbar.exists( DIALOG_DELAY ) ) then
        printlog( CFN & "NewToolbar" )
        call DialogTest( NewToolbar )
        
        select case gApplication
        case "BACKGROUND"   :   brc = hToolsCustomizeTestSaveIn( DOCUMENT_ONLY )
        case else           :   brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
        end select

        if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )
        
        printlog( CFN & "Name the new toolbar for further usage" )
        ToolbarName.setText( "tUpdtCustomize" )
        
        printlog( CFN & "Close NewToolbar dialog with OK" )
        hCloseDialog( NewToolbar, "ok" )
    else
        warnlog( CFN & "Could not access New Toolbar dialog" )
    endif
    
    printlog( CFN & "Rename the toolbar via Toolbar-Button" )
    kontext "TabCustomizeToolbars"
    hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
    
    printlog( "Select rename" )
    hMenuSelectNr( MENUITEM_RENAME )
    
    printlog( CFN & "Cancel the dialog" )
    kontext "RenameToolbar"
    if ( RenameToolbar.exists( DIALOG_DELAY ) ) then
        call dialogtest( RenameToolbar )
        hCloseDialog( RenameToolbar, "Cancel" )
    else
        warnlog( CFN & "Could not access Toolbar renaming dialog" )
    endif
    
    printlog( CFN & "Delete the toolbar via Toolbar-Button" )
    kontext "TabCustomizeToolbars"
    hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
    
    printlog( "Select delete" )
    hMenuSelectNr( MENUITEM_DELETE )
       
    kontext "TabCustomizeToolbars"
    hUpdtToolsCustomizeScriptSelector( 2 )
    
    kontext "TabCustomizeToolbars"
    select case gApplication
    case "BACKGROUND"   :   brc = hToolsCustomizeTestSaveIn( DOCUMENT_ONLY )
    case else           :   brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
    end select

    if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )
    
    printlog( CFN & "Down..." )
    if ( BtnDown.isEnabled() ) then
        BtnDown.click()
    else
        qaerrorlog( "BtnDown is not enabled" )
    endif
    
    printlog( CFN & "Up..." )
    if ( BtnUp.isEnabled() ) then
        BtnUp.click()
    else
        qaerrorlog( "BtnUp is not enabled" )
    endif

    kontext "TabCustomizeToolbars"
    printlog( CFN & "Add command" )
    AddCommands.click()
    
    kontext "ScriptSelector"
    if ( ScriptSelector.exists( DIALOG_DELAY ) ) then
    
        call dialogtest( ScriptSelector )
    
        ' This is a workaround that applies when - for some reason - the menu
        ' (menubutton: AddCommands) is not open. In this case the ScriptSelector
        ' will not open. Before this hack the office was left in an unstable state
        ' and the following tests would have failed. Now we get a  warning
        ' instead.
        
        printlog( CFN & "Add the default item" )
        try
            kontext "ScriptSelector"
            hCloseDialog( ScriptSelector, "ok" )
        catch
            qaerrorlog( "#i79207# Could not access ok button on ScriptSelector" )
            kontext "ScriptSelector"
            if ( ScriptSelector.exists( DIALOG_DELAY ) ) then printlog( "Scriptselector is open" )
        endcatch
        
    else
        LibraryTreeList.typeKeys( "<HOME>" )
        for iCurrentItem = 1 to 5
            printlog( CFN & "LibraryTreeList: Moving down..." )
            LibraryTreeList.typeKeys( "<DOWN>" )
            if ( ScriptSelector.isEnabled() ) then exit for
        next iCurrentItem
    endif
    
    ' Note: The Customize dialog in the background is updated immediately. This
    '       means that the cancel-button is active but blocked for a moment
    'WaitSlot( 2000 )
    
    printlog( CFN & "Close the Script Selector, back to ToolsCustomize dialog" )
    hCloseDialog( ScriptSelector, "cancel" )
    
    kontext "TabCustomizeToolbars"
    printlog( CFN & "Click the Modify-button" )

    if ( not hClickCommandButton( 1 ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
    	exit function
    endif
    
    printlog( CFN & "Rename the item" )
    UseBindings
    kontext "CustomizeToolbarsRename"
    if ( CustomizeToolbarsRename.exists( DIALOG_DELAY ) ) then
        call dialogtest( CustomizeToolbarsRename )
        EingabeFeld.setText( "Renamed item" )
    
        printlog( CFN & "Close the dialog" )
        hCloseDialog( CustomizeToolbarsRename, "ok" )
    else
        warnlog( CFN & "CustomizeToolbarsRename could not be accessed" )
    endif
    
    kontext "TabCustomizeToolbars"

    if ( not hClickCommandButton( 2 ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    kontext "TabCustomizeToolbars"
    waitslot
    printlog( CFN & "Click the Modify-button" )
    printlog( "******************** 1 ********************" )
    hDeselectSeparator()
    printlog( "******************** 2 ********************" )

    if ( not hClickCommandButton( 3 ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    kontext "TabCustomizeToolbars"
    waitslot
    printlog( CFN & "Click the Modify-button" )

if ( not hClickCommandButton( MENUITEM_MODIFY ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    kontext "TabCustomizeToolbars"
    WaitSlot
    printlog( CFN & "Click the Modify-button" )

    if ( not hClickCommandButton( 1 ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    kontext "TabCustomizeToolbars"
    waitslot
    printlog( CFN & "Click the Modify-button" )
    printlog( "******************** 3 ********************" )
    hDeselectSeparator()
    printlog( "******************** 4 ********************" )

    if ( not hClickCommandButton( 5 ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif
    
    printlog( CFN & "On the Change Icon dialog: Click to import an icon" )
    kontext "ChangeIcon"
    if ( ChangeIcon.exists( DIALOG_DELAY ) ) then
        call dialogtest( ChangeIcon )
        import.click()
    
        printlog( CFN & "Cancel the FileOpen-dialog" )
        kontext "OeffnenDlg"
        call dialogtest( OeffnenDlg )
        hCloseDialog( OeffnenDlg, "cancel" )
        
        printlog( CFN & "Close the Change Icon dialog with <ok>" )
        kontext "ChangeIcon"
        hCloseDialog( ChangeIcon, "ok" )
    else
        warnlog( CFN & "Could not access Change Icon dialog" )
    endif
    
    kontext "TabCustomizeToolbars"
    waitslot
    printlog( CFN & "Click the Modify-button" )

    if ( not hClickCommandButton( 3 ) ) then
        warnlog( CFN & "Something went wrong when accessing the command button" )
        exit function
    endif

end function


'*******************************************************************************

function hUpdtToolsCustomizeEvents()

    const CFN = "hUpdtToolsCustomizeEvents::"
    const APPLICATION_ONLY         = 1
    const APPLICATION_AND_DOCUMENT = 2
    const TAB_EVENTS               = 1

    dim brc as boolean

    printlog( "" )
    printlog( "Events" )
    
    hToolsCustomizeSelectTab( "events" )
    if ( TabCustomizeEvents.exists() ) then
        if ( TabCustomizeEvents.isVisible() ) then
            call DialogTest( TabCustomizeEvents )

            hUpdtToolsCustomizeScriptSelector( TAB_EVENTS )

            kontext "TabCustomizeEvents"
            select case gApplication
            case "BACKGROUND"   :   brc = hToolsCustomizeTestSaveIn( APPLICATION_ONLY )
            case else           :   brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
            end select

            if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )

        else
            warnlog( "<TabCustomizeEvents> is not visible" )
        endif
    else
        warnlog( "<TabCustomizeEvents> did not open" )
    endif

end function

'*******************************************************************************

function hUpdtToolsCustomizeKeyboard() as boolean

    const CFN = "hUpdtToolsCustomizeKeyboard::"
    const FIRST_CHANGEABLE_ITEM = 2
    
    printlog( "" )
    printlog( "Keyboard" )

    if ( gApplication = "BACKGROUND" ) then
        if ( not hToolsCustomizeSelectTab( "keyboard" ) ) then
            qaerrorlog( "#i61765# TabTastatur is missing when called from Backing Window" )
            hUpdtToolsCustomizeKeyboard() = false
            exit function
        endif
    endif

    hToolsCustomizeSelectTab( "keyboard" )

    kontext "TabTastatur"
    call DialogTest( TabTastatur )
  
    ' no verification of functionality, this is an update test!
    kontext "TabTastatur"
    StarOffice.check()
    hSelectNode( Tastatur , FIRST_CHANGEABLE_ITEM )
    hSelectTopNode( bereich )

    ' Workaround: It might still happen that the currently selected accelerator
    '             is "fixed" so we need to find another one that can be modified.
    do while ( not Aendern.isEnabled() ) 
        printlog( "Moving selection down by one, Control is not enabled" )
        Tastatur.TypeKeys( "<DOWN>" )
    loop 

    Aendern.click()
    Zuruecksetzen.click()
    hSelectNode( Tastatur , FIRST_CHANGEABLE_ITEM )

    ' Workaround: It might still happen that the currently selected accelerator
    '             is "fixed" so we need to find another one that can be modified.
    do while ( not Aendern.isEnabled() ) 
        printlog( "Moving selection down by one, Control is not enabled" )
        Tastatur.TypeKeys( "<DOWN>" )
    loop 

    Aendern.click()
    Loeschen.click()
    Speichern.click()
    
    kontext "SpeichernDlg"
    hCloseDialog( SpeichernDlg, "cancel" )
    
    kontext "TabTastatur"
    Laden.click()
    
    kontext "OeffnenDlg"
    hCloseDialog( OeffnenDlg, "cancel" )

end function

'*******************************************************************************

function hUpdtToolsCustomizeScriptSelector( iPageButton as integer ) as boolean
    
    const CFN = "hUpdtToolsCustomizeScriptSelector::"

    dim brc as boolean :  brc = true
    const TAB_EVENTS   = 1
    const TAB_TOOLBARS = 2
    const TAB_MENU     = 3
    const DIALOG_DELAY = 2

    select case iPageButton
    case TAB_EVENTS
        kontext "TabCustomizeEvents"
        printlog( CFN & "Assign Macro... (1)" )
        AssignMacro.click()
    case TAB_TOOLBARS
        kontext "TabCustomizeToolbars"
        printlog( CFN & "Add... (2)" )
        AddCommands.click()
    case TAB_MENU
        kontext "TabCustomizeMenu"
        printlog( CFN & "Add... (3)" )
        AddCommands.click()
    case else
        warnlog( CFN & "Invalid function parameter" )
        hUpdtToolsCustomizeScriptSelector() = false
        exit function
    end select
  
    kontext "ScriptSelector"
    if ( ScriptSelector.exists( DIALOG_DELAY ) ) then
        call DialogTest( ScriptSelector )

        kontext "ScriptSelector"
        hCloseDialog( ScriptSelector, "cancel" )
    else
         warnlog( CFN & "Dialog <ScriptSelector> did not open" )
    endif
   
    select case iPageButton
    case TAB_EVENTS   : kontext "TabCustomizeEvents"
    case TAB_TOOLBARS : kontext "TabCustomizeToolbars"
    case TAB_MENU     : kontext "TabCustomizeMenu"
    end select    
    
    hUpdtToolsCustomizeScriptSelector() = brc
    
end function

'*******************************************************************************

function hToolsCustomizeTestSaveIn( iItems as integer ) as boolean
    
    const CFN = "hToolsCustomizeTestSaveIn::"
    dim iPresentItems as integer

    iPresentItems = SaveIn.getItemCount()
    
    if ( iPresentItems <> iItems ) then
        printlog( CFN & "Incorrect itemcount in SaveIn: " )
        printlog( CFN & "Expected: " & iItems )
        printlog( CFN & "Found...: " & iPresentItems )
        hToolsCustomizeTestSaveIn() = false
    else
        printlog( CFN & "Correct itemcount in SaveIn: " & iItems )
        hToolsCustomizeTestSaveIn() = true
    endif

end function

'*******************************************************************************

function hOpenMenuButton( oControl as object ) as integer

    ' This function is very evil.
    ' It was written to hopefully workaround the infamous menubutton which is a button 
    ' that - when clicked - opens a menu. This feature is shaky and depends on 
    ' a lot of factors. There is a simple working implemantation in t_menu.inc 
    ' which has the drawback of being absolutely slow, costing the tools_customize
    ' test a lot of time waiting for the control (30% of testtime spent waiting).
    ' This approach tries to be dynamic: Machines that can do it the fast way
    ' use it automatically, machines that are too slow get two retries with the 
    ' slower approach.
    ' The menubutton is one of the last remaining places where none of the
    ' speed optmizations and enhancements apply, so neither WaitSlot() nor 
    ' synchronous slot execution help here.

    dim iClick as integer
    dim bUseSlowMethod as boolean : bUseSlowMethod = false
    
    const CFN = "hOpenMenuButton: "
    const RC_FAILURE = -1
    const MAX_RETRIES = 3
    const DEFAULT_DELAY = 1000
    
    hOpenMenuButton() = RC_FAILURE
    
    for iClick = 1 to MAX_RETRIES
    
        if ( bUseSlowMethod ) then 
            wait( DEFAULT_DELAY )
            oControl.OpenMenu()
            wait( DEFAULT_DELAY * 3 )
        else
            oControl.click()
        endif
            
        try
            hOpenMenuButton() = MenuGetItemCount
            printlog( CFN & "Success on " & iClick & ". attempt" )
            exit function
        catch
            qaerrorlog( CFN & "#i96753 - Failed to retrieve itemcount from Menu-/Command-button" )
            bUseSlowMethod = true
        endcatch
        
    next iClick
    
end function

'*******************************************************************************

function hClickCommandButton( iItemToClick as integer ) as boolean

    const CFN = "hClickCommandButton::"
    printlog( CFN & "Enter" )
    
    dim brc as boolean 'a multi purpose boolean returnvalue
    dim iMenuItems as integer

    iMenuItems = hOpenMenuButton( Command )
    
    ' exit on error
    if ( iMenuItems < 0 ) then
        warnlog( CFN & "Menu apparently not open, giving up." )
    	hClickCommandButton() = false
    	exit function
    endif        
    
    hMenuSelectNr( iItemToClick ) 
    wait( 500 )
    ' check for the rename dialog (menu)
    kontext "CustomizeMenuReName"
    if ( CustomizeMenuReName.exists() ) then
    	printlog( CFN & "Opened dialog: Rename Menu" )
    	hClickCommandButton() = true
    	exit function
    endif
    
    ' check for the rename dialog (toolbar)    
    kontext "CustomizeToolbarsRename"
    if ( CustomizeToolbarsRename.exists() ) then
    	printlog( CFN & "Opened dialog: Rename Toolbar" )
    	hClickCommandButton() = true
    	exit function
    endif

    printlog( CFN & "Exit" )
    hClickCommandButton() = true

end function