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
138 '///+<li>Press in first section '... Toolbars' the 'toolbar'-button</li>
142 '///+<li>A drop down menu will be opened.</li>
143 '///+<li>Select the first enabled menu entry which should be 'Restore...'</li>
148 if ( active.exists( 2 ) ) then
149 if Active.GetRT = 304 then
151 '///+<li>Press Yes button on verification dialog.</li>
155 warnlog( "No verification comes up if the RESET button has been pressed!" )
158 '///+<li>Close 'Toolbars' tab page and the dialog with OK.</li>
159 kontext "tabcustomizetoolbars"
160 TabCustomizeToolbars.OK
162 warnlog( "Cutomuze Toolbar not open (from context menu)" )
163 'Closing the Context menu if the dialog does not come up.
168 warnlog( CFN & "Could not access Standardbar" )
171 '///+<li>Close document.</li>
173 hResetStandardBar() = true
174 printlog( CFN & "Exit" )
179 '*******************************************************************************
181 function hStandardbarItemGetCount() as integer
183 '///<h3>Update test: Get the number of items in the StandardBar</h3>
184 '///<i>Starting point: Any plain document</i><br>
187 '///+<li>Nothing</li>
191 '///+<li>Number of items on the toolbar (integer)</li>
193 '///+<li>No errorhandling is done. Beware.</li>
196 '///<u>Description</u>:
199 dim iToolbarItemsCurrent as integer
200 dim iToolbarItemsExpected as integer
201 iToolbarItemsExpected = 30
203 const CFN = "hStandardbarItemGetCount::"
205 gApplication = "WRITER"
206 printlog( CFN & "Enter" )
208 '///+<li>Look for additional icons on the standardbar (through extensions)</li>
209 printlog( CFN & "Count all items at the Standardbar" )
211 '///+<li>Open the context menu on the Standardbar</li>
212 Kontext "Standardbar"
213 Standardbar.OpenContextmenu()
215 '///+<li>Select the 1. entry</li>
218 '///+<li>Count all entries ( there must be 30 entries )</li>
219 iToolbarItemsCurrent = 0
220 iToolbarItemsCurrent = hMenuItemGetCount()
222 ' StarOffice/StarSuite come with a preinstalled extension beginning with build
223 ' 9181. This extension is not shipped with the Solaris patches as this would
224 ' violate Sun's patching policy. So StarSuite/StarOffice now have 30 or 31
225 ' items on the standardbar, OOo and its spinoffs have 30.
228 if ( iToolbarItemsCurrent = iToolbarItemsExpected ) then
229 printlog( CFN & "Correct number of items on the StandardBar. Good" )
231 warnlog( CFN & "Expected: " & iToolbarItemsExpected & _
232 " entries, found: " & iToolbarItemsCurrent )
235 '///+<li>close the context menu</li>
237 hStandardbarItemGetCount() = iToolbarItemsCurrent
238 printlog( CFN & "Exit" )
243 '*******************************************************************************
245 function hToggleToolbarItem( iMenuPos as integer )
247 '///<h3>Update test: Toggle an icon on the Standardbar (on/off)</h3>
248 '///<i>Starting point: Any plain document</i><br>
251 '///+<li>Position of the item in the menu (integer)</li>
255 '///+<li>Nothing</li>
257 '///<u>Description</u>:
260 const CFN = "hToggleToolbarItem::"
261 dim iItemsInMenu as integer
263 printlog( CFN & "Enter with option (Menu position): " & iMenuPos )
265 '///+<li>Open the context menu of the standard bar</li>
266 Kontext "Standardbar"
267 Standardbar.OpenContextmenu()
269 '///+<li>Retrieve the number of items in the menu</li>
270 iItemsInMenu = hMenuItemGetCount()
272 ' in case the toolbar does not fit into the window we have more items
273 ' (those that are invisible will be listed as context menu entries),
274 ' the menuitem (invisible items) is placed at position nItems - 3
275 '///+<li>Take the number of items -3, select the entry</li>
276 hMenuselectNr( iItemsInMenu - 3 )
278 '///+<li>Select the provided menu position</li>
279 hMenuselectNr( iMenuPos )
280 printlog( CFN & "Exit" )
285 '*******************************************************************************
287 function hStandardbarLoadUrl() as boolean
289 '///<h3>Update test: Access the url-entryfield</h3>
290 '///<i>Starting point: Any plain document</i><br>
293 '///+<li>Nothing</li>
297 '///+<li>Nothing</li>
299 '///<u>Description</u>:
303 ' this function tries to write to the url-EntryField. This should fail,
304 ' because the item is not visible. Then the item should be enabled,
305 ' written to and disabled again (no use of reset toolbar here, this is
306 ' done in another testcase
308 dim iItemMenuPos as integer
311 const ITEM_MENU_POSITION = 1
312 const CFN = "hStandardbarLoadUrl::"
314 printlog( CFN & "Enter" )
316 '///+<li>Write to URL-Filed (fails: Entryfiled is not visible)</li>
318 Kontext "Standardbar"
319 URLEingabe.settext( "Should not work" )
320 warnlog( CFN & "The Load URL EntryField is visible and active" )
322 printlog( CFN & "The Load URL EntryField is not visible. Good." )
325 '///+<li>add the control to the standardbar</li>
326 printlog( CFN & "activate load URL" )
327 hToggleToolbarItem( ITEM_MENU_POSITION )
329 '///+<li>verify its existence by entering some text</li>
330 Kontext "Standardbar"
332 URLEingabe.settext( "Should work" )
333 printlog( CFN & "The Load URL REntryFiled is visible and active. Good." )
335 warnlog( CFN & "Could not write to 'load url' control" )
338 '///+<li>remove the control from the standardbar</li>
339 printlog( CFN & "Deactivate load URL" )
340 hToggleToolbarItem( ITEM_MENU_POSITION )
341 Kontext "Standardbar"
343 '///+<li>try to modify non existing object, failure expected</li>
345 Kontext "Standardbar"
346 URLEingabe.settext( "Should not work" )
347 warnlog( CFN & "The Load URL EntryField is visible and active." )
349 printlog( CFN & "The Load URL EntryField is not visible. Good." )
351 printlog( CFN & "Exit" )
356 '*******************************************************************************
358 function hStandardbarNewDialog()
360 '///<h3>Update test: New from Template via StandardBar</h3>
361 '///<i>Starting point: Plain document</i><br>
364 '///+<li>Nothing</li>
368 '///+<li>Nothing</li>
370 '///<u>Description</u>:
373 const CFN = "hStandardbarNewDialog::"
374 const ITEM_MENU_POSITION = 3
376 printlog( CFN & "Enter" )
378 '///+<li>Click on "New from Template"-button (fails, it is not visible)</li>
381 warnlog( CFN & "The 'New from Template'-button should not be visible." )
383 printlog( CFN & "The control is not present or active." )
386 '///+<li>add the control to the standardbar</li>
387 printlog( CFN & "activate New from Template button" )
388 hToggleToolbarItem( ITEM_MENU_POSITION )
390 '///+<li>click the button</li>
391 Kontext "Standardbar"
398 '///+<li>handle possible dialogs (there should never be one)</li>
400 if ( active.exists( 1 ) ) then
401 warnlog( CFN & "Unexpected active" )
402 printlog( CFN & active.gettext() )
404 printlog( CFN & "Closing dialog" )
407 warnlog( CFN & "Unknown dialog blocks test, now crashing" )
411 '///+<li>close the templates and samples dialog</li>
412 printlog( CFN & "Close templates and samples (cancel)" )
413 Kontext "TemplateAndDocuments"
414 if ( TemplateAndDocuments.Exists( 5 ) ) then
415 TemplateAndDocuments.cancel()
417 warnlog( CFN & "The 'Template and Documents'-dialog was not activated" )
420 '///+<li>finally remove the button from the toolbar</li>
421 printlog( CFN & "Deactivate New from Template button" )
422 hToggleToolbarItem( ITEM_MENU_POSITION )
423 Kontext "Standardbar"
428 '*******************************************************************************
430 function hStandardbarSaveAs()
432 '///<h3>Update test: SaveAs button on StandardBar</h3>
433 '///<i>Starting point: Any plain document</i><br>
436 '///+<li>Nothing</li>
440 '///+<li>Nothing</li>
442 '///<u>Description</u>:
446 dim bBreakOnError as boolean
448 const ITEM_MENU_POSITION = 6
449 const CFN = "hStandardbarSaveAs::"
451 printlog( CFN & "Enter" )
453 '///+<li>Click on SaveAs (fails, item is not visible)</li>
457 printlog( CFN & "The control is not present, good." )
460 kontext "SpeichernDlg"
461 if ( SpeichernDlg.exists( 1 ) ) then
462 warnlog( "#i46363# (?)The 'SaveAs'-button should be invisible." )
463 SpeichernDlg.cancel()
466 '///+<li>Add the control to the standardbar</li>
467 printlog( CFN & "Activate 'Save As' button" )
468 hToggleToolbarItem( ITEM_MENU_POSITION )
470 '///+<li>Click the button</li>
471 Kontext "Standardbar"
472 hWaitForObject( SpeichernAls , 5000 )
476 warnlog( CFN & "Failed to add SaveAs button" )
479 '///+<li>Close the save-as dialog</li>
480 printlog( CFN & "Close Save As (cancel)" )
481 Kontext "SpeichernDlg"
482 if ( SpeichernDlg.Exists( 5 ) ) then
483 SpeichernDlg.cancel()
485 warnlog( CFN & "The 'Save As'-dialog was not activated" )
488 '///+<li>Remove the button from the toolbar</li>
489 printlog( CFN & "Deactivate 'Save as' button" )
490 hToggleToolbarItem( ITEM_MENU_POSITION )
494 Kontext "Standardbar"
495 printlog( CFN & "Exit" )