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 : global update test (Standardbar)
32 '\***************************************************************************
34 function hAccessStandardBar() as boolean
36 '///<h3>Verify that the Standard Bar exists</h3>
37 '///<i>This function works for all gApplications</i><br>
44 '///+<li>Errorcondition (boolean)</li>
46 '///+<li>TRUE if StandardBar exists</li>
47 '///+<li>FALSE if standardBar does not exist</li>
50 '///<u>Description</u>:
52 const CFN = "hAccessStandardBar::"
55 printlog( CFN & "Enter" )
57 '///+<li>Open a new document</li>
60 '///+<li>Try to access the standardbar (query .exists())</li>
62 if ( StandardBar.exists() ) then
63 if ( standardbar.isVisible() ) then
64 printlog( CFN & "StandardBar is visible. Good." )
67 warnlog( "The StandardBar is not visible in " & gApplication )
71 warnlog( "The StandardBar does not exist in " & gApplication )
75 '///+<li>Close the navigator</li>
77 hCloseDialog( Navigator, "close,optional" )
79 '///+<li>Close the document</li>
81 hAccessStandardBar() = brc
82 printlog( CFN & "Exit" )
87 '*******************************************************************************
89 function hResetStandardBar() as boolean
91 '///<h3>Reset the Standard Bar to default configuration</h3>
98 '///+<li>Errorcondition (boolean)</li>
100 '///+<li>Always TRUE as no errorconditions are handled yet</li>
103 '///<u>Description</u>:
106 const CFN = "hResetStandardBar::"
107 const MIN_STATIC_DELAY = 1
108 const DEFAULT_DELAY = 2
109 const MENUITEM_RESTORE = 1
110 const MENUITEM_CLOSEMENU = 0
111 const TOOLBAR_MENUITEM_CUSTOMIZE = 2
112 const EXPECTED_RESOURCE_ID = 304
115 printlog( CFN & "Enter" )
117 '///+<li>Create a new document</li>
119 printlog " - Standardbar"
121 kontext "standardbar"
122 if ( Standardbar.exists() ) then
124 '///+<li>Open the context menu on Standardbar</li>
125 Standardbar.OpenContextmenu
126 sleep( MIN_STATIC_DELAY )
128 '///+<li>Click on 2. entry (Cutomize Toolbar)</li>
129 hMenuselectNr ( TOOLBAR_MENUITEM_CUSTOMIZE )
130 sleep( MIN_STATIC_DELAY )
133 Active.SetPage TabCustomizeToolbars
134 sleep( MIN_STATIC_DELAY )
136 '///+<li>Toggle to 'Toolbars' tab page.</li>
137 kontext "TabCustomizeToolbars"
138 if TabCustomizeToolbars.Exists( DEFAULT_DELAY ) then
139 sleep( MIN_STATIC_DELAY )
141 '///+<li>Press in first section '... Toolbars' the 'toolbar'-button</li>
143 sleep( MIN_STATIC_DELAY )
145 '///+<li>A drop down menu will be opened.</li>
146 '///+<li>Select the first enabled menu entry which should be 'Restore...'</li>
147 hMenuSelectNr( MENUITEM_RESTORE )
148 sleep( MIN_STATIC_DELAY )
151 if ( active.exists( DEFAULT_DELAY ) ) then
152 if ( Active.GetRT = EXPECTED_RESOURCE_ID ) then
154 '///+<li>Press Yes button on verification dialog.</li>
158 warnlog( "No verification comes up if the RESET button has been pressed!" )
161 '///+<li>Close 'Toolbars' tab page and the dialog with OK.</li>
162 kontext "tabcustomizetoolbars"
163 hCloseDialog( TabCustomizeToolbars, "ok" )
165 warnlog( "Cutomuze Toolbar not open (from context menu)" )
166 'Closing the Context menu if the dialog does not come up.
167 Menuselect( MENUITEM_CLOSEMENU )
171 warnlog( CFN & "Could not access Standardbar" )
174 '///+<li>Close document.</li>
176 hResetStandardBar() = true
177 printlog( CFN & "Exit" )
182 '*******************************************************************************
184 function hStandardbarItemGetCount() as integer
186 '///<h3>Update test: Get the number of items in the StandardBar</h3>
187 '///<i>Starting point: Any plain document</i><br>
190 '///+<li>Nothing</li>
194 '///+<li>Number of items on the toolbar (integer)</li>
196 '///+<li>No errorhandling is done. Beware.</li>
199 '///<u>Description</u>:
202 dim iToolbarItemsCurrent as integer
203 const DEFAULT_TOOLBAR_ITEMCOUNT = 30
204 const WEBLOG_PUBLISHER = 2
206 const CFN = "hStandardbarItemGetCount::"
208 gApplication = "WRITER"
209 printlog( CFN & "Enter" )
211 '///+<li>Look for additional icons on the standardbar (through extensions)</li>
212 printlog( CFN & "Count all items at the Standardbar" )
214 '///+<li>Open the context menu on the Standardbar</li>
215 Kontext "Standardbar"
216 Standardbar.OpenContextmenu()
218 '///+<li>Select the 1. entry</li>
221 '///+<li>Count all entries ( there must be 30 entries )</li>
222 iToolbarItemsCurrent = 0
223 iToolbarItemsCurrent = hMenuItemGetCount()
225 ' StarOffice/StarSuite come with a preinstalled extension beginning with build
226 ' 9181. This extension is not shipped with the Solaris patches as this would
227 ' violate Sun's patching policy. So StarSuite/StarOffice now have 30 or 31
228 ' items on the standardbar, OOo and its spinoffs have 30.
230 select case ( iToolbarItemsCurrent )
231 case DEFAULT_TOOLBAR_ITEMCOUNT
232 printlog( CFN & "Default number of items found" )
233 case DEFAULT_TOOLBAR_ITEMCOUNT + WEBLOG_PUBLISHER
234 printlog( CFN & "Default icons + Weblog publisher icons found" )
236 warnlog( CFN & "Number of icons is unexpected: " & iToolbarItemsCurrent )
239 '///+<li>close the context menu</li>
241 hStandardbarItemGetCount() = iToolbarItemsCurrent
242 printlog( CFN & "Exit" )
247 '*******************************************************************************
249 function hToggleToolbarItem( iMenuPos as integer )
251 '///<h3>Update test: Toggle an icon on the Standardbar (on/off)</h3>
252 '///<i>Starting point: Any plain document</i><br>
255 '///+<li>Position of the item in the menu (integer)</li>
259 '///+<li>Nothing</li>
261 '///<u>Description</u>:
264 const CFN = "hToggleToolbarItem::"
265 const INVISIBLE_ITEMS_MODIFIER = 3
266 dim iItemsInMenu as integer
268 printlog( CFN & "Enter with option (Menu position): " & iMenuPos )
270 '///+<li>Open the context menu of the standard bar</li>
271 Kontext "Standardbar"
272 Standardbar.OpenContextmenu()
274 '///+<li>Retrieve the number of items in the menu</li>
275 iItemsInMenu = hMenuItemGetCount()
277 ' in case the toolbar does not fit into the window we have more items
278 ' (those that are invisible will be listed as context menu entries),
279 ' the menuitem (invisible items) is placed at position nItems - 3
280 '///+<li>Take the number of items -3, select the entry</li>
281 hMenuselectNr( iItemsInMenu - INVISIBLE_ITEMS_MODIFIER )
283 '///+<li>Select the provided menu position</li>
284 hMenuselectNr( iMenuPos )
285 printlog( CFN & "Exit" )
290 '*******************************************************************************
292 function hStandardbarLoadUrl() as boolean
294 '///<h3>Update test: Access the url-entryfield</h3>
295 '///<i>Starting point: Any plain document</i><br>
298 '///+<li>Nothing</li>
302 '///+<li>Nothing</li>
304 '///<u>Description</u>:
308 ' this function tries to write to the url-EntryField. This should fail,
309 ' because the item is not visible. Then the item should be enabled,
310 ' written to and disabled again (no use of reset toolbar here, this is
311 ' done in another testcase
313 dim iItemMenuPos as integer : iItemMenuPos = 1
315 const ITEM_MENU_POSITION = 1
316 const CFN = "hStandardbarLoadUrl::"
318 printlog( CFN & "Enter" )
320 '///+<li>Write to URL-Filed (fails: Entryfiled is not visible)</li>
322 Kontext "Standardbar"
323 URLEingabe.settext( "Should not work" )
324 warnlog( CFN & "The Load URL EntryField is visible and active" )
326 printlog( CFN & "The Load URL EntryField is not visible. Good." )
329 '///+<li>add the control to the standardbar</li>
330 printlog( CFN & "activate load URL" )
331 hToggleToolbarItem( ITEM_MENU_POSITION )
333 '///+<li>verify its existence by entering some text</li>
334 Kontext "Standardbar"
336 URLEingabe.settext( "Should work" )
337 printlog( CFN & "The Load URL REntryFiled is visible and active. Good." )
339 warnlog( CFN & "Could not write to 'load url' control" )
342 '///+<li>remove the control from the standardbar</li>
343 printlog( CFN & "Deactivate load URL" )
344 hToggleToolbarItem( ITEM_MENU_POSITION )
345 Kontext "Standardbar"
347 '///+<li>try to modify non existing object, failure expected</li>
349 Kontext "Standardbar"
350 URLEingabe.settext( "Should not work" )
351 warnlog( CFN & "The Load URL EntryField is visible and active." )
353 printlog( CFN & "The Load URL EntryField is not visible. Good." )
355 printlog( CFN & "Exit" )
360 '*******************************************************************************
362 function hStandardbarNewDialog()
364 '///<h3>Update test: New from Template via StandardBar</h3>
365 '///<i>Starting point: Plain document</i><br>
368 '///+<li>Nothing</li>
372 '///+<li>Nothing</li>
374 '///<u>Description</u>:
377 const CFN = "hStandardbarNewDialog::"
378 const ITEM_MENU_POSITION = 3
379 const TEMPLATE_DIALOG_MAX_RETRIES = 3
380 const RC_TIMEOUT = -1
384 printlog( CFN & "Enter" )
386 '///+<li>Click on "New from Template"-button (fails, it is not visible)</li>
389 warnlog( CFN & "The 'New from Template'-button should not be visible." )
391 printlog( CFN & "The control is not present or active." )
394 '///+<li>add the control to the standardbar</li>
395 printlog( CFN & "activate New from Template button" )
396 hToggleToolbarItem( ITEM_MENU_POSITION )
398 '///+<li>click the button</li>
399 for iTry = 1 to TEMPLATE_DIALOG_MAX_RETRIES
401 Kontext "Standardbar"
402 hClickButton( NeuDialog )
404 '///+<li>handle possible dialogs (there should never be one)</li>
406 if ( active.exists() ) then
407 warnlog( CFN & "Unexpected active" )
408 printlog( CFN & active.gettext() )
409 if ( hCloseDialog( Active, "ok" ) = RC_TIMEOUT ) then
410 warnlog( CFN & "Unknown dialog blocks test, now crashing" )
414 '///+<li>close the templates and samples dialog</li>
415 printlog( CFN & "Close templates and samples (cancel)" )
416 Kontext "TemplateAndDocuments"
417 if ( TemplateAndDocuments.Exists( 5 ) ) then
418 hCloseDialog( TemplateAndDocuments, "cancel" )
421 if ( iTry = TEMPLATE_DIALOG_MAX_RETRIES ) then
422 warnlog( CFN & "The 'Template and Documents'-dialog was not activated" )
429 '///+<li>finally remove the button from the toolbar</li>
430 printlog( CFN & "Deactivate New from Template button" )
431 hToggleToolbarItem( ITEM_MENU_POSITION )
432 Kontext "Standardbar"
437 '*******************************************************************************
439 function hStandardbarSaveAs()
441 '///<h3>Update test: SaveAs button on StandardBar</h3>
442 '///<i>Starting point: Any plain document</i><br>
445 '///+<li>Nothing</li>
449 '///+<li>Nothing</li>
451 '///<u>Description</u>:
455 dim bBreakOnError as boolean
457 const ITEM_MENU_POSITION = 6
458 const CFN = "hStandardbarSaveAs::"
460 printlog( CFN & "Enter" )
462 '///+<li>Click on SaveAs (fails, item is not visible)</li>
466 printlog( CFN & "The control is not present, good." )
469 kontext "SpeichernDlg"
470 if ( SpeichernDlg.exists( 1 ) ) then
471 warnlog( "#i46363# (?)The 'SaveAs'-button should be invisible." )
472 hCloseDialog( SpeichernDlg, "cancel" )
475 '///+<li>Add the control to the standardbar</li>
476 printlog( CFN & "Activate 'Save As' button" )
477 hToggleToolbarItem( ITEM_MENU_POSITION )
479 '///+<li>Click the button</li>
480 Kontext "Standardbar"
481 hWaitForObject( SpeichernAls , 5000 )
484 '///+<li>Close the save-as dialog</li>
485 printlog( CFN & "Close Save As (cancel)" )
486 Kontext "SpeichernDlg"
487 if ( SpeichernDlg.Exists( 2 ) ) then
488 hCloseDialog( SpeichernDlg, "cancel" )
490 qaerrorlog( "Retrying" )
491 Kontext "Standardbar"
493 Kontext "SpeichernDlg"
494 if ( SpeichernDlg.exists( 1 ) ) then
495 printlog( "FileSaveAs dialog is open" )
496 hCloseDialog( SpeichernDlg, "cancel" )
498 warnlog( CFN & "The 'Save As'-dialog was not activated" )
502 '///+<li>Remove the button from the toolbar</li>
503 printlog( CFN & "Deactivate 'Save as' button" )
504 hToggleToolbarItem( ITEM_MENU_POSITION )
508 Kontext "Standardbar"
509 printlog( CFN & "Exit" )