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 : gregor.hartmann@oracle.com
30 '* short description : Update Test for the Tools Customize Dialog
32 '\******************************************************************************
34 testcase tUpdtCustomize( cApp as string )
36 printlog( "Tools/Customize dialog" )
38 if ( hCreateDocument() ) then
39 if ( hToolsCustomizeOpen() ) then
40 hUpdtToolsCustomizeKeyboard()
41 hUpdtToolsCustomizeMenu()
42 hUpdtToolsCustomizeToolbars()
43 hUpdtToolsCustomizeEvents()
44 hCloseDialog( TabCustomizeEvents, "cancel" )
46 warnlog( "Tools/Customize dialog did not open" )
50 warnlog( "Failed to create initial document" )
55 '*******************************************************************************
57 function hUpdtToolsCustomizeMenu()
59 const CFN = "hUpdtToolsCustomizeMenu::"
61 const MENUITEM_MOVE = 1
62 const MENUITEM_ADDSUBMENU = 1
63 const MENUITEM_RENAME = 2
64 const MENUITEM_DELETE = 3
65 const MENUITEM_MODIFY = 2
66 const MENUITEM_MODIFY_LARGE_MENU = 4
68 const APPLICATION_ONLY = 1
69 const APPLICATION_AND_DOCUMENT = 2
70 const ITEMNAME = "tUpdtCustomize"
75 dim iCurrentItem as integer
76 dim iMenuListItems as integer
77 dim iEntriesListItems as integer
82 hToolsCustomizeSelectTab( "Menu" )
83 call DialogTest( TabCustomizeMenu )
85 printlog( CFN & "Click New..." )
86 kontext "TabCustomizeMenu"
89 Kontext "MenuOrganiser"
90 if ( MenuOrganiser.exists( 2 ) ) then
91 printlog( CFN & "MenuOrganiser" )
92 call DialogTest( MenuOrganiser )
94 printlog( CFN & "Down..." )
97 printlog( CFN & "Up..." )
100 printlog( CFN & "Name the new menu" )
101 MenuName.setText( "tUpdtCustomize" )
103 'qaerrorlog( "#i60609# Undeclared listbox in menu organiser" )
104 printlog( "TODO: Access the listbox in menuorganizer" )
106 printlog( CFN & "Close the menu with ok" )
107 hCloseDialog( MenuOrganiser, "ok" )
109 warnlog( "Dialog <MenuOrganiser> did not open" )
112 printlog( CFN & "Click the menu listbutton" )
113 kontext "TabCustomizeMenu"
114 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
116 printlog( CFN & "Select Move..." )
117 hMenuSelectNr( MENUITEM_MOVE )
119 kontext "MenuOrganiser"
120 if ( MenuOrganiser.exists( 2 ) ) then
121 printlog( CFN & "Click UP" )
124 kontext "MenuOrganiser"
125 printlog( CFN & "Click DOWN" )
128 printlog( CFN & "Cancel the dialog" )
129 hCloseDialog( MenuOrganiser, "cancel" )
131 warnlog( "Dialog <MenuOrganizer> did not open" )
134 printlog( CFN & "Click the menu listbutton" )
135 kontext "TabCustomizeMenu"
136 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
138 printlog( CFN & "Select Rename..." )
139 hMenuSelectNr( MENUITEM_RENAME )
141 printlog( CFN & "Cancel the renaming-dialog" )
145 printlog( CFN & "Click the menu listbutton" )
146 kontext "TabCustomizeMenu"
147 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
149 printlog( CFN & "Select Delete" )
150 hMenuSelectNr( MENUITEM_DELETE )
152 kontext "TabCustomizeMenu"
153 hUpdtToolsCustomizeScriptSelector( 3 )
155 printlog( CFN & "Check itemcount in SaveIn List" )
156 kontext "TabCustomizeMenu"
157 select case gApplication
158 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( APPLICATION_ONLY )
159 case else : brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
161 if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )
163 printlog( CFN & "Down..." )
166 printlog( CFN & "Up..." )
169 printlog( CFN & "Click the Modify-Button and select item 1 (Add submenu)" )
170 kontext "TabCustomizeMenu"
172 if ( not hClickCommandButton( MENUITEM_ADDSUBMENU ) ) then
173 warnlog( CFN & "Something went wrong when accessing the command button" )
177 printlog( CFN & "Give the submenu a name, accept with OK" )
178 kontext "CustomizeMenuName"
179 call dialogtest( CustomizeMenuName )
180 EingabeFeld.setText( ITEMNAME )
181 CustomizeMenuName.ok()
183 printlog( CFN & "Find the new submenu in the list and select it" )
185 kontext "TabCustomizeMenu"
186 iEntriesListItems = Entries.getItemCount()
187 for iCurrentItem = 1 to iEntriesListItems
189 Entries.select( iCurrentItem )
190 if ( Entries.getSelText() = ITEMNAME ) then
197 printlog( CFN & "Click the Modify-Button and select to rename the item" )
198 kontext "TabCustomizeMenu"
200 if ( not hClickCommandButton( 3 ) ) then
201 warnlog( CFN & "Something went wrong when accessing the command button" )
205 printlog( CFN & "Rename the item, accept with OK" )
206 kontext "CustomizeMenuReName"
207 call dialogtest( CustomizeMenuReName )
208 EingabeFeld.setText( ITEMNAME & "1" )
209 CustomizeMenuReName.ok()
211 printlog( CFN & "Verify that the name has been updated" )
212 kontext "TabCustomizeMenu"
213 if ( Entries.getSelText() <> ( ITEMNAME & "1" ) ) then
214 warnlog( "Names do not match" )
217 printlog( CFN & "Click the Modify-Button and delete the current item" )
218 kontext "TabCustomizeMenu"
220 if ( not hClickCommandButton( MENUITEM_MODIFY_LARGE_MENU ) ) then
221 warnlog( CFN & "Something went wrong when accessing the command button" )
225 printlog( CFN & "Click the Modify-Button and create a new group" )
226 kontext "TabCustomizeMenu"
228 if ( not hClickCommandButton( MENUITEM_MODIFY ) ) then
229 warnlog( CFN & "Something went wrong when accessing the command button" )
233 ' Note: The current index for the delete-function is at pos 2.
234 printlog( CFN & "Click the Modify-Button and delete the new group" )
235 kontext "TabCustomizeMenu"
237 if ( not hClickCommandButton( MENUITEM_MODIFY ) ) then
238 warnlog( CFN & "Something went wrong when accessing the command button" )
244 '*******************************************************************************
246 function hUpdtToolsCustomizeToolbars()
248 const CFN = "hUpdtToolsCustomizeToolbars::"
250 const DOCUMENT_ONLY = 1
251 const APPLICATION_AND_DOCUMENT = 2
253 const MENUITEM_RENAME = 1
254 const MENUITEM_DELETE = 2
255 const MENUITEM_MODIFY = 4
257 const DIALOG_DELAY = 1
260 dim iCurrentItem as integer
263 printlog( "Toolbars" )
265 brc = hToolsCustomizeSelectTab( "Toolbars" )
266 call DialogTest( TabCustomizeToolbars )
268 printlog( CFN & "Click New..." )
269 kontext "TabCustomizeToolbars"
273 if ( NewToolbar.exists( DIALOG_DELAY ) ) then
274 printlog( CFN & "NewToolbar" )
275 call DialogTest( NewToolbar )
277 select case gApplication
278 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( DOCUMENT_ONLY )
279 case else : brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
282 if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )
284 printlog( CFN & "Name the new toolbar for further usage" )
285 ToolbarName.setText( "tUpdtCustomize" )
287 printlog( CFN & "Close NewToolbar dialog with OK" )
288 hCloseDialog( NewToolbar, "ok" )
290 warnlog( CFN & "Could not access New Toolbar dialog" )
293 printlog( CFN & "Rename the toolbar via Toolbar-Button" )
294 kontext "TabCustomizeToolbars"
295 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
297 printlog( "Select rename" )
298 hMenuSelectNr( MENUITEM_RENAME )
300 printlog( CFN & "Cancel the dialog" )
301 kontext "RenameToolbar"
302 if ( RenameToolbar.exists( DIALOG_DELAY ) ) then
303 call dialogtest( RenameToolbar )
304 hCloseDialog( RenameToolbar, "Cancel" )
306 warnlog( CFN & "Could not access Toolbar renaming dialog" )
309 printlog( CFN & "Delete the toolbar via Toolbar-Button" )
310 kontext "TabCustomizeToolbars"
311 hOpenMenuButton( MenuBtn ) ' MenuBtn.OpenMenu()
313 printlog( "Select delete" )
314 hMenuSelectNr( MENUITEM_DELETE )
316 kontext "TabCustomizeToolbars"
317 hUpdtToolsCustomizeScriptSelector( 2 )
319 kontext "TabCustomizeToolbars"
320 select case gApplication
321 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( DOCUMENT_ONLY )
322 case else : brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
325 if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )
327 printlog( CFN & "Down..." )
328 if ( BtnDown.isEnabled() ) then
331 qaerrorlog( "BtnDown is not enabled" )
334 printlog( CFN & "Up..." )
335 if ( BtnUp.isEnabled() ) then
338 qaerrorlog( "BtnUp is not enabled" )
341 kontext "TabCustomizeToolbars"
342 printlog( CFN & "Add command" )
345 kontext "ScriptSelector"
346 if ( ScriptSelector.exists( DIALOG_DELAY ) ) then
347 printlog( "ScriptSelector open." )
349 LibraryTreeList.typeKeys( "<HOME>" )
350 for iCurrentItem = 1 to 5
351 printlog( CFN & "LibraryTreeList: Moving down..." )
352 LibraryTreeList.typeKeys( "<DOWN>" )
353 if ( ScriptSelector.isEnabled() ) then exit for
357 call dialogtest( ScriptSelector )
359 printlog( CFN & "Close the Script Selector, back to ToolsCustomize dialog" )
360 hCloseDialog( ScriptSelector, "cancel" )
362 kontext "TabCustomizeToolbars"
363 printlog( CFN & "Click the Modify-button" )
365 if ( hClickCommandButton( 1 ) ) then
367 printlog( CFN & "Command button clicked successfully" )
368 kontext "CustomizeToolbarsRename"
371 if ( CustomizeToolbarsRename.exists( DIALOG_DELAY ) ) then
373 printlog( CFN & "Rename dialog is open" )
374 call dialogtest( CustomizeToolbarsRename )
375 EingabeFeld.setText( "Renamed item" )
377 printlog( CFN & "Close the dialog" )
378 hCloseDialog( CustomizeToolbarsRename, "ok" )
380 warnlog( CFN & "CustomizeToolbarsRename could not be accessed" )
383 warnlog( CFN & "Something went wrong when accessing the command button" )
387 kontext "TabCustomizeToolbars"
388 if ( hClickCommandButton( 2 ) ) then
389 printlog( CFN & "Successfully clicked second item on the command button" )
391 warnlog( CFN & "Something went wrong when accessing the command button" )
395 kontext "TabCustomizeToolbars"
397 printlog( CFN & "Deselect separator (if this is the current object)" )
400 kontext "TabCustomizeToolbars"
401 if ( not hClickCommandButton( 3 ) ) then
402 warnlog( CFN & "Something went wrong when accessing the command button" )
407 kontext "TabCustomizeToolbars"
408 printlog( CFN & "Click the Modify-button" )
409 if ( hClickCommandButton( MENUITEM_MODIFY ) ) then
410 printlog( CFN & "Successfully selected modify-item on the command button" )
412 warnlog( CFN & "Something went wrong when accessing the command button" )
417 kontext "TabCustomizeToolbars"
418 printlog( CFN & "Click the Modify-button" )
419 if ( hClickCommandButton( 1 ) ) then
420 printlog( CFN & "Successfully selected modify-item on the command button" )
422 warnlog( CFN & "Something went wrong when accessing the command button" )
427 kontext "TabCustomizeToolbars"
428 printlog( CFN & "Click the Modify-button" )
431 if ( hClickCommandButton( 5 ) ) then
432 printlog( CFN & "Successfully selected modify-item on the command button" )
434 warnlog( CFN & "Something went wrong when accessing the command button" )
439 printlog( CFN & "On the Change Icon dialog: Click to import an icon" )
440 if ( ChangeIcon.exists( DIALOG_DELAY ) ) then
441 call dialogtest( ChangeIcon )
444 printlog( CFN & "Cancel the FileOpen-dialog" )
446 call dialogtest( OeffnenDlg )
447 hCloseDialog( OeffnenDlg, "cancel" )
449 printlog( CFN & "Close the Change Icon dialog with <ok>" )
451 hCloseDialog( ChangeIcon, "ok" )
453 warnlog( CFN & "Could not access Change Icon dialog" )
457 kontext "TabCustomizeToolbars"
458 printlog( CFN & "Click the Modify-button" )
459 if ( hClickCommandButton( 3 ) ) then
460 printlog( CFN & "Successfully selected modify-item on the command button" )
462 warnlog( CFN & "Something went wrong when accessing the command button" )
469 '*******************************************************************************
471 function hUpdtToolsCustomizeEvents()
473 const CFN = "hUpdtToolsCustomizeEvents::"
474 const APPLICATION_ONLY = 1
475 const APPLICATION_AND_DOCUMENT = 2
483 hToolsCustomizeSelectTab( "events" )
484 if ( TabCustomizeEvents.exists() ) then
485 if ( TabCustomizeEvents.isVisible() ) then
486 call DialogTest( TabCustomizeEvents )
488 hUpdtToolsCustomizeScriptSelector( TAB_EVENTS )
490 kontext "TabCustomizeEvents"
491 select case gApplication
492 case "BACKGROUND" : brc = hToolsCustomizeTestSaveIn( APPLICATION_ONLY )
493 case else : brc = hToolsCustomizeTestSaveIn( APPLICATION_AND_DOCUMENT )
496 if ( not brc ) then warnlog( "Incorrect itemcount in listbox, see above" )
499 warnlog( "<TabCustomizeEvents> is not visible" )
502 warnlog( "<TabCustomizeEvents> did not open" )
507 '*******************************************************************************
509 function hUpdtToolsCustomizeKeyboard() as boolean
511 const CFN = "hUpdtToolsCustomizeKeyboard::"
512 const FIRST_CHANGEABLE_ITEM = 2
515 printlog( "Keyboard" )
517 if ( gApplication = "BACKGROUND" ) then
518 if ( not hToolsCustomizeSelectTab( "keyboard" ) ) then
519 qaerrorlog( "#i61765# TabTastatur is missing when called from Backing Window" )
520 hUpdtToolsCustomizeKeyboard() = false
525 hToolsCustomizeSelectTab( "keyboard" )
527 kontext "TabTastatur"
528 call DialogTest( TabTastatur )
530 ' no verification of functionality, this is an update test!
531 kontext "TabTastatur"
533 hSelectNode( Tastatur , FIRST_CHANGEABLE_ITEM )
534 hSelectTopNode( bereich )
536 ' Workaround: It might still happen that the currently selected accelerator
537 ' is "fixed" so we need to find another one that can be modified.
538 do while ( not Aendern.isEnabled() )
539 printlog( "Moving selection down by one, Control is not enabled" )
540 Tastatur.TypeKeys( "<DOWN>" )
544 Zuruecksetzen.click()
545 hSelectNode( Tastatur , FIRST_CHANGEABLE_ITEM )
547 ' Workaround: It might still happen that the currently selected accelerator
548 ' is "fixed" so we need to find another one that can be modified.
549 do while ( not Aendern.isEnabled() )
550 printlog( "Moving selection down by one, Control is not enabled" )
551 Tastatur.TypeKeys( "<DOWN>" )
558 kontext "SpeichernDlg"
559 hCloseDialog( SpeichernDlg, "cancel" )
561 kontext "TabTastatur"
565 hCloseDialog( OeffnenDlg, "cancel" )
569 '*******************************************************************************
571 function hUpdtToolsCustomizeScriptSelector( iPageButton as integer ) as boolean
573 const CFN = "hUpdtToolsCustomizeScriptSelector::"
575 dim brc as boolean : brc = true
577 const TAB_TOOLBARS = 2
579 const DIALOG_DELAY = 2
581 select case iPageButton
583 kontext "TabCustomizeEvents"
584 printlog( CFN & "Assign Macro... (1)" )
587 kontext "TabCustomizeToolbars"
588 printlog( CFN & "Add... (2)" )
591 kontext "TabCustomizeMenu"
592 printlog( CFN & "Add... (3)" )
595 warnlog( CFN & "Invalid function parameter" )
596 hUpdtToolsCustomizeScriptSelector() = false
600 kontext "ScriptSelector"
601 if ( ScriptSelector.exists( DIALOG_DELAY ) ) then
602 call DialogTest( ScriptSelector )
604 kontext "ScriptSelector"
605 hCloseDialog( ScriptSelector, "cancel" )
607 warnlog( CFN & "Dialog <ScriptSelector> did not open" )
610 select case iPageButton
611 case TAB_EVENTS : kontext "TabCustomizeEvents"
612 case TAB_TOOLBARS : kontext "TabCustomizeToolbars"
613 case TAB_MENU : kontext "TabCustomizeMenu"
616 hUpdtToolsCustomizeScriptSelector() = brc
620 '*******************************************************************************
622 function hToolsCustomizeTestSaveIn( iItems as integer ) as boolean
624 const CFN = "hToolsCustomizeTestSaveIn::"
625 dim iPresentItems as integer
627 iPresentItems = SaveIn.getItemCount()
629 if ( iPresentItems <> iItems ) then
630 printlog( CFN & "Incorrect itemcount in SaveIn: " )
631 printlog( CFN & "Expected: " & iItems )
632 printlog( CFN & "Found...: " & iPresentItems )
633 hToolsCustomizeTestSaveIn() = false
635 printlog( CFN & "Correct itemcount in SaveIn: " & iItems )
636 hToolsCustomizeTestSaveIn() = true
641 '*******************************************************************************
643 function hOpenMenuButton( oControl as object ) as integer
645 ' This function is very evil.
646 ' It was written to hopefully workaround the infamous menubutton which is a button
647 ' that - when clicked - opens a menu. This feature is shaky and depends on
648 ' a lot of factors. There is a simple working implemantation in t_menu.inc
649 ' which has the drawback of being absolutely slow, costing the tools_customize
650 ' test a lot of time waiting for the control (30% of testtime spent waiting).
651 ' This approach tries to be dynamic: Machines that can do it the fast way
652 ' use it automatically, machines that are too slow get two retries with the
654 ' The menubutton is one of the last remaining places where none of the
655 ' speed optmizations and enhancements apply, so neither WaitSlot() nor
656 ' synchronous slot execution help here.
658 dim iClick as integer
659 dim bUseSlowMethod as boolean : bUseSlowMethod = false
661 const CFN = "hOpenMenuButton: "
662 const RC_FAILURE = -1
663 const MAX_RETRIES = 3
664 const DEFAULT_DELAY = 1000
666 hOpenMenuButton() = RC_FAILURE
668 for iClick = 1 to MAX_RETRIES
670 if ( bUseSlowMethod ) then
671 wait( DEFAULT_DELAY )
673 wait( DEFAULT_DELAY * 3 )
679 hOpenMenuButton() = MenuGetItemCount
680 printlog( CFN & "Success on " & iClick & ". attempt" )
683 qaerrorlog( CFN & "#i96753 - Failed to retrieve itemcount from Menu-/Command-button" )
684 bUseSlowMethod = true
691 '*******************************************************************************
693 function hClickCommandButton( iItemToClick as integer ) as boolean
695 const CFN = "hClickCommandButton::"
696 printlog( CFN & "Enter" )
698 dim brc as boolean 'a multi purpose boolean returnvalue
699 dim iMenuItems as integer
701 iMenuItems = hOpenMenuButton( Command )
704 if ( iMenuItems < 0 ) then
705 warnlog( CFN & "Menu apparently not open, giving up." )
706 hClickCommandButton() = false
710 hMenuSelectNr( iItemToClick )
712 ' check for the rename dialog (menu)
713 kontext "CustomizeMenuReName"
714 if ( CustomizeMenuReName.exists() ) then
715 printlog( CFN & "Opened dialog: Rename Menu" )
716 hClickCommandButton() = true
720 ' check for the rename dialog (toolbar)
721 kontext "CustomizeToolbarsRename"
722 if ( CustomizeToolbarsRename.exists() ) then
723 printlog( CFN & "Opened dialog: Rename Toolbar" )
724 hClickCommandButton() = true
728 printlog( CFN & "Exit" )
729 hClickCommandButton() = true