'encoding UTF-8 Do not remove or change this line!
'**************************************************************
'
' Licensed to the Apache Software Foundation (ASF) under one
' or more contributor license agreements. See the NOTICE file
' distributed with this work for additional information
' regarding copyright ownership. The ASF licenses this file
' to you under the Apache License, Version 2.0 (the
' "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing,
' software distributed under the License is distributed on an
' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
' KIND, either express or implied. See the License for the
' specific language governing permissions and limitations
' under the License.
'
'**************************************************************
'*
'* short description : global update test (Standardbar)
'*
'\***************************************************************************
function hAccessStandardBar() as boolean
'///
Verify that the Standard Bar exists
'///This function works for all gApplications
'///Input:
'///
'///+- Nothing
'///
'///Returns:
'///
'///+- Errorcondition (boolean)
'///
'///+- TRUE if StandardBar exists
'///+- FALSE if standardBar does not exist
'///
'///
'///Description:
'///
const CFN = "hAccessStandardBar::"
dim brc as boolean
printlog( CFN & "Enter" )
'///+- Open a new document
hCreateDocument()
'///+- Try to access the standardbar (query .exists())
kontext "StandardBar"
if ( StandardBar.exists() ) then
if ( standardbar.isVisible() ) then
printlog( CFN & "StandardBar is visible. Good." )
brc = true
else
warnlog( "The StandardBar is not visible in " & gApplication )
brc = false
endif
else
warnlog( "The StandardBar does not exist in " & gApplication )
brc = false
endif
'///+- Close the navigator
kontext "Navigator"
hCloseDialog( Navigator, "close,optional" )
'///+- Close the document
hDestroyDocument()
hAccessStandardBar() = brc
printlog( CFN & "Exit" )
'///
end function
'*******************************************************************************
function hResetStandardBar() as boolean
'///Reset the Standard Bar to default configuration
'///Input:
'///
'///+- Nothing
'///
'///Returns:
'///
'///+- Errorcondition (boolean)
'///
'///+- Always TRUE as no errorconditions are handled yet
'///
'///
'///Description:
'///
const CFN = "hResetStandardBar::"
const MIN_STATIC_DELAY = 1
const DEFAULT_DELAY = 2
const MENUITEM_RESTORE = 1
const MENUITEM_CLOSEMENU = 0
const TOOLBAR_MENUITEM_CUSTOMIZE = 2
const EXPECTED_RESOURCE_ID = 304
printlog( CFN & "Enter" )
'///+- Create a new document
hInitSingleDoc()
printlog " - Standardbar"
kontext "standardbar"
if ( Standardbar.exists() ) then
'///+- Open the context menu on Standardbar
Standardbar.OpenContextmenu
sleep( MIN_STATIC_DELAY )
'///+- Click on 2. entry (Cutomize Toolbar)
hMenuselectNr ( TOOLBAR_MENUITEM_CUSTOMIZE )
sleep( MIN_STATIC_DELAY )
kontext
Active.SetPage TabCustomizeToolbars
sleep( MIN_STATIC_DELAY )
'///+- Toggle to 'Toolbars' tab page.
kontext "TabCustomizeToolbars"
if TabCustomizeToolbars.Exists( DEFAULT_DELAY ) then
sleep( MIN_STATIC_DELAY )
'///+- Press in first section '... Toolbars' the 'toolbar'-button
MenuBtn.Click
sleep( MIN_STATIC_DELAY )
'///+- A drop down menu will be opened.
'///+- Select the first enabled menu entry which should be 'Restore...'
hMenuSelectNr( MENUITEM_RESTORE )
sleep( MIN_STATIC_DELAY )
kontext
if ( active.exists( DEFAULT_DELAY ) ) then
if ( Active.GetRT = EXPECTED_RESOURCE_ID ) then
'///+- Press Yes button on verification dialog.
Active.Yes()
end if
else
warnlog( "No verification comes up if the RESET button has been pressed!" )
end if
'///+- Close 'Toolbars' tab page and the dialog with OK.
kontext "tabcustomizetoolbars"
hCloseDialog( TabCustomizeToolbars, "ok" )
else
warnlog( "Cutomuze Toolbar not open (from context menu)" )
'Closing the Context menu if the dialog does not come up.
Menuselect( MENUITEM_CLOSEMENU )
endif
else
warnlog( CFN & "Could not access Standardbar" )
endif
'///+- Close document.
hDestroyDocument()
hResetStandardBar() = true
printlog( CFN & "Exit" )
'///
end function
'*******************************************************************************
function hStandardbarItemGetCount() as integer
'///Update test: Get the number of items in the StandardBar
'///Starting point: Any plain document
'///Input:
'///
'///+- Nothing
'///
'///Returns:
'///
'///+- Number of items on the toolbar (integer)
'///
'///+- No errorhandling is done. Beware.
'///
'///
'///Description:
'///
dim iToolbarItemsCurrent as integer
const DEFAULT_TOOLBAR_ITEMCOUNT = 30
const WEBLOG_PUBLISHER = 2
const CFN = "hStandardbarItemGetCount::"
gApplication = "WRITER"
printlog( CFN & "Enter" )
'///+- Look for additional icons on the standardbar (through extensions)
printlog( CFN & "Count all items at the Standardbar" )
'///+- Open the context menu on the Standardbar
Kontext "Standardbar"
Standardbar.OpenContextmenu()
'///+- Select the 1. entry
hMenuselectNr( 1 )
'///+- Count all entries ( there must be 30 entries )
iToolbarItemsCurrent = 0
iToolbarItemsCurrent = hMenuItemGetCount()
' StarOffice/StarSuite come with a preinstalled extension beginning with build
' 9181. This extension is not shipped with the Solaris patches as this would
' violate Sun's patching policy. So StarSuite/StarOffice now have 30 or 31
' items on the standardbar, OOo and its spinoffs have 30.
select case ( iToolbarItemsCurrent )
case DEFAULT_TOOLBAR_ITEMCOUNT
printlog( CFN & "Default number of items found" )
case DEFAULT_TOOLBAR_ITEMCOUNT + WEBLOG_PUBLISHER
printlog( CFN & "Default icons + Weblog publisher icons found" )
case else
warnlog( CFN & "Number of icons is unexpected: " & iToolbarItemsCurrent )
end select
'///+- close the context menu
hMenuClose()
hStandardbarItemGetCount() = iToolbarItemsCurrent
printlog( CFN & "Exit" )
'///
end function
'*******************************************************************************
function hToggleToolbarItem( iMenuPos as integer )
'///Update test: Toggle an icon on the Standardbar (on/off)
'///Starting point: Any plain document
'///Input:
'///
'///+- Position of the item in the menu (integer)
'///
'///Returns:
'///
'///+- Nothing
'///
'///Description:
'///
const CFN = "hToggleToolbarItem::"
const INVISIBLE_ITEMS_MODIFIER = 3
dim iItemsInMenu as integer
printlog( CFN & "Enter with option (Menu position): " & iMenuPos )
'///+- Open the context menu of the standard bar
Kontext "Standardbar"
Standardbar.OpenContextmenu()
'///+- Retrieve the number of items in the menu
iItemsInMenu = hMenuItemGetCount()
' in case the toolbar does not fit into the window we have more items
' (those that are invisible will be listed as context menu entries),
' the menuitem (invisible items) is placed at position nItems - 3
'///+- Take the number of items -3, select the entry
hMenuselectNr( iItemsInMenu - INVISIBLE_ITEMS_MODIFIER )
'///+- Select the provided menu position
hMenuselectNr( iMenuPos )
printlog( CFN & "Exit" )
'///
end function
'*******************************************************************************
function hStandardbarLoadUrl() as boolean
'///Update test: Access the url-entryfield
'///Starting point: Any plain document
'///Input:
'///
'///+- Nothing
'///
'///Returns:
'///
'///+- Nothing
'///
'///Description:
'///
' this function tries to write to the url-EntryField. This should fail,
' because the item is not visible. Then the item should be enabled,
' written to and disabled again (no use of reset toolbar here, this is
' done in another testcase
dim iItemMenuPos as integer : iItemMenuPos = 1
const ITEM_MENU_POSITION = 1
const CFN = "hStandardbarLoadUrl::"
printlog( CFN & "Enter" )
'///+- Write to URL-Filed (fails: Entryfiled is not visible)
try
Kontext "Standardbar"
URLEingabe.settext( "Should not work" )
warnlog( CFN & "The Load URL EntryField is visible and active" )
catch
printlog( CFN & "The Load URL EntryField is not visible. Good." )
endcatch
'///+- add the control to the standardbar
printlog( CFN & "activate load URL" )
hToggleToolbarItem( ITEM_MENU_POSITION )
'///+- verify its existence by entering some text
Kontext "Standardbar"
try
URLEingabe.settext( "Should work" )
printlog( CFN & "The Load URL REntryFiled is visible and active. Good." )
catch
warnlog( CFN & "Could not write to 'load url' control" )
endcatch
'///+- remove the control from the standardbar
printlog( CFN & "Deactivate load URL" )
hToggleToolbarItem( ITEM_MENU_POSITION )
Kontext "Standardbar"
'///+- try to modify non existing object, failure expected
try
Kontext "Standardbar"
URLEingabe.settext( "Should not work" )
warnlog( CFN & "The Load URL EntryField is visible and active." )
catch
printlog( CFN & "The Load URL EntryField is not visible. Good." )
endcatch
printlog( CFN & "Exit" )
'///
end function
'*******************************************************************************
function hStandardbarNewDialog()
'///Update test: New from Template via StandardBar
'///Starting point: Plain document
'///Input:
'///
'///+- Nothing
'///
'///Returns:
'///
'///+- Nothing
'///
'///Description:
'///
const CFN = "hStandardbarNewDialog::"
const ITEM_MENU_POSITION = 3
const TEMPLATE_DIALOG_MAX_RETRIES = 3
const RC_TIMEOUT = -1
dim iTry as integer
printlog( CFN & "Enter" )
'///+- Click on "New from Template"-button (fails, it is not visible)
try
NeuDialog.Click()
warnlog( CFN & "The 'New from Template'-button should not be visible." )
catch
printlog( CFN & "The control is not present or active." )
endcatch
'///+- add the control to the standardbar
printlog( CFN & "activate New from Template button" )
hToggleToolbarItem( ITEM_MENU_POSITION )
'///+- click the button
for iTry = 1 to TEMPLATE_DIALOG_MAX_RETRIES
Kontext "Standardbar"
hClickButton( NeuDialog )
'///+- handle possible dialogs (there should never be one)
kontext "Active"
if ( active.exists() ) then
warnlog( CFN & "Unexpected active" )
printlog( CFN & active.gettext() )
if ( hCloseDialog( Active, "ok" ) = RC_TIMEOUT ) then
warnlog( CFN & "Unknown dialog blocks test, now crashing" )
endif
endif
'///+- close the templates and samples dialog
printlog( CFN & "Close templates and samples (cancel)" )
Kontext "TemplateAndDocuments"
if ( TemplateAndDocuments.Exists( 5 ) ) then
hCloseDialog( TemplateAndDocuments, "cancel" )
exit for
else
if ( iTry = TEMPLATE_DIALOG_MAX_RETRIES ) then
warnlog( CFN & "The 'Template and Documents'-dialog was not activated" )
endif
endif
next iTry
'///+- finally remove the button from the toolbar
printlog( CFN & "Deactivate New from Template button" )
hToggleToolbarItem( ITEM_MENU_POSITION )
Kontext "Standardbar"
'///
end function
'*******************************************************************************
function hStandardbarSaveAs()
'///Update test: SaveAs button on StandardBar
'///Starting point: Any plain document
'///Input:
'///
'///+- Nothing
'///
'///Returns:
'///
'///+- Nothing
'///
'///Description:
'///
dim bBreakOnError as boolean
const ITEM_MENU_POSITION = 6
const CFN = "hStandardbarSaveAs::"
printlog( CFN & "Enter" )
'///+- Click on SaveAs (fails, item is not visible)
try
SpeichernAls.Click()
catch
printlog( CFN & "The control is not present, good." )
endcatch
kontext "SpeichernDlg"
if ( SpeichernDlg.exists( 1 ) ) then
warnlog( "#i46363# (?)The 'SaveAs'-button should be invisible." )
hCloseDialog( SpeichernDlg, "cancel" )
else
'///+- Add the control to the standardbar
printlog( CFN & "Activate 'Save As' button" )
hToggleToolbarItem( ITEM_MENU_POSITION )
'///+- Click the button
Kontext "Standardbar"
hWaitForObject( SpeichernAls , 5000 )
SpeichernAls.click()
'///+- Close the save-as dialog
printlog( CFN & "Close Save As (cancel)" )
Kontext "SpeichernDlg"
if ( SpeichernDlg.Exists( 2 ) ) then
hCloseDialog( SpeichernDlg, "cancel" )
else
qaerrorlog( "Retrying" )
Kontext "Standardbar"
SpeichernAls.click()
Kontext "SpeichernDlg"
if ( SpeichernDlg.exists( 1 ) ) then
printlog( "FileSaveAs dialog is open" )
hCloseDialog( SpeichernDlg, "cancel" )
else
warnlog( CFN & "The 'Save As'-dialog was not activated" )
endif
endif
'///+- Remove the button from the toolbar
printlog( CFN & "Deactivate 'Save as' button" )
hToggleToolbarItem( ITEM_MENU_POSITION )
endif
Kontext "Standardbar"
printlog( CFN & "Exit" )
'///
end function