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: toolbar_tools.inc,v $
13 '* last change: $Author: obo $ $Date: 2008-07-25 09:56:35 $
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 : global update test (Standardbar)
38 '\***************************************************************************
40 function hAccessStandardBar() as boolean
42 '///<h3>Verify that the Standard Bar exists</h3>
43 '///<i>This function works for all gApplications</i><br>
50 '///+<li>Errorcondition (boolean)</li>
52 '///+<li>TRUE if StandardBar exists</li>
53 '///+<li>FALSE if standardBar does not exist</li>
56 '///<u>Description</u>:
58 const CFN = "hAccessStandardBar::"
61 printlog( CFN & "Enter" )
63 '///+<li>Open a new document</li>
66 '///+<li>Try to access the standardbar (query .exists())</li>
68 if ( StandardBar.exists() ) then
69 if ( standardbar.isVisible() ) then
70 printlog( CFN & "StandardBar is visible. Good." )
73 warnlog( "The StandardBar is not visible in " & gApplication )
77 warnlog( "The StandardBar does not exist in " & gApplication )
81 '///+<li>Close the navigator</li>
84 '///+<li>Close the document</li>
86 hAccessStandardBar() = brc
87 printlog( CFN & "Exit" )
92 '*******************************************************************************
94 function hResetStandardBar() as boolean
96 '///<h3>Reset the Standard Bar to default configuration</h3>
103 '///+<li>Errorcondition (boolean)</li>
105 '///+<li>Always TRUE as no errorconditions are handled yet</li>
108 '///<u>Description</u>:
111 const CFN = "hResetStandardBar::"
113 printlog( CFN & "Enter" )
115 '///+<li>Create a new document</li>
117 printlog " - Standardbar"
119 kontext "standardbar"
120 if ( Standardbar.exists() ) then
122 '///+<li>Open the context menu on Standardbar</li>
123 Standardbar.OpenContextmenu
126 '///+<li>Click on 2. entry (Cutomize Toolbar)</li>
131 Active.SetPage TabCustomizeToolbars
134 '///+<li>Toggle to 'Toolbars' tab page.</li>
135 kontext "TabCustomizeToolbars"
136 if TabCustomizeToolbars.Exists( 2 ) then
139 '///+<li>Press in first section '... Toolbars' the 'toolbar'-button</li>
143 '///+<li>A drop down menu will be opened.</li>
144 '///+<li>Select the first enabled menu entry which should be 'Restore...'</li>
149 if ( active.exists( 2 ) ) then
150 if Active.GetRT = 304 then
152 '///+<li>Press Yes button on verification dialog.</li>
156 warnlog( "No verification comes up if the RESET button has been pressed!" )
159 '///+<li>Close 'Toolbars' tab page and the dialog with OK.</li>
160 kontext "tabcustomizetoolbars"
161 TabCustomizeToolbars.OK
163 warnlog( "Cutomuze Toolbar not open (from context menu)" )
164 'Closing the Context menu if the dialog does not come up.
169 warnlog( CFN & "Could not access Standardbar" )
172 '///+<li>Close document.</li>
174 hResetStandardBar() = true
175 printlog( CFN & "Exit" )
180 '*******************************************************************************
182 function hStandardbarItemGetCount() as integer
184 '///<h3>Update test: Get the number of items in the StandardBar</h3>
185 '///<i>Starting point: Any plain document</i><br>
188 '///+<li>Nothing</li>
192 '///+<li>Number of items on the toolbar (integer)</li>
194 '///+<li>No errorhandling is done. Beware.</li>
197 '///<u>Description</u>:
200 dim iToolbarItemsCurrent as integer
201 dim iToolbarItemsExpected as integer
202 iToolbarItemsExpected = 30
204 const CFN = "hStandardbarItemGetCount::"
206 gApplication = "WRITER"
207 printlog( CFN & "Enter" )
209 '///+<li>Look for additional icons on the standardbar (through extensions)</li>
210 printlog( CFN & "Count all items at the Standardbar" )
212 '///+<li>Open the context menu on the Standardbar</li>
213 Kontext "Standardbar"
214 Standardbar.OpenContextmenu()
216 '///+<li>Select the 1. entry</li>
219 '///+<li>Count all entries ( there must be 30 entries )</li>
220 iToolbarItemsCurrent = 0
221 iToolbarItemsCurrent = hMenuItemGetCount()
223 ' StarOffice/StarSuite come with a preinstalled extension beginning with build
224 ' 9181. This extension is not shipped with the Solaris patches as this would
225 ' violate Sun's patching policy. So StarSuite/StarOffice now have 30 or 31
226 ' items on the standardbar, OOo and its spinoffs have 30.
229 if ( iToolbarItemsCurrent = iToolbarItemsExpected ) then
230 printlog( CFN & "Correct number of items on the StandardBar. Good" )
232 warnlog( CFN & "Expected: " & iToolbarItemsExpected & _
233 " entries, found: " & iToolbarItemsCurrent )
236 '///+<li>close the context menu</li>
238 hStandardbarItemGetCount() = iToolbarItemsCurrent
239 printlog( CFN & "Exit" )
244 '*******************************************************************************
246 function hToggleToolbarItem( iMenuPos as integer )
248 '///<h3>Update test: Toggle an icon on the Standardbar (on/off)</h3>
249 '///<i>Starting point: Any plain document</i><br>
252 '///+<li>Position of the item in the menu (integer)</li>
256 '///+<li>Nothing</li>
258 '///<u>Description</u>:
261 const CFN = "hToggleToolbarItem::"
262 dim iItemsInMenu as integer
264 printlog( CFN & "Enter with option (Menu position): " & iMenuPos )
266 '///+<li>Open the context menu of the standard bar</li>
267 Kontext "Standardbar"
268 Standardbar.OpenContextmenu()
270 '///+<li>Retrieve the number of items in the menu</li>
271 iItemsInMenu = hMenuItemGetCount()
273 ' in case the toolbar does not fit into the window we have more items
274 ' (those that are invisible will be listed as context menu entries),
275 ' the menuitem (invisible items) is placed at position nItems - 3
276 '///+<li>Take the number of items -3, select the entry</li>
277 hMenuselectNr( iItemsInMenu - 3 )
279 '///+<li>Select the provided menu position</li>
280 hMenuselectNr( iMenuPos )
281 printlog( CFN & "Exit" )
286 '*******************************************************************************
288 function hStandardbarLoadUrl() as boolean
290 '///<h3>Update test: Access the url-entryfield</h3>
291 '///<i>Starting point: Any plain document</i><br>
294 '///+<li>Nothing</li>
298 '///+<li>Nothing</li>
300 '///<u>Description</u>:
304 ' this function tries to write to the url-EntryField. This should fail,
305 ' because the item is not visible. Then the item should be enabled,
306 ' written to and disabled again (no use of reset toolbar here, this is
307 ' done in another testcase
309 dim iItemMenuPos as integer
312 const ITEM_MENU_POSITION = 1
313 const CFN = "hStandardbarLoadUrl::"
315 printlog( CFN & "Enter" )
317 '///+<li>Write to URL-Filed (fails: Entryfiled is not visible)</li>
319 Kontext "Standardbar"
320 URLEingabe.settext( "Should not work" )
321 warnlog( CFN & "The Load URL EntryField is visible and active" )
323 printlog( CFN & "The Load URL EntryField is not visible. Good." )
326 '///+<li>add the control to the standardbar</li>
327 printlog( CFN & "activate load URL" )
328 hToggleToolbarItem( ITEM_MENU_POSITION )
330 '///+<li>verify its existence by entering some text</li>
331 Kontext "Standardbar"
333 URLEingabe.settext( "Should work" )
334 printlog( CFN & "The Load URL REntryFiled is visible and active. Good." )
336 warnlog( CFN & "Could not write to 'load url' control" )
339 '///+<li>remove the control from the standardbar</li>
340 printlog( CFN & "Deactivate load URL" )
341 hToggleToolbarItem( ITEM_MENU_POSITION )
342 Kontext "Standardbar"
344 '///+<li>try to modify non existing object, failure expected</li>
346 Kontext "Standardbar"
347 URLEingabe.settext( "Should not work" )
348 warnlog( CFN & "The Load URL EntryField is visible and active." )
350 printlog( CFN & "The Load URL EntryField is not visible. Good." )
352 printlog( CFN & "Exit" )
357 '*******************************************************************************
359 function hStandardbarNewDialog()
361 '///<h3>Update test: New from Template via StandardBar</h3>
362 '///<i>Starting point: Plain document</i><br>
365 '///+<li>Nothing</li>
369 '///+<li>Nothing</li>
371 '///<u>Description</u>:
374 const CFN = "hStandardbarNewDialog::"
375 const ITEM_MENU_POSITION = 3
377 printlog( CFN & "Enter" )
379 '///+<li>Click on "New from Template"-button (fails, it is not visible)</li>
382 warnlog( CFN & "The 'New from Template'-button should not be visible." )
384 printlog( CFN & "The control is not present or active." )
387 '///+<li>add the control to the standardbar</li>
388 printlog( CFN & "activate New from Template button" )
389 hToggleToolbarItem( ITEM_MENU_POSITION )
391 '///+<li>click the button</li>
392 Kontext "Standardbar"
399 '///+<li>handle possible dialogs (there should never be one)</li>
401 if ( active.exists( 1 ) ) then
402 warnlog( CFN & "Unexpected active" )
403 printlog( CFN & active.gettext() )
405 printlog( CFN & "Closing dialog" )
408 warnlog( CFN & "Unknown dialog blocks test, now crashing" )
412 '///+<li>close the templates and samples dialog</li>
413 printlog( CFN & "Close templates and samples (cancel)" )
414 Kontext "TemplateAndDocuments"
415 if ( TemplateAndDocuments.Exists( 5 ) ) then
416 TemplateAndDocuments.cancel()
418 warnlog( CFN & "The 'Template and Documents'-dialog was not activated" )
421 '///+<li>finally remove the button from the toolbar</li>
422 printlog( CFN & "Deactivate New from Template button" )
423 hToggleToolbarItem( ITEM_MENU_POSITION )
424 Kontext "Standardbar"
429 '*******************************************************************************
431 function hStandardbarSaveAs()
433 '///<h3>Update test: SaveAs button on StandardBar</h3>
434 '///<i>Starting point: Any plain document</i><br>
437 '///+<li>Nothing</li>
441 '///+<li>Nothing</li>
443 '///<u>Description</u>:
447 dim bBreakOnError as boolean
449 const ITEM_MENU_POSITION = 6
450 const CFN = "hStandardbarSaveAs::"
452 printlog( CFN & "Enter" )
454 '///+<li>Click on SaveAs (fails, item is not visible)</li>
458 printlog( CFN & "The control is not present, good." )
461 kontext "SpeichernDlg"
462 if ( SpeichernDlg.exists( 1 ) ) then
463 warnlog( "#i46363# (?)The 'SaveAs'-button should be invisible." )
464 SpeichernDlg.cancel()
467 '///+<li>Add the control to the standardbar</li>
468 printlog( CFN & "Activate 'Save As' button" )
469 hToggleToolbarItem( ITEM_MENU_POSITION )
471 '///+<li>Click the button</li>
472 Kontext "Standardbar"
473 hWaitForObject( SpeichernAls , 5000 )
476 '///+<li>Close the save-as dialog</li>
477 printlog( CFN & "Close Save As (cancel)" )
478 Kontext "SpeichernDlg"
479 if ( SpeichernDlg.Exists( 2 ) ) then
480 SpeichernDlg.cancel()
482 qaerrorlog( "Retrying" )
483 Kontext "Standardbar"
485 Kontext "SpeichernDlg"
486 if ( SpeichernDlg.exists( 1 ) ) then
487 printlog( "FileSaveAs dialog is open" )
488 SpeichernDlg.cancel()
490 warnlog( CFN & "The 'Save As'-dialog was not activated" )
494 '///+<li>Remove the button from the toolbar</li>
495 printlog( CFN & "Deactivate 'Save as' button" )
496 hToggleToolbarItem( ITEM_MENU_POSITION )
500 Kontext "Standardbar"
501 printlog( CFN & "Exit" )