diff options
Diffstat (limited to 'testautomation/framework/tools/includes')
16 files changed, 5399 insertions, 0 deletions
diff --git a/testautomation/framework/tools/includes/CJK_tools.inc b/testautomation/framework/tools/includes/CJK_tools.inc new file mode 100644 index 000000000000..38664ef78501 --- /dev/null +++ b/testautomation/framework/tools/includes/CJK_tools.inc @@ -0,0 +1,325 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : hercule.li@oracle.com +'* +'* short description : Tools for CJK feature test in Writer +'* +'\*********************************************************************** + +function CheckAsianLanguageSupport( sSupport as String ) as String + + ToolsOptions + Call hToolsOptions("LANGUAGESETTINGS","LANGUAGES") + + if ( aktivieren.exists() ) then + if ( aktivieren.isEnabled() ) then + if ( lcase( sSupport ) = "on" ) then + printlog( "Enabling Asian Language Support" ) + Aktivieren.Check + else + printlog( "Disabling Asian Language Support" ) + Aktivieren.uncheck() + endif + else + warnlog( "Activate Asian Language Support checkbox is disabled" ) + endif + else + warnlog( "Activate Asian Language Support checkbox is missing" ) + endif + + Kontext "ExtrasOptionenDlg" + ExtrasOptionenDlg.OK() + +end function + +'******************************************************************************' + +function fStartupNavigator(navigatorItem as String , subItemNum as Integer) + Dim j as Integer + + Kontext "Navigator" + if NOT Navigator.Exists then + ' If you don' t ask for the Navigator and it's open it would be clodes and test fails ! + ViewNavigator + end if + Kontext "NavigatorWriter" + if Auswahlliste.GetItemCount < 11 then + Inhaltsansicht.Click + end if + if Auswahlliste.GetItemCount > 11 then + For j= 1 to 1 + Auswahlliste.Select j + Auswahlliste.TypeKeys "-" + next j + end if + Kontext "NavigatorWriter" + Auswahlliste.TypeKeys "<Up>", 11 + sleep 1 + Select case navigatorItem + case "Headings" : goto GoON + case "Tables" : Auswahlliste.TypeKeys "<down>" + case "TextFrame" : Auswahlliste.TypeKeys "<down>" , 2 + case "Graphics" : Auswahlliste.TypeKeys "<down>" , 3 + case "OLEObject" : Auswahlliste.TypeKeys "<down>" , 4 + case "Bookmarks" : Auswahlliste.TypeKeys "<down>" , 5 + case "Section" : Auswahlliste.TypeKeys "<down>" , 6 + case "Hyperlinks" : Auswahlliste.TypeKeys "<down>" , 7 + case "References" : Auswahlliste.TypeKeys "<down>" , 8 + case "Indexes" : Auswahlliste.TypeKeys "<down>" , 9 + case "Notes" : Auswahlliste.TypeKeys "<down>" , 10 + case "DrawObjects" : Auswahlliste.TypeKeys "<down>" , 11 + end Select + sleep 1 + GoON: + Auswahlliste.TypeKeys "<return>" + sleep 1 + Toolbox.Click Inhaltsansicht + sleep 1 + Auswahlliste.TypeKeys "<Up>",subItemNum + sleep 1 +end function + +'******************************************************************************' + +function fGetCountryName( CountryID as Integer ) as String + + select case iSprache + case 01 : ' English (USA) + select case CountryID + case 1: fGetCountryName = "English (USA)" + case 33: fGetCountryName = "French (France)" + case 34: fGetCountryName = "Spanish (Spain)" + case 39: fGetCountryName = "Italian (Italy)" + case 46: fGetCountryName = "Swedish (Sweden)" + case 49: fGetCountryName = "German (Germany)" + case 55: fGetCountryName = "Portuguese (Brazil)" + case 81: fGetCountryName = "Japanese" + case 82: fGetCountryName = "Korean (RoK)" + case 86: fGetCountryName = "Chinese (simplified)" + case 88: fGetCountryName = "Chinese (traditional)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 33 : ' France + select case CountryID + case 1: fGetCountryName = "Anglais (U.S.A.)" + case 33: fGetCountryName = "Français (France)" + case 34: fGetCountryName = "Espagnol (Espagne)" + case 39: fGetCountryName = "Italien (Italie)" + case 46: fGetCountryName = "Suédois (Suède)" + case 49: fGetCountryName = "Allemand (Allemagne)" + case 55: fGetCountryName = "Portugais (Brésil)" + case 81: fGetCountryName = "Japonais" + case 82: fGetCountryName = "Coréen" + case 86: fGetCountryName = "Chinois (simple)" + case 88: fGetCountryName = "Chinois (traditionnel)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 34 : ' Spanish + select case CountryID + case 1: fGetCountryName = "Inglés (EE.UU.)" + case 33: fGetCountryName = "Francés (Francia)" + case 34: fGetCountryName = "Español (España)" + case 39: fGetCountryName = "Italiano (Italia)" + case 46: fGetCountryName = "Sueco (Suecia)" + case 49: fGetCountryName = "Alemán (Alemania)" + case 55: fGetCountryName = "Portugués (Brasil)" + case 81: fGetCountryName = "Japonés" + case 82: fGetCountryName = "Coreano" + case 86: fGetCountryName = "Chino (simple)" + case 88: fGetCountryName = "Chino (tradicional)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 39 : ' Italy + select case CountryID + case 1: fGetCountryName = "Inglese (US)" + case 33: fGetCountryName = "Francese (Francia)" + case 34: fGetCountryName = "Spagnolo (Spagna)" + case 39: fGetCountryName = "Italiano (Italia)" + case 46: fGetCountryName = "Svedese (Svezia)" + case 49: fGetCountryName = "Tedesco (Germania)" + case 55: fGetCountryName = "Portoghese (Brasile)" + case 81: fGetCountryName = "Giapponese" + case 82: fGetCountryName = "Coreano" + case 86: fGetCountryName = "Cinese (semplificato)" + case 88: fGetCountryName = "Cinese (tradizionale)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 46 : ' Swedish + select case CountryID + case 1: fGetCountryName = "engelska" + case 33: fGetCountryName = "franska (Frankrike)" + case 34: fGetCountryName = "spanska (Spanien)" + case 39: fGetCountryName = "italienska (Italien)" + case 46: fGetCountryName = "svenska (Sverige)" + case 49: fGetCountryName = "tyska (Tyskland)" + case 55: fGetCountryName = "portugisiska (Brasilien)" + case 81: fGetCountryName = "Japanska" + case 82: fGetCountryName = "koreanska" + case 86: fGetCountryName = "kinesiska (enkel)" + case 88: fGetCountryName = "kinesiska (trad.)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 49 : ' German + select case CountryID + case 1: fGetCountryName = "Englisch (USA)" + case 33: fGetCountryName = "Französisch (Frankreich)" + case 34: fGetCountryName = "Spanisch (Spanien)" + case 39: fGetCountryName = "Italienisch (Italien)" + case 46: fGetCountryName = "Schwedisch (Schweden)" + case 49: fGetCountryName = "Deutsch (Deutschland)" + case 55: fGetCountryName = "Portugiesisch (Brasilien)" + case 81: fGetCountryName = "Japanisch" + case 82: fGetCountryName = "Koreanisch (RoK)" + case 86: fGetCountryName = "Chinesisch (einfach)" + case 88: fGetCountryName = "Chinesisch (Trad.)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 50 : ' Slovenian + select case CountryID + case 1: fGetCountryName = "angleški (ZDA)" + case 33: fGetCountryName = "francoski (Francija)" + case 34: fGetCountryName = "španski (Španija)" + case 39: fGetCountryName = "italijanski (Italija)" + case 46: fGetCountryName = "švedski (Švedska)" + case 49: fGetCountryName = "nemški (Nemčija)" + case 55: fGetCountryName = "portugalski (Brazilija)" + case 81: fGetCountryName = "japonski" + case 82: fGetCountryName = "korejski (RK)" + case 86: fGetCountryName = "kitajski (poenostavljeni)" + case 88: fGetCountryName = "kitajski (tradicionalni)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 55 : ' Portuguese + select case CountryID + case 1: fGetCountryName = "Inglês (EUA)" + case 33: fGetCountryName = "Francês (França)" + case 34: fGetCountryName = "Espanhol (Espanha)" + case 39: fGetCountryName = "Italiano (Itália)" + case 46: fGetCountryName = "Sueco (Suécia)" + case 49: fGetCountryName = "Alemão (Alemanha)" + case 55: fGetCountryName = "Português (Brasil)" + case 81: fGetCountryName = "Japonês" + case 82: fGetCountryName = "Coreano (RoK)" + case 86: fGetCountryName = "Chinês (simplificado)" + case 88: fGetCountryName = "Chinês (tradicional)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 81 : ' Japanese + select case CountryID + case 1: fGetCountryName = "英語(米国)" + case 33: fGetCountryName = "フランス語(フランス)" + case 34: fGetCountryName = "スペイン語(スペイン)" + case 39: fGetCountryName = "イタリア語(イタリア)" + case 46: fGetCountryName = "スウェーデン語(スウェーデン)" + case 49: fGetCountryName = "ドイツ語(ドイツ)" + case 55: fGetCountryName = "ポルトガル語(ブラジル)" + case 81: fGetCountryName = "日本語" + case 82: fGetCountryName = "韓国語" + case 86: fGetCountryName = "中国語(簡体字)" + case 88: fGetCountryName = "中国語(繁体字)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 82 : ' Korean + select case CountryID + case 1: fGetCountryName = "영어(미국)" + case 33: fGetCountryName = "스페인어(스페인)" + case 34: fGetCountryName = "프랑스어(프랑스)" + case 39: fGetCountryName = "이탈리아어 (이태리)" + case 46: fGetCountryName = "스웨덴어(스웨덴)" + case 49: fGetCountryName = "독일어(독일)" + case 55: fGetCountryName = "포르투갈어(브라질)" + case 81: fGetCountryName = "일본어" + case 82: fGetCountryName = "한국어" + case 86: fGetCountryName = "중국어(간체)" + case 88: fGetCountryName = "중국어(번체)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case 86 : ' Chinese (simplified) + select case CountryID + case 1: fGetCountryName = "英语(美国)" + case 33: fGetCountryName = "法语(法国)" + case 34: fGetCountryName = "西班牙语(西班牙)" + case 39: fGetCountryName = "意大利语(意大利)" + case 46: fGetCountryName = "瑞典语(瑞典)" + case 49: fGetCountryName = "德语(德国)" + case 55: fGetCountryName = "葡萄牙语(巴西)" + case 81: fGetCountryName = "日语" + case 82: fGetCountryName = "朝鲜语" + case 86: fGetCountryName = "中文(简体字)" + case 88: fGetCountryName = "中文(繁体字)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + + case 88 : ' Chinese (traditional) + select case CountryID + case 1: fGetCountryName = "英語(美國)" + case 33: fGetCountryName = "法語(法國)" + case 34: fGetCountryName = "西班牙語(西班牙)" + case 39: fGetCountryName = "意大利語(意大利)" + case 46: fGetCountryName = "瑞典語(瑞典)" + case 49: fGetCountryName = "德語(德國)" + case 55: fGetCountryName = "葡萄牙語(巴西)" + case 81: fGetCountryName = "日文" + case 82: fGetCountryName = "韓語" + case 86: fGetCountryName = "中文(簡體字)" + case 88: fGetCountryName = "中文(繁體)" + case else : + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + case else : ' Fallback + QAErrorLog "Now, the test does not support for the language " +iSprache + fGetCountryName = "" + end select + +end function + + + diff --git a/testautomation/framework/tools/includes/customize_tools.inc b/testautomation/framework/tools/includes/customize_tools.inc new file mode 100644 index 000000000000..0237990a3166 --- /dev/null +++ b/testautomation/framework/tools/includes/customize_tools.inc @@ -0,0 +1,186 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Tools to ease the use of the ToolsCustomize-Dialog +'* +'\****************************************************************************** + +function hToolsCustomizeOpen() as boolean + + printlog( "Open Tools/Customize dialog" ) + ToolsCustomize + hToolsCustomizeOpen() = hToolsCustomizeSelectTab( "Events" ) + +end function + +'******************************************************************************* + +function hToolsCustomizeSelectTab( cTab as string ) as boolean + + '///<h3>Switch Tabpages on ToolsCustomize Dialog</h3> + '///<i>Starting point: The Tools/Customize dialog</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Name of the Tab (string)</li> + '///<ul> + '///+<li>"Keyboard"</li> + '///+<li>"Menu"</li> + '///+<li>"Toolbars"</li> + '///+<li>"Events"</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorstatus (boolean)</li> + '///<ul> + '///+<li>TRUE if the requested tab is open</li> + '///+<li>FALSE on any other condition</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hToolsCustomizeSelectTab::" + hToolsCustomizeSelectTab() = true + ctab = lcase( ctab ) + + '///+<li>Switch to one of the four available tabpages</li> + '///<ol> + + printlog( "Open Tools/Customize: <" & ctab & ">" ) + kontext + + try + select case ctab + '///+<li>Keyboard</li> + case "keyboard" : + active.setPage TabTastatur + WaitSlot + kontext "TabTastatur" + if ( not Aendern.isVisible() ) then + printlog( CFN & "Keyboard tabpage is not available" ) + hToolsCustomizeSelectTab() = false + endif + '///+<li>Menu</li> + case "menu" : + active.setPage TabCustomizeMenu + WaitSlot + kontext "TabCustomizeMenu" + if ( not Entries.isVisible() ) then + printlog( CFN & "Menu tabpage is not available" ) + hToolsCustomizeSelectTab() = false + endif + '///+<li>Toolbars</li> + case "toolbars" : + active.setPage TabCustomizeToolbars + WaitSlot + kontext "TabCustomizeToolbars" + if ( not ToolbarContents.isVisible() ) then + printlog( CFN & "Toolbar tabpage is not available" ) + hToolsCustomizeSelectTab() = false + endif + '///+<li>Events</li> + case "events" : + active.setPage TabCustomizeEvents + WaitSlot + kontext "TabCustomizeEvents" + if ( not AssignMacro.isVisible() ) then + printlog( CFN & "Assign Macro tabpage is not available" ) + hToolsCustomizeSelectTab() = false + endif + end select + '///</ol> + catch + printlog( CFN & "Could not access requested tabpage" ) + hToolsCustomizeSelectTab() = false + endcatch + '///</ul> + +end function + +'******************************************************************************* + +function hDeselectSeparator() as integer + + '///<h3>Make sure that we do not work on a separator item (Toolbars)</h3> + '///<i>Starting point: Tools/Customize: Toolbars must be open</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Position of the selected item (integer)</li> + '///<ul> + '///+<li>Always > 1</li> + '///+<li>Always < Max number of items</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + + dim iCurrentItem as integer + dim cString as string + dim irc as integer + const CFN = "hDeselectSeparator::" + + kontext "ToolsCustomizeToolbars" + if ( ToolbarContents.getItemCount > 0 ) then + + iCurrentItem = ToolbarContents.getSelIndex() + cString = ToolbarContents.getSelText() + + '///+<li>Check whether the selected item contains a number of minus-chars (---)</li> + if ( instr( cString , "----" ) ) then + + '///+<li>If we are at the beginning of the list: Move up</li> + if ( iCurrentItem = 1 ) then + irc = 2 + ToolbarContents.select( irc ) + printlog( CFN & " Moved away from separator (up)" ) + else + '///+<li>If we are somewhere else in the list, move down</li> + irc = iCurrentItem - 1 + ToolbarContents.select( irc ) + printlog( CFN & " Moved away from separator (down)" ) + endif + + endif + else + irc = 0 + endif + + hDeselectSeparator() = irc + '///</ul> + +end function + +'******************************************************************************* + diff --git a/testautomation/framework/tools/includes/fileoperations.inc b/testautomation/framework/tools/includes/fileoperations.inc new file mode 100644 index 000000000000..1ba484df58af --- /dev/null +++ b/testautomation/framework/tools/includes/fileoperations.inc @@ -0,0 +1,723 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : check the internal file dialog ( extended tests ) +'* +'\****************************************************************************** + +function hSaveLoadDelSuccess( cFile as string ) as integer + + '///<h3>Successfully save, close, load, close and delete a file</h3> + '///<i>Uses</i>: framework\tools\t_stringtools.inc<br><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Filename incl. extension (string)</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcode (integer)</li> + '///<ul> + '///+<li>0 = all ok</li> + '///+<li>1 = Saving failed</li> + '///+<li>2 = Closing the file failed</li> + '///+<li>3 = Reloading failed</li> + '///+<li>4 = Closing the file failed</li> + '///+<li>5 = Deleting failed</li> + '///+<li>-1 = Post operation error</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim brc as boolean + dim cFileExt as string : cFileExt = cFile & hGetSuffix( "current" ) + + const CFN = "hSaveLoadDelSuccess::" + + printlog( "" ) + printlog( CFN & "Enter with option: " & cFile & "/" & cFileExt ) + + '///+<li>Close the navigator if it exists</li> + kontext "Navigator" + hCloseDialog( Navigator, "close,optional" ) + + '///+<li>Save the current file, overwriting existing</li> + brc = hSaveFileExpectSuccess( cFile , TRUE ) ' save and overwrite + if ( brc ) then + + '///+<li>Close the file</li> + brc = hDestroyDocument() + if ( brc ) then + + '///+<li>Reload the file</li> + brc = hLoadFileExpectSuccess( cFileExt ) + if ( brc ) then + + '///+<li>Close the document</li> + brc = hDestroyDocument() + if ( brc ) then + + '///+<li>Delete the file via FileOpen</li> + brc = hDeleteFileViaFileOpen( cFileExt ) + if ( brc ) then + printlog( CFN & "Save, close, load, close, delete ok" ) + hSaveLoadDelSuccess() = 0 + else + warnlog( CFN & "Failed to delete file" ) + hSaveLoadDelSuccess() = 5 + endif + + else + warnlog( CFN & "Failed to close file" ) + hSaveLoadDelSuccess() = 4 + endif + + else + warnlog( CFN & "Failed to load file" ) + hSaveLoadDelSuccess() = 3 + endif + + + else + warnlog( CFN & "Closing file failed" ) + hSaveLoadDelSuccess() = 2 + endif + + else + warnlog( CFN & "Saving failed" ) + hSaveLoadDelSuccess() = 1 + endif + + '///+<li>Close possible Messagebox (#i33946#)</li> + kontext "active" + if ( active.exists( 1 ) ) then + printlog( CFN & "Unexpected message: " & active.getText() ) + qaerrorlog( "#i33946# - message when deleting last document in folder" ) + active.ok() + hSaveLoadDelSuccess() = 6 + endif + + '///+<li>Close document</li> + brc = hDestroyDocument() + + '///</ul> + +end function + +'******************************************************************************* + +function hLoadFileExpectSuccess( fpath as string ) as boolean + + '///<h3>Load a file where failure is expected</h3> + '///<i>Uses</i>: framework\tools\t_stringtools.inc<br><br> + '///<i>This function is quite similar to hLoadFile but does much less + '///+ errorhandling so the information of the type of failure is a little + '///+ more exact</i><br><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Filename incl. extension (string)</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE = File was loaded without problems</li> + '///+<li>FALSE = Any error</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim brc as boolean : brc = true + + const CFN = "hLoadFileExpectSuccess::" + printlog( CFN & "Enter with option: " & fpath ) + + '///+<li>Click FileOpen (or use the menu)</li> + hUseAsyncSlot( "FileOpen" ) + + '///+<li>Enter the filename (with extension)</li> + 'printlog( " - Type the filepath/name into the entryfield" ) + Kontext "OeffnenDLG" + if ( OeffnenDlg.exists( 1 ) ) then + DateiName.setText( fpath ) + + '///+<li>Click "Open"</li> + 'printlog( " - Click 'Open'" ) + oeffnen.click() + + '///+<li>Watch out for an unexpected messagebox<br> + Kontext "Active" + if ( Active.Exists( 1 ) ) then + printlog( "Unexpected active: " & active.getText() ) + Active.OK() + + Kontext "OeffnenDLG" + OeffnenDLG.cancel() + brc = false + endif + + '///+recover in case of error so the test has a chance to continue</li> + ' try to recover in case of failure so the test can continue. + Kontext "OeffnenDLG" + if ( Oeffnen.exists( 1 ) ) then + warnlog( "The file was not opened, it doesn't appear to exist" ) + OeffnenDLG.cancel() + brc = false + endif + else + warnlog( CFN & "File Open dialog did not open" ) + endif + + '///+<li>Return the errorcode</li> + printlog( CFN & "Exit with result: " & brc ) + hLoadFileExpectSuccess() = brc + '///</ul> + +end function + +'******************************************************************************* + +function hSaveFileExpectSuccess( fpath as string , bReplace as boolean ) as boolean + + '///<h3>Save a file with optional replace where success is expected</h3> + '///<i>Uses</i>: framework\tools\t_stringtools.inc<br><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Filename incl. extension (string)</li> + '///+<li>Replace file (boolean)</li> + '///<ul> + '///+<li>TRUE = Replace the file</li> + '///+<li>FALSE = Do not replace the file</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE = There was an error loading the file (as expected)</li> + '///+<li>FALSE = The file was loaded without problems/any other error</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hSaveFileExpectSuccess::" + dim brc as boolean : brc = true + + dim iDocumentCount as integer + + printlog( CFN & "Enter with options: " & fpath & ", " & bReplace ) + + '///+<li>Make sure we start from the backing window</li> + hFileCloseAll() + + + '///+<li>Open a new document</li> + hCreateDocument() + + '///+<li>Click "Save As..."</li> + hUseAsyncSlot( "FileSaveAs" ) + + Kontext "SpeichernDlg" + if ( SpeichernDlg.exists( 1 ) ) then + + '///+<li>Enter a filename (with extension)</li> + Dateiname.setText( hGetWorkPath() & fpath ) + + '///+<li>Click "Save"</li> + speichern.click() + + '///+<li>If the file exists, say "yes" to replace it</li> + if ( bReplace ) then + Kontext "Active" + if ( active.exists( 2 ) ) then + printlog( CFN & "Overwriting file" ) + printlog( "Message: " & active.getText() ) + try + active.yes() + catch + warnlog( CFN & "Unexpected active - no YES button available." ) + printlog( CFN & "if any this should have been overwrite warning." ) + endcatch + endif + endif + + '///+<li>Handle any unexpected errormessage with "OK"</li> + Kontext "Active" + if ( active.exists( 2 ) ) then + printlog( CFN & "Unexpected active: " & active.getText() ) + brc = false + active.ok() + endif + + '///+<li>The FileSave dialog should be closed at this point</li> + kontext "SpeichernDlg" + if ( SpeichernDlg.exists( 1 ) ) then + warnlog( CFN & "File Save dialog is still open, it should be closed" ) + SpeichernDlg.cancel() + endif + else + warnlog( CFN & "Failed to open File Open dialog" ) + brc = false + endif + + '///+<li>Verify that exactly one document is open</li> + if( getDocumentCount <> 1 ) then + warnlog( CFN & "Incorrect number of open documents" ) + brc = false + endif + + printlog( CFN & "Exit with result: " & brc ) + hSaveFileExpectSuccess() = brc + '///</ul> + +end function + +'******************************************************************************* + +function hSaveFileExpectFailure( fpath as string , errortype as integer ) as boolean + + '///<h3>Save a file where failure is expected</h3> + '///<i>Uses</i>: framework\tools\t_stringtools.inc<br><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Filename incl. extension (string)</li> + '///+<li>Errortype (Integer). Valid options are:</li> + '///<ul> + '///+<li>0 = Invalid characters in string</li> + '///+<li>1 = Filename is interpreted as device</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE = <b><i>There was an error saving the file (as expected)</i></b></li> + '///+<li>FALSE = The file was saved without problems/any other error</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + ' currently we have two different kinds of failure + ' 1. File cannot be saved due to invalid character(s) + ' This is errortype = 0 + ' 2. File cannot be saved because the given name is interpreted as device + ' This is errortype = 1 + ' This sequence tries to save a document with an invalid name. The errormsg + ' is closed, the filedialog cancelled and the file closed. + + dim brc as boolean : brc = false + + dim cMsg as string + + const CFN = "hSaveFileExpectFailure::" + + '///+<li>Open an new document</li> + hCreateDocument() + + '///+<li>Click "Save As;"</li> + printlog( "" ) + printlog( CFN & "Enter with options: " & fpath & ", " & errortype ) + hUseAsyncSlot( "FileSaveAs" ) + + '///+<li>Enter the filename</li> + kontext "SpeichernDlg" + if ( SpeichernDlg.exists( 1 ) ) then + + Kontext "SpeichernDlg" + Dateiname.setText( fpath ) + + '///+<li>Click "Save"</li> + speichern.click() + + '///<ul> + '///+<li>Handle invalid characters (Errormessages)</li> + select case( errortype ) + case 0: + + brc = false + + Kontext "Active" + if ( Active.exists( 1 ) ) then + + printlog( CFN & "Check for possible overwrite warning..." ) + try + Active.yes() + printlog( CFN & "Closed Messagebox with <YES>" ) + printlog( CFN & "This was the overwrite warning" ) + catch + endcatch + endif + + Kontext "Active" + if ( Active.exists( 1 ) ) then + cMsg = active.getText() + try + Active.ok() + printlog( CFN & "Closed Save-Failure warning with <OK>" ) + brc = true + catch + qaerrorlog( CFN & "Unknown dialog encountered, <OK> failed:" ) + printlog( cMSG ) + endcatch + endif + + + case 1: + + Kontext "Active" + if ( Active.exists( 1 ) ) then + printlog( CFN & "Expected active: " & active.getText() ) + Active.OK() + + Kontext "SpeichernDLG" + if ( SpeichernDlg.exists( 1 ) ) then + SpeichernDLG.cancel() + brc = true + else + warnlog( CFN & "File Save dialog is missing. Bad!" ) + brc = false + endif + else + warnlog( CFN & "Errormessage for '/', '\' or ':' is missing" ) + brc = false + endif + + end select + + else + warnlog( CFN & "Failed to open File Save dialog" ) + endif + '///</ul> + + '///+<li>Close the document</li> + hDestroyDocument() + + '///+<li>Return errorcondition</li> + printlog( CFN & "Exit with status: " & brc ) + hSaveFileExpectFailure() = brc + + '///</ul> + +end function + +'******************************************************************************* + +function hDeleteFileViaFileOpen( cFile as String ) as boolean + + '///<h3>Delete a file using the File Open dialog</h3> + '///<i>Uses</i>: framework\tools\t_stringtools.inc<br><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Filename incl. extension (string)</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE = File was deleted</li> + '///+<li>FALSE = Any other condition</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + ' This sub deletes a file by name. No errors or warnings are expected. + ' if everything goes well, we're back to the originating document after + ' completion. + + dim iSelectedFilePosition as integer + dim brc as boolean + + const CFN = "hDeleteFileViaFileOpen::" + printlog( CFN & "Enter with option: " & cFile ) + + ' Test for wildcards - the dialog cannot handle those + if ( instr( cFile , "?" ) <> 0 ) then + warnlog( CFN & "Incorrect call to function, wildcards are not allowed" ) + hDeleteFileViaFileOpen() = false + exit function + endif + + ' Test for wildcards - the dialog cannot handle those + if ( instr( cFile , "*" ) <> 0 ) then + warnlog( CFN & "Incorrect call to function, wildcards are not allowed" ) + hDeleteFileViaFileOpen() = false + exit function + endif + + '///+<li>Click "File Open"</li> + hUseAsyncSlot( "FileOpen" ) + + '///+<li>Look for the requested file, get the position from the filelist</li> + Kontext "OeffnenDLG" + iSelectedFilePosition = hFindFileObjectViaFileOpen( cFile ) + + '///+<li>If the file exists, delete it + verify, if not: Warn and exit</li> + if ( iSelectedFilePosition > 0 ) then + + ' Enable for debug + 'printlog( CFN & "Requested file: " & cFile ) + 'printlog( CFN & "Object is at..: " & iSelectedFilePosition ) + 'printlog( CFN & "Object name is: " & DateiAuswahl.getSelText() ) + + DateiAuswahl.TypeKeys( "<DELETE>" ) + + ' Confirm deletion. This dialog should always pop up when deleting + Kontext "ConfirmDelete" + if ( ConfirmDelete.exists( 1 ) ) then + Delete.click() + printlog( CFN & "Deleted file: " & cFile ) + else + warnlog( CFN & "Messagebox to confirm deletion of file is missing" ) + endif + + ' Handle possible Warnings/Errormessages. If no errors happen, + ' verify that the file has been deleted. Note that this dialog will not + ' change the returnvalue. + Kontext "Active" + if( Active.exists( 1 ) ) then + warnlog( CFN & "Unexpected active: " & active.getText() ) + Active.OK() + endif + + ' Verify that the file does no longer exist in the filelist. + iSelectedFilePosition = hFindFileObjectViaFileOpen( cFile ) + if ( iSelectedFilePosition = 0 ) then + brc = true + else + brc = false + endif + + else + + brc = false + warnlog( CFN & "File not found in workdir: " & cFile ) + + endif + + '///+<li>Cancel the FileOpen dialog</li> + kontext "OeffnenDlg" + OeffnenDlg.cancel() + + '///+<li>Return errorcondition</li> + printlog( CFN & "Exit with result: " & brc ) + hDeleteFileViaFileOpen() = brc + + '///</ul> + +end function + +'******************************************************************************* + +function hNameGen_append( iDecChar as long ) as string + + '///<h3>Create a filename with specified character at the end</h3> + '///<u>Input</u>: + '///<ol> + '///+<li>Character as number (integer)</li> + '///<ul> + '///+<li>Only positive numbers are allowed</li> + '///+<li>Respect integer boundaries</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>A filename containing a special character at the end (before suffix)</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim cFile as string + const CFN = "hNameGen_append::" + + '///+<li>Create a string "test", append ascii char</li> + cFile = "test" & CHR$( iDecChar ) + printlog( CFN & "ASCII " & iDecChar & " appended, len = " & len( cFile ) ) + if ( len( cFile ) <> 5 ) then + warnlog( CFN & "Character not appended" ) + endif + + '///+<li>Return the new filename</li> + hNameGen_append() = cFile + + '///</ul> + +end function + +'******************************************************************************* + +function hNameGen_lead( iDecChar as long ) as string + + '///<h3>Create a filename with specified character at the beginning</h3> + '///<u>Input</u>: + '///<ol> + '///+<li>Character as number (integer)</li> + '///<ul> + '///+<li>Only positive numbers are allowed</li> + '///+<li>Respect integer boundaries</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>A filename containing a special character at the beginning</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim cFile as string + const CFN = "hNameGen_lead::" + + '///+<li>Create a string beginning with ascii char and append "test"</li> + cFile = CHR$( iDecChar ) & "test" + printlog( CFN & "ASCII " & iDecChar & " prepended, len = " & len( cFile ) ) + if ( len( cFile ) <> 5 ) then + warnlog( CFN & "Character not prepended" ) + endif + + '///+<li>Return the new filename</li> + hNamegen_lead() = cFile + + '///</ul> + +end function + +'******************************************************************************* + +function hFindFileObjectViaFileOpen( cName as string ) as integer + + '///<h3>Get the position of a filesystem object in filelist of fileopen dialog</h3> + '///<i>Note that the filepicker must be open in order to use this function.<br> + '///The object with the given name is selected when leaving the function.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Filename incl. extension (string) but without any pathseparator</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Position of the object in the filepicker list</li> + '///<ul> + '///+<li>0: Object not found</li> + '///+<li>> 0: Position</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hFindFileObjectViaFileOpen::" + + dim iCurrentObject as integer + dim cCurrentName as string + dim iFileOpenItemCount as integer + + dim iPos as integer : iPos = 0 + dim cPath as string : cPath = cName + + dim iPathItems as integer + dim asPathList( 100 ) as string + + dim iWait as integer ' some increment variable + + printlog( CFN & "Enter with option (File): " & cName ) + + '///+<li>If a fully qualified path has been provided we have to split it up</li> + iPathItems = DirNameList( cPath, asPathList() ) + 'printlog( CFN & "iPathItems (new): " & iPathItems ) + + if ( iPathItems > 3 ) then + cName = asPathList( iPathItems ) + printlog( CFN & "CNAME from plist: " & cName ) + + '///+<li>And walk to the directory</li> + cPath = left( cPath , ( len ( cPath ) - len( cName ) ) - 1 ) + printlog( CFN & "CPATH from plist: " & cPath ) + + kontext "OeffnenDlg" + if ( OeffnenDlg.exists( 1 ) ) then + Dateiname.setText( cPath ) + Oeffnen.click() + else + warnlog( CFN & "File Open dialog is not open" ) + hFindFileObjectViaFileOpen() = 0 + exit function + endif + endif + + '///+<li>get the number of items in the filepicker</li> + kontext "OeffnenDlg" + iWait = 0 + while ( DateiAuswahl.getItemCount() = 0 ) + wait( 100 ) + iWait = iWait + 1 + if ( iWait = 10 ) then + warnlog( "Filepicker is not populated within reasonable timeframe, aborting" ) + kontext "OeffnenDlg" + OeffnenDlg.Close() + hFindFileObjectViaFileOpen() = 0 + exit function + else + printlog( "Waiting for filepicker list to populate..." ) + endif + wend + + iFileOpenItemCount = DateiAuswahl.getItemCount() + + '///+<li>Jump to the first item in the filelist and select it with SPACE</li> + DateiAuswahl.typeKeys( "<HOME>" ) + DateiAuswahl.typeKeys( "<SPACE>" ) + + '///+<li>Navigate through the list until we find the requested object</li> + for iCurrentObject = 1 to iFileOpenItemCount + + cCurrentName = DateiAuswahl.getSelText() + + if ( cCurrentName = cName ) then + iPos = iCurrentObject + exit for + endif + + DateiAuswahl.typeKeys( "<DOWN>" ) + + next iCurrentObject + + '///+<li>Print some info to the log</li> + if ( iPos > 0 ) then + printlog( CFN & "Exit: Found item [" & cName & "] at pos: " & iPos ) + else + printlog( CFN & "Exit: Requested item [" & cName & "] was not found." ) + endif + + '///+<li>return the position or 0 on failure</li> + hFindFileObjectViaFileOpen() = iPos + '///</ul> + +end function + diff --git a/testautomation/framework/tools/includes/formcontrols.inc b/testautomation/framework/tools/includes/formcontrols.inc new file mode 100644 index 000000000000..7271347e10eb --- /dev/null +++ b/testautomation/framework/tools/includes/formcontrols.inc @@ -0,0 +1,800 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +' ** +' ** owner : gregor.hartmann@oracle.com +' ** +' ** short description : Tools to draw and select form controls in basic-ide +' ** +'\****************************************************************************** + +private const ICONTROLCOUNT = 22 + +'******************************************************************************* + +function hGetControlParams( cParam as string ) as integer + + '///<h3>Retrieve basic parameters to draw formcontrols to a dialog</h3> + '///<i>All values are in percent relative to the window size. + '///+ All values are optimized for 1024x768 pixels screen resolution but + '///+ have been tested successfully with 1280x1024 and 800x600</i><br> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Name of the coordinate (string). Valid options are:</li> + '///<ul> + '///+<li>"XOREGO" (Upper left corner)</li> + '///+<li>"YOREGO" (Upper left corner)</li> + '///+<li>"XDIST" (Distance between the upper left corners of neighbor controls)</li> + '///+<li>"YDIST" (Distance between the upper left corners of neighbor controls)</li> + '///+<li>"XSIZE" (Width of control)</li> + '///+<li>"YSIZE" (Heighth of the control)</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Coordinate/Distance/Size in percent of window size (integer)</li> + '///<ul> + '///+<li>A number between 1 and 100</li> + '///+<li>0 on error (invalid function parameter)</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + cParam = ucase( cParam ) + + '///+<li>Currently following values are defined:</li> + '///<ul> + select case ( cParam ) + '///+<li>XOREGO = 31</li> + case "XOREGO" : hGetControlParams() = 31 + '///+<li>XDIST = 8</li> + case "XDIST" : hGetControlParams() = 8 + '///+<li>XSIZE = 6</li> + case "XSIZE" : hGetControlParams() = 6 + '///+<li>YOREGO = 30</li> + case "YOREGO" : hGetControlParams() = 30 + '///+<li>YDIST = 7</li> + case "YDIST" : hGetControlParams() = 7 + '///+<li>YSIZE = 5</li> + case "YSIZE" : hGetControlParams() = 5 + '///+<li>Incorrect function parameter = 0</li> + case else : hGetControlParams() = 0 + '///</ul> + end select + '///</ul> + +end function + +'******************************************************************************* + +function hGetControlName( iControl as integer ) as string + + '///<h3>A function to deliver a speaking name for all form controls</h3> + '///<i>Note that the numbers of the controls are unique</i><br> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description below</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Name for a control (string)</li> + '///<ul> + '///+<li>Name for a control (may contain whitespaces)</li> + '///+<li>An empty string in case of an invalid function parameter</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + '///+<li>Currently following control are defined:</li> + '///<ol> + select case iControl + '///+<li>Push Button</li> + case 1 : hGetControlName() = "Push Button" + '///+<li>Image Control</li> + case 2 : hGetControlName() = "Image Control" + '///+<li>Check Box</li> + case 3 : hGetControlName() = "Check Box" + '///+<li>Radio Button</li> + case 4 : hGetControlName() = "Radio Button" + '///+<li>Fixed Text</li> + case 5 : hGetControlName() = "Fixed Text" + '///+<li>Edit Field</li> + case 6 : hGetControlName() = "Edit Field" + '///+<li>List Box</li> + case 7 : hGetControlName() = "List Box" + '///+<li>Combo Box</li> + case 8 : hGetControlName() = "Combo Box" + '///+<li>Vertical ScrollBar</li> + case 9 : hGetControlName() = "Vertical ScrollBar" + '///+<li>Horizontal ScrollBar</li> + case 10 : hGetControlName() = "Horizontal ScrollBar" + '///+<li>Frame</li> + case 11 : hGetControlName() = "Frame" + '///+<li>Progress Bar</li> + case 12 : hGetControlName() = "Progress Bar" + '///+<li>Vertical Fixed Line</li> + case 13 : hGetControlName() = "Vertical Fixed Line" + '///+<li>Horizontal Fixed Line</li> + case 14 : hGetControlName() = "Horizontal Fixed Line" + '///+<li>Date Field</li> + case 15 : hGetControlName() = "Date Field" + '///+<li>Time Field</li> + case 16 : hGetControlName() = "Time Field" + '///+<li>Numeric Field</li> + case 17 : hGetControlName() = "Numeric Field" + '///+<li>Currency Field</li> + case 18 : hGetControlName() = "Currency Field" + '///+<li>Form Field</li> + case 19 : hGetControlName() = "Form Field" + '///+<li>Pattern Field</li> + case 20 : hGetControlName() = "Pattern Field" + '///+<li>File Control</li> + case 21 : hGetControlName() = "File Control" + '///+<li>Tree Control</li> + case 22 : hGetControlName() = "Tree Control" + '///</ol> + '///+<li>"" for function parameter < 1 or > 22 </li> + case else : sControl = "" + end select + '///</ul> + +end function + +'******************************************************************************* + +function hInsertControl( iControl as integer ) as string + + '///<h3>Function to insert one of the BASIC formcontrols by index</h3> + '///<i>Note that the numbers of the controls are unique</i><br> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description below</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Name for a control (string)</li> + '///<ul> + '///+<li>Name for a control (may contain whitespaces)</li> + '///+<li>An empty string in case of an invalid function parameter</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hInsertControl::" + + Kontext "ToolsCollectionBar" + + '///+<li>Click on the requested button on the ToolsCollectionBar:</li> + '///<ol> + select case iControl + '///+<li>Push Button</li> + case 1 : InsPushButton.click() + '///+<li>Image Control</li> + case 2 : InsImgCtrl.click() + '///+<li>Check Box</li> + case 3 : InsCheckbox.click() + '///+<li>Radio Button</li> + case 4 : InsRadioButton.click() + '///+<li>Fixed Text</li> + case 5 : InsFixedText.click() + '///+<li>Edit Field</li> + case 6 : InsEditField.click() + '///+<li>List Box</li> + case 7 : InsListbox.click() + '///+<li>Combo Box</li> + case 8 : InsComboBox.click() + '///+<li>Vertical ScrollBar</li> + case 9 : InsScrollBarV.click() + '///+<li>Horizontal ScrollBar</li> + case 10 : InsScrollBarH.click() + '///+<li>Frame</li> + case 11 : InsFrame.click() + '///+<li>Progress Bar</li> + case 12 : InsProgressbar.click() + '///+<li>Vertical Fixed Line</li> + case 13 : InsFixedLineV.click() + '///+<li>Horizontal Fixed Line</li> + case 14 : InsFixedLineH.click() + '///+<li>Date Field</li> + case 15 : InsDateField.click() + '///+<li>Time Field</li> + case 16 : InsTimeField.click() + '///+<li>Numeric Field</li> + case 17 : InsNumField.click() + '///+<li>Currency Field</li> + case 18 : InsCurrencyField.click() + '///+<li>Form Field</li> + case 19 : InsFormField.click() + '///+<li>Pattern Field</li> + case 20 : InsPatternField.click() + '///+<li>File Control</li> + case 22 : InsFileCtrl.click() + '///+<li>Tree Control</li> + case 22 : InsTreeControl.click() + end select + '///</ol> + '///+<li>"" for function parameter < 1 or > 22 </li> + + hInsertControl() = hGetControlName( iControl ) + '///</ul> + +end function + +'******************************************************************************* + +function hDrawControlOnDialog( iControl as integer ) as string + + '///<h3>Draw a control on a dialog at a fixed position</h3> + '///<i>Note that the numbers of the controls are unique</i><br> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Name for a control (string)</li> + '///<ul> + '///+<li>Name for a control (may contain whitespaces)</li> + '///+<li>An empty string in case of an invalid function parameter</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hDrawControlOnDialog::" + + dim sControl as string ' The name of the current control + dim brc as boolean ' some returnvalue + + ' coordinates of the controls on the dialog in the dialog-editor + dim iXO as integer + dim iYO as integer + dim iXE as integer + dim iYE as integer + + '///+<li>determine where the control is to be painted (hGetControlPos...)</li> + iXO = hGetControlPosXO( iControl ) + iYO = hGetControlPosYO( iControl ) + iXE = hGetControlPosXE( iControl ) + iYE = hGetControlPosYE( iControl ) + + '///+<li>click the desired control</li> + sControl = hInsertControl( iControl ) + printlog( CFN & " Index=" & iControl & _ + " at XO=" & iXO & _ + " XE=" & iXE & _ + " YO=" & iYO & _ + " YE=" & iYE & _ + " : " & sControl ) + + '///+<li>Draw the control (using hDrawControl(...))</li> + brc = hDrawControl( iXO, iYO, iXE, iYE ) + hDrawControlOnDialog() = sControl + '///</ul> + +end function + +'******************************************************************************* + +function hDrawControl( xPos as integer, _ + yPos as integer, _ + xEnd as integer, _ + yEnd as integer ) as boolean + + '///<h3>Draw a control on the dialog pane in the dialog editor</h3> + '///<i>Starting point: Basic IDE/Dialog editor</i><br> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<i>Note: All units are in percent of the relative to the current window size</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>X-Orego (Upper left corner) (integer)</li> + '///<ul> + '///+<li>Min = 0</li> + '///+<li>Max = 100 (allowed but not useful)</li> + '///</ul> + '///+<li>Y-Orego (Upper left corner) (integer)</li> + '///<ul> + '///+<li>Min = 0</li> + '///+<li>Max = 100 (allowed but not useful)</li> + '///</ul> + '///+<li>X-End (Lower right corner) (integer)</li> + '///<ul> + '///+<li>Min = 0</li> + '///+<li>Max = 100 (allowed but not useful)</li> + '///</ul> + '///+<li>Y-End (Lower right corner) (integer)</li> + '///<ul> + '///+<li>Min = 0</li> + '///+<li>Max = 100 (allowed but not useful)</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorstatus (boolean)</li> + '///<ul> + '///+<li>TRUE on success</li> + '///+<li>FALSE on failure</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hDrawControl::" + + '///+<li>Set context to Basic IDE</li> + Kontext "BasicIDE" + + '///+<li>Draw the control using mouse actions</li> + '///<ol> + '///+<li>Mouse down on pos X/Y-Orego</li> + '///+<li>Mouse move to pos X/Y-End</li> + '///+<li>Mouse up on pos X/Y-End</li> + '///</ol> + '///</ul> + + autoexecute = false + DialogWindow.MouseUp( 20 , 20 ) : wait 100 + + try + DialogWindow.MouseMove ( xPos, yPos ) : wait 100 + DialogWindow.MouseDown ( xPos, yPos ) : wait 100 + DialogWindow.MouseMove ( xEnd, yEnd ) : wait 100 + DialogWindow.MouseUp ( xEnd, yEnd ) : wait 100 + hDrawControl() = true + catch + warnlog( "#i39852# " & CFN & "Unable to complete mouseactions on dialog" ) + hDrawControl() = false + endcatch + autoexecute = true + +end function + +'******************************************************************************* + +function hGetControlPosXO( iControl as integer ) as integer + + '///<h3>Retrieve the upper left X-coordinate for a control</h3> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>X-Orego in percent of window size (integer)</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim xOffset as integer + xOffset = hGetControlParams( "xorego" ) + + dim xDistance as integer + xDistance = hGetControlParams( "xdist" ) + + '///+<li>Define an offset for the control depending on its ID</li> + '///<ul> + '///+<li>< 7 : Column one</li> + '///+<li>7 ... 12 : Column two</li> + '///+<li>13 ... 18 : Column three</li> + '///+<li>> 18 : Column four</li> + '///</ul> + '///</ul> + + select case ( iControl ) + case 1, 2, 3, 4, 5, 6 : hGetControlPosXO() = xOffset + case 7, 8, 9, 10, 11, 12 : hGetControlPosXO() = xOffset + 1 * xDistance + case 13, 14, 15, 16, 17, 18 : hGetControlPosXO() = xOffset + 2 * xDistance + case 19, 20, 21, 22, 23, 24 : hGetControlPosXO() = xOffset + 3 * xDistance + end select + +end function + +'******************************************************************************* + +function hGetControlPosYO( iControl as integer ) as integer + + '///<h3>Retrieve the upper left Y-coordinate for a control</h3> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 21, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Y-Orego in percent of window size (integer)</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + dim yOffset as integer + yOffset = hGetControlParams( "yorego" ) + + dim yDistance as integer + yDistance = hGetControlParams( "ydist" ) + + '///+<li>Define an offset for the control depending on its ID</li> + '///<ul> + '///+<li>1 , 7 , 13 , 19 : Row one</li> + '///+<li>2 , 8 , 14 , 20 : Row two</li> + '///+<li>3 , 9 , 15 , 21 : Row three</li> + '///+<li>4 , 10 , 16 , 22 : Row four</li> + '///+<li>5 , 11 , 17 : Row five</li> + '///+<li>6 , 12 , 18 : Row six</li> + '///</ul> + '///</ul> + + select case ( iControl ) + case 1, 7, 13, 19 : hGetControlPosYO() = yOffset + case 2, 8, 14, 20 : hGetControlPosYO() = yOffset + 1 * yDistance + case 3, 9, 15, 21 : hGetControlPosYO() = yOffset + 2 * yDistance + case 4, 10, 16, 22 : hGetControlPosYO() = yOffset + 3 * yDistance + case 5, 11, 17, 23 : hGetControlPosYO() = yOffset + 4 * yDistance + case 6, 12, 18, 24 : hGetControlPosYO() = yOffset + 5 * yDistance + end select + +end function + +'******************************************************************************* + +function hGetControlPosXE( iControl as integer ) as integer + + '///<h3>Retrieve the lower right X-coordinate for a control</h3> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>X-End in percent of window size (integer)</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + '///+<li>Get pos for X-Orego, add "XSIZE"</li> + hGetControlPosXE() = hGetControlPosXO( iControl ) + _ + hGetControlParams( "xsize" ) + '///</ul> + +end function + +'******************************************************************************* + +function hGetControlPosYE( iControl as integer ) as integer + + '///<h3>Retrieve the lower right Y-coordinate for a control</h3> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Y-End in percent of window size (integer)</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + '///+<li>Get pos for Y-Orego, add "YSIZE"</li> + hGetControlPosYE() = hGetControlPosYO( iControl ) + _ + hGetControlParams( "ysize" ) + '///</ul> + +end function + +'******************************************************************************* + +function hGetControlPosXM( iControl as integer ) as integer + + '///<h3>Retrieve the center (X) of a control</h3> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>X-Center in percent of window size (integer)</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim XO as integer + dim XE as integer + + '///+<li>Find X-Orego</li> + XO = hGetControlPosXO( iControl ) + + '///+<li>Find X-End</li> + XE = hGetControlPosXE( iControl ) + + '///+<li>Calculate the distance, find the middle between the two</li> + hGetControlPosXM() = XO + 0.5 * ( XE - XO ) + '///</ul> + +end function + +'******************************************************************************* + +function hGetControlPosYM( iControl as integer ) as integer + + '///<h3>Retrieve the center (Y) of a control</h3> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...). The coordinates + '///+ returned by this function can be used to draw and to select a control.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Y-Center in percent of window size (integer)</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim YO as integer + dim YE as integer + + '///+<li>Find Y-Orego</li> + YO = hGetControlPosYO( iControl ) + + '///+<li>Find Y-End</li> + YE = hGetControlPosYE( iControl ) + + '///+<li>Calculate the distance, find the middle between the two</li> + hGetControlPosYM() = YO + 0.5 * ( YE - YO ) + '///</ul> + +end function + +'******************************************************************************* + +function hSelectControl( iControl as integer ) as boolean + + '///<h3>Function to select one of the BASIC formcontrols by index</h3> + '///<i>Note: Refer to the inline documentation for implementation details</i><br> + '///<i>In most cases it is desired to place multiple controls on a single + '///+ dialog pane. To prevent the controls from overlapping each other + '///+ they are arranged in rows and columns. Each control is identified + '///+ by a unique number (see description for hInsertControl(...)). The + '///+ dimensions are defined in hGetControlParams(...).</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Number of the control (integer)</li> + '///<ul> + '///+<li>Any number between 1 and 22, see description for hInsertControl()</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorstatus (boolean)</li> + '///<ul> + '///+<li>TRUE if the properties-button on ToolsCollectionBar is enabled</li> + '///+<li>FALSE in any other case</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim xPos as integer + dim yPos as integer + dim iCurrentSelectionMethod as integer + + const SELECT_MIDDLE = 1 ' click into the middle of the control + const SELECT_UPPER_LEFT = 2 ' click the upper left corner of the control + const SELECT_LOWER_RIGHT = 3 ' click the lower right corner of the control + const SELECT_FRAME_AROUND = 4 ' select by drawing a frame around the control + + const EXTRA_FRAME_SIZE = 1 ' one percent in-/outside the border of the control + const SELECTION_METHODS = 4 ' this function sports four ways of seleting a control + const REPEAT_COUNT = 5 ' number of times to send a keystroke to the dialog window + + hSelectControl() = false + + '///+<li>Verify that the ToolsCollectionBar is visible. if not: Abort</li> + kontext "ToolsCollectionBar" + if ( not ToolsCollectionBar.exists() ) then + warnlog( "The ToolsCollectionBar is not visible, open it first" ) + exit function + endif + + '///+<li>Enable the selection mode on ToolsCollectionBar</li> + SelectMode.click() + + ' Note: The controls have areas where they ignore a mouseclick. E.g. the + ' framecontrol can only be grabbed at the border, you won't be able to + ' select it by clicking in the middle. Furthermore - even if the Dialog- + ' editor-window is maximized - we might still miss the upper left corner. + ' So what happens in this loop is that we try to click in the middle of the + ' control. This works in 21 out of 22 cases. If it fails, we try to grab the + ' border, first upper left corner then lower right. If this still fails, + ' we try to select the control by using a rectangle selection around the + ' control. If this last resort fails, the function exits gracefully but + ' with a warnlog (causing some other functions to fail with warnings + ' as well). Beware of possible problems with screen resolutions. + ' This function has been tested for 1024x768 and 1280x1024 pixels. + ' Method 4 is dangerous because it might accidentially select the + ' background window which is the reason why this is not the default. + + '///+<li>Try four different ways of selecting the control before giving up</li> + '///<ol> + '///+<li>Mouse-Click in the middle</li> + '///+<li>Mouse-Click on upper left corner</li> + '///+<li>Mouse-Click on lower right corner</li> + '///+<li>Rubberband around the control (Mouse movement)</li> + '///+<li>Deselct everything and use <TAB> to activate the control</li> + '///</ol> + + autoexecute = false + for iCurrentSelectionMethod = 1 to SELECTION_METHODS + + Kontext "BasicIDE" + DialogWindow.typeKeys( "<UP><LEFT>" , REPEAT_COUNT ) + select case ( iCurrentSelectionMethod ) + case SELECT_MIDDLE + + xPos = hGetControlPosXM( iControl ) + yPos = hGetControlPosYM( iControl ) + DialogWindow.MouseMove( xPos, yPos ) + DialogWindow.MouseDown( xPos, yPos ) + DialogWindow.MouseUp ( xPos, yPos ) + + case SELECT_UPPER_LEFT + + xPos = hGetControlPosXO( iControl ) + EXTRA_FRAME_SIZE + yPos = hGetControlPosYO( iControl ) + EXTRA_FRAME_SIZE + DialogWindow.MouseMove( xPos, yPos ) + DialogWindow.MouseDown( xPos, yPos ) + DialogWindow.MouseUp ( xPos, yPos ) + + case SELECT_LOWER_RIGHT + + xPos = hGetControlPosXE( iControl ) - EXTRA_FRAME_SIZE + yPos = hGetControlPosYE( iControl ) - EXTRA_FRAME_SIZE + DialogWindow.MouseMove( xPos, yPos ) + DialogWindow.MouseDown( xPos, yPos ) + DialogWindow.MouseUp ( xPos, yPos ) + + case SELECT_FRAME_AROUND + + xPos = hGetControlPosXO( iControl ) - EXTRA_FRAME_SIZE + yPos = hGetControlPosYO( iControl ) - EXTRA_FRAME_SIZE + DialogWindow.MouseMove( xPos, yPos ) + DialogWindow.MouseDown( xPos, yPos ) + + xPos = hGetControlPosXE( iControl ) + EXTRA_FRAME_SIZE + yPos = hGetControlPosYE( iControl ) + EXTRA_FRAME_SIZE + DialogWindow.MouseMove( xPos, yPos ) + DialogWindow.MouseUp ( xPos, yPos ) + + end select + + try + if ( iControl = 11 ) then + wait( 100 ) + printlog( "tried method: " & iCurrentSelectionMethod ) + endif + ContextProperties + hSelectControl() = true + exit for + catch + endcatch + + next iCurrentSelectionMethod + autoexecute = true + '///</ul> + +end function + + diff --git a/testautomation/framework/tools/includes/help_tools.inc b/testautomation/framework/tools/includes/help_tools.inc new file mode 100644 index 000000000000..7b17d4fe37ed --- /dev/null +++ b/testautomation/framework/tools/includes/help_tools.inc @@ -0,0 +1,239 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Replacements for routines in t_lists.inc adds some +'* +'\****************************************************************************** + +function hOpenHelp() as boolean + + printlog( "Open Help Browser" ) + + HelpContents + + kontext "StarOfficeHelp" + if ( StarOfficeHelp.exists( 5 ) ) then + hOpenHelp() = TRUE + else + warnlog( "Unable to open help browser" ) + hOpenHelp() = FALSE + endif + + +end function + +'******************************************************************************* + +function hCloseHelp() as boolean + + printlog( "Close Help Browser" ) + + kontext "StarOfficeHelp" + StarOfficeHelp.typeKeys( "<MOD1 F4>" ) + + if ( StarOfficeHelp.notExists( 3 ) ) then + hCloseHelp() = TRUE + else + warnlog( "Help browser could not be closed" ) + hCloseHelp() = FALSE + endif + +end function + +'****************************************************************************** + +function hSelectHelpTab( cTab as string ) as boolean + + '///<h3>Select a tab on the help dialog by name</h3> + '///<u>Input</u>: + '///<ol> + '///+<li>The tab to open (string)</li> + '///<ul> + '///+<li>"content" for the contents tab</li> + '///+<li>"index" for the index tab</li> + '///+<li>"find" for the find tab</li> + '///+<li>"bookmarks" for the bookmarks tab</li> + '///</ul> + '///</ol> + + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE if the requested tabpage is open</li> + '///+<li>FALSE if the requested tabpage did not open</li> + '///</ul> + '///</ol> + + '///<u>Description</u>: + '///<ul> + const CFN = "hSelectHelpTab::" + + dim brc as boolean : brc = false + dim cTabName as string : cTabName = lcase( cTab ) + + kontext "StarOfficeHelp" + + printlog( CFN & "Enter" ) + + '///+<li>Select the requested Tabpage, verify that it is open</li> + select case cTabName + case "content" : TabControl.setPage( ContentPage ) + if ( SearchContent.isVisible() ) then + call DialogTest( ContentPage ) + brc = true + endif + case "index" : TabControl.setPage( IndexPage ) + if ( SearchIndex.isVisible() ) then + call DialogTest( IndexPage ) + brc = true + endif + case "find" : TabControl.setPage( FindPage ) + if ( SearchFind.isVisible() ) then + call DialogTest( FindPage ) + brc = true + endif + case "bookmarks" : TabControl.setPage( BookmarksPage ) + if ( Bookmarks.isVisible() ) then + call DialogTest( BookmarksPage ) + brc = true + endif + case else + printlog( CFN & "Invalid parameter passed to function: " & cTab ) + printlog( CFN & "Valid are: content, index, find, bookmarks" ) + brc = false + end select + + '///+<li>Print a comment to the log</li> + if ( brc ) then + printlog( CFN & "Exit: Selected Tabpage: " & cTab ) + endif + + '///+<li>Return TRUE or FALSE</li> + hSelectHelpTab() = brc + + '///</ul> +end function + +'******************************************************************************* + +function hUseBookmarksContextMenu( cAction as string ) as boolean + + '///<h3>handle the bookmarks context menu in Help Browser</h3> + '///<u>Input</u>: + '///<ol> + '///+<li>The context item to execute (string)</li> + '///<ul> + '///+<li>"show"</li> + '///+<li>"rename"</li> + '///+<li>"delete"</li> + '///</ul> + '///</ol> + + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE on success</li> + '///+<li>FALSE on any other error</li> + '///</ul> + '///</ol> + + '///<u>Description</u>: + '///<ul> + const CFN = "hUseBookmarksContextMenu::" + dim cSelection as string + dim iActionPos as integer + + printlog( CFN & "Enter" ) + + '///+<li>Verify that we are on the Bookmarks Page</li> + Kontext "BookmarksPage" + if ( not BookmarksPage.exists() ) then + printlog( CFN & "BookmarksPage is not open" ) + hUseBookmarksContextMenu() = false + exit function + endif + + '///+<li>Find the index of the requested entry</li> + cSelection = lcase( cAction ) + select case cSelection + case "show" : iActionPos = 1 + case "rename" : iActionPos = 2 + case "delete" : iActionPos = 3 + case else : iActionPos = 0 + end select + + '///+<li>If action is unsuported, return false and exit the function</li> + if ( iActionPos = 0 ) then + printlog( CFN & "Invalid action passed to function" ) + hUseBookmarksContextMenu() = false + exit function + endif + + '///+<li>Open the context menu and select the requested index</li> + kontext "Bookmarks" + Bookmarks.openContextMenu() + printlog( CFN & "Exit: Opening item: " & MenuGetItemText( iActionPos ) ) + MenuSelect( iActionPos ) + + '///+<li>Return TRUE if all went well so far</li> + hUseBookmarksContextMenu() = true + + '///</ul> + +end function + +'******************************************************************************* + +function hHelpGetAboutItemCount() as integer + + printlog( "Get the number of applications listed in the help listbox (should be 8)" ) + const ABOUT_ITEMS = 8 + + dim itemcount as integer + + hOpenHelp() + hSelectHelpTab( "index" ) + + Kontext "IndexPage" + itemcount = HelpAbout.getItemCount() + + if ( itemcount <> ABOUT_ITEMS ) then + warnlog( "Number of applications is incorrect" ) + printlog( "Found...: " & itemcount ) + printlog( "Expected: " & ABOUT_ITEMS + endif + + hCloseHelp() + + hHelpGetAboutItemCount() = itemcount + +end function + diff --git a/testautomation/framework/tools/includes/i18n_tools.inc b/testautomation/framework/tools/includes/i18n_tools.inc new file mode 100644 index 000000000000..aa0e141a45f3 --- /dev/null +++ b/testautomation/framework/tools/includes/i18n_tools.inc @@ -0,0 +1,105 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Tools to ease working with language dependent strings/values +'* +'\****************************************************************************** + +function hTestLocale() as boolean + + + '///<h3>Test whether we are running on an utf8 locale (Linux only)</h3><br> + + '///<u>Parameter(s):</u><br> + '///<ol> + '///+<li>No input parameters</li> + '///</ol> + + + '///<u>Returns:</u><br> + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE: Yes, this is a UTF-8 locale</li> + '///+<li>FALSE: Anything else</li> + '///</ul> + '///</ol> + + const CFN = "hTestLocale::" + dim brc as boolean 'a multi purpose boolean returnvalue + dim irc as integer + irc = 0 + + dim lc_all as string + dim lang as string + + '///<u>Description:</u> + '///<ul> + + if ( gtSysName = "Linux" ) then + + '///+<li>Retrieve LANG</li> + lang = environ( "LANG" ) + lang = ucase( lang ) + if ( instr( lang , "UTF8" ) or instr( lang , "UTF-8" ) ) then + irc = 1 + endif + + '///+<li>Retrieve LC_ALL (Note that this variable is mostly set but has no value assigned)</li> + lc_all = environ( "LC_ALL" ) + lc_all = ucase( lc_all ) + if ( instr( lc_all , "UTF8" ) or instr( lc_all , "UTF-8" ) ) then + irc = irc + 1 + else + if ( lc_all = "" ) then + printlog( CFN & "No value set for LC_ALL, assuming UTF-8" ) + irc = irc + 1 + else + printlog( CFN & "LC_ALL is set but has no UTF-8 locale" ) + endif + endif + + else + + irc = 2 ' this is Windows and Solaris - they always can handle weird content + + endif + + if ( irc = 2 ) then + printlog( CFN & "UTF-8 locale found" ) + hTestLocale() = TRUE + else + printlog( CFN & "Please verify that you are running on UTF-8 locale" ) + hTestLocale() = FALSE + endif + + '///</ul> + + +end function diff --git a/testautomation/framework/tools/includes/options_tools.inc b/testautomation/framework/tools/includes/options_tools.inc new file mode 100644 index 000000000000..4f7a05154795 --- /dev/null +++ b/testautomation/framework/tools/includes/options_tools.inc @@ -0,0 +1,326 @@ +'encoding UTF-8 Do not remove or change this line! +'******************************************************************************* +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : thorsten.bosbach@oracle.com +'* +'* short description : tools for options tests +'* +'\****************************************************************************** + +sub GetPathList ( ls1 () as String, ls2 () as String, ls3 () as String ) + + Dim lsInterim ( 50 ) as String + Dim i as Integer + Dim sList as String + Dim bNewCreate as Boolean + '///routine to get the correct comparison list for path-options + '///+ if the list does not exist => CreatePathList + '///+ you can find the lists for all languages in separate files + '///+[TesttoolPath]\framework\options\input\paths_[LanguageCode].txt + ls1 (0) = 0 : ls2 (0) = 0 : ls3 (0) = 0 + sList = gTesttoolPath + "framework\optional\input\options\paths_" + iSprache + ".txt" + sList = convertpath( sList ) + + if App.Dir ( sList ) = "" then + bNewCreate = TRUE + CreatePathList + else + bNewCreate = FALSE + end if + + if bAsianLan = TRUE then + + select case iSystemSprache + case 01, 33, 34, 39, 46, 49 + ListRead ( lsInterim (), sList, "utf8" ) + case else + + if bNewCreate = FALSE then + CreatePathList + endif + + ListRead ( lsInterim (), sList, "utf8" ) + end select + + else + ListRead ( lsInterim (), sList , "utf8" ) + end if + + for i = 1 to ListCount ( lsInterim () ) + ListAppend ( ls1 (), Left ( lsInterim (i), Instr ( lsInterim (i), ";" ) - 1 ) ) + ListAppend ( ls2 (), Mid ( lsInterim (i), Len ( lsInterim (i) ) - 2, 1 ) ) + ListAppend ( ls3 (), Right ( lsInterim (i), 1 ) ) + next i + +end sub + +'******************************************************************************* + +sub CreatePathList + + Dim i as Integer, iNum as Integer + Dim sType as String, sVario as String, sList as String + Dim lsInterim ( 50 ) as String + '///create the comparison list for path-options + '///+[TesttoolPath]\framework\options\input\paths_[LanguageCode].txt + sList = ConvertPath ( gTesttoolPath + "framework\optional\input\options\paths_" + iSprache + ".txt" ) + call hNewDocument() + ToolsOptions + hToolsOptions ( "StarOffice", "Paths" ) + + for i=1 to Typ.GetItemCount + + Kontext "TabPfade" + + if i=1 then + Typ.TypeKeys "<Down>" + Typ.TypeKeys "<Home>" + else + Typ.TypeKeys "<Down>" + end if + + sType = Typ.GetSelText + + if Bearbeiten.IsEnabled then + Bearbeiten.Click + + Kontext "OeffnenDlg" + + if OeffnenDlg.Exists then + sVario = 1 + iNum = 1 + OeffnenDlg.Cancel + end if + + Kontext "PfadeAuswaehlen" + if PfadeAuswaehlen.Exists then + sVario = 2 + iNum = Pfade.GetItemCount + PfadeAuswaehlen.Cancel + end if + + else + sVario = 0 + iNum = 0 + end if + + ListAppend ( lsInterim(), sType + ";" + sVario + ";" + iNum ) + next i + + if bAsianLan = FALSE then + Warnlog "The file for comparison does not exists. The file will be written!" + Warnlog "Please check : " + sList + ListWrite ( lsInterim(), sList ) + else + Warnlog "The file for comparison does not exists. The file will be written!" + Warnlog "Please check : " + sList + ListWrite ( lsInterim(), sList, "utf8" ) + end if + +end sub + +'******************************************************************************* + +sub Make3D + + '///test with 3D-objects when 3D-options are changed ( view page ) + gApplication = "IMPRESS" + call hNewDocument() + WL_SD_Wuerfel + Sleep 1 + + Kontext "Documentimpress" + DocumentImpress.MouseDown 50, 50 + DocumentImpress.MouseMove 30, 60 + DocumentImpress.MouseUp 30, 60 + Sleep 3 + call hCloseDocument() + gApplication = "WRITER" + +end sub + +'******************************************************************************* + +sub DeleteColor( cColorName as String ) + 'Deletes a color by name. The color is selected in the listbox + 'and should - if it exists - be visible in the entryfield above the list. + 'If this is not the case the color probably not exists and thus + 'cannot be deleted. + 'Remember i18n, only use this sub for colors you created yourself! + dim iItems as Integer 'Number of listed colors + dim i as Integer 'counter + dim bExists as Boolean 'TRUE if color has been successfully deleted + dim iPos as Integer 'Position of the deleted color + dim sColor as string + + printlog "DeleteColor:: - Trying to delete color: '" + cColorName + "'" + Kontext "TabFarben" + bExists = FALSE + iItems = Farbe.getItemCount + i = 0 + while ((i<iItems) AND (NOT bExists)) + sColor = Farbe.getItemText(i+1) + if (sColor = cColorName) then + Loeschen.Click + Kontext "Active" + if Active.Exists then + printlog active.getText + Active.Yes + else + qaErrorlog "No warning about deleting the color." + endif + printlog " - successfully deleted color @ " + (i+1) + "/" + iItems + bExists = TRUE + else + inc (i) + endif +' if FarbName.getText = cColorName then + wend + iPos = i+1 + + if bExists then + 'The userdefined colors usually are appended to the list. If they are + 'somewhere else this might be a bug. + if iItems <> iPos then + warnlog " The color was not located at the end of the list." + printlog " The Order of the list might be corrupted" + end if + else + 'Inform that the color did not exist. This usually is perfectly ok. + printlog " (The color was not deleted, it was not found)" + endif +end sub + +'******************************************************************************* + +sub modifyColorRGB_PGUP( iColor as Integer ) + 'The current color's values are set to maximum (255) for RGB + printlog( "modifyColorRGB_PGUP:: - change the color by pressing PAGE UP in RGB listboxes." ) + + Kontext "TabFarben" + Farbe.Select(iColor) + R.TypeKeys("<PageUp>") + G.TypeKeys("<PageUp>") + B.TypeKeys("<PageUp>") + printlog("modifyColorRGB_PGUP:: Press 'modify'") + Aendern.Click() + Sleep (1) +end sub + +'******************************************************************************* + +sub createNewColor( aColor() as String ) + ' INPUT : array: (1): Name; (2): Red value; (3): Green value; (4): Blue value + ' OUTPUT: + 'The desired color is selected by name and created. + 'If it already exists, there is a problem + printlog( "createNewColor:: Adding a color to the list: '" + aColor(1) + "'" + Kontext "TabFarben" + FarbName.setText(aColor(1)) + R.SetText(aColor(2)) + G.SetText(aColor(3)) + B.SetText(aColor(4)) + Sleep(1) + Hinzufuegen.Click + Sleep(1) + + Kontext "DuplicateNameWarning" + if DuplicateNameWarning.Exists then + warnlog "createNewColor:: Color already exists." + DuplicateNameWarning.OK + Kontext "NameDlg" + if NameDlg.Exists then + printlog "createNewColor:: Naming dialog shown. Good, cancelling" + NameDlg.Cancel + else + warnlog "createNewColor:: Naming dialog didn't came up." + end if + else + printlog "createNewColor:: New color has been created" + end if +end sub + +'******************************************************************************* + +sub getColorRGB( aColor() as String ) + ' INPUT : array with index 1-4 that will get deleted + ' OUTPUT: array: (1): Name; (2): Red value; (3): Green value; (4): Blue value + 'A RGB color always has four attributes: + 'The name and the three RGB values (0...255) + printlog( "GetColorRGB:: Determining the current color" ) + FarbModell.Select(1) + + aColor(1) = FarbName.GetText() + aColor(2) = R.GetText() + aColor(3) = G.GetText() + aColor(4) = B.GetText() + + printlog( "GetColorRGB:: N = " & aColor(1) ) + printlog( "GetColorRGB:: R = " & aColor(2) ) + printlog( "GetColorRGB:: G = " & aColor(3) ) + printlog( "GetColorRGB:: B = " & aColor(4) ) +end sub + +'******************************************************************************* + +sub compareTwoColorsRGB( aColor() as String ) + ' INPUT : array: (1): Name; (2): Red value; (3): Green value; (4): Blue value + ' and a selected color + ' OUTPUT: + 'Comparision of two colors. Tested values are: + 'Name and three RGB values + 'aColor is the expected value, bColor is the current color + dim i as Integer + dim bColor(4) as String + + printlog( "compareTwoColorsRGB:: Compare saved default color with the current" ) + call getColorRGB(bColor()) + for i = 1 to 4 + if aColor(i) <> bColor(i) then + warnlog( "compareTwoColorsRGB:: " & "(" & i & ") Expected: '" _ + & aColor( i ) & "' found: '" & bColor(i) & "'" ) + else + printlog( "compareTwoColorsRGB:: " & "(" & i & ") OK" ) + endif + next i +end sub + +'******************************************************************************* + +sub ModifyColorRGB( aColor() as String ) + 'A RGB color always has four attributes: + 'The name and the three RGB values (0...255) + + Kontext "TabFarben" + FarbName.SetText( aColor( 1 ) ) + FarbModell.Select( 1 ) + R.SetText( aColor( 2 ) ) + G.SetText( aColor( 3 ) ) + B.SetText( aColor( 4 ) ) + Aendern.Click +end sub + diff --git a/testautomation/framework/tools/includes/pbrowser_tools.inc b/testautomation/framework/tools/includes/pbrowser_tools.inc new file mode 100644 index 000000000000..391c1a3c2456 --- /dev/null +++ b/testautomation/framework/tools/includes/pbrowser_tools.inc @@ -0,0 +1,329 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Tools for working with the property browser for formcontrols +'* +'\****************************************************************************** + +function hOpenPropertyBrowser() as boolean + + '///<h3>Open the BASIC property browser</h3> + + const CFN = "framework::tools::includes::pbrowser_tools.inc::hOpenPropertyBrowser(): " + + kontext "ControlPropertiesTabControl" + if ( ControlPropertiesTabControl.exists() ) then + printlog( "Property Browser is already open, no action taken" ) + hOpenPropertyBrowser() = true + else + if ( hUseAsyncSlot( "ContextProperties" ) <> -1 ) then + kontext "ControlPropertiesTabControl" + if ( ControlPropertiesTabControl.exists( 2 ) ) then + ControlPropertiesTabControl.setPage( TabGeneralControl ) + hOpenPropertyBrowser() = true + else + warnlog( CFN & "Dialog <ControlPropertiesTabControl> is not available" ) + hOpenPropertyBrowser() = false + endif + else + warnlog( CFN & "Could not execute <ContextProperties> slot" ) + hOpenPropertyBrowser() = false + endif + endif + +end function + +'******************************************************************************* + +function hClosePropertyBrowser() as boolean + + const CFN = "framework::tools::includes::pbrowser_tools.inc::hClosePropertyBrowser(): " + printlog( "Closing Property-Browser (if open)" ) + + kontext "ControlPropertiesTabControl" + if ( ControlPropertiesTabControl.exists() ) then + + hUseAsyncSlot( "ContextProperties" ) + + if ( ControlPropertiesTabControl.notExists( 2 ) ) then + hClosePropertyBrowser() = true + else + warnlog( CFN & "Failed to close dialog" ) + hClosePropertyBrowser() = false + endif + else + printlog( "Property browser is not open, no action taken." ) + hClosePropertyBrowser() = true + endif + +end function + +'******************************************************************************* + +function hPBSetControlName( cControl as string ) as boolean + + '///<h3>Name a control, with limited errorhandling</h3> + + '///<i>This function was introduced due to a problem with the property- + '///browser not being open fast enough or just refusing to accept input</i><br><br> + + '///<u>Input</u>: + '///<ol> + '///+<li>Text to be inserted in the control "NameText" (string)</li> + '///</ol> + + '///<u>Returns</u>: + '///<ol> + + '///+<li>Errorcondition</li> + '///<ul> + '///+<li>TRUE: The control name was successfully updated</li> + '///+<li>FALSE: Control is not visible within current context</li> + '///</ul> + + '///</ol> + + const CFN = "hPBSetControlName::" + + '///<u>Description</u>: + '///<ul> + '///+<li>Test that the control "NameText" exists</li> + + ' Note: A number of fallbacks are used here because the entryfield "NameText" + ' is less than reliable. My hope is that one of the methods succeeds. + kontext "TabGeneralControl" + if ( NameText.exists() ) then + '///+<li>Set the new name</li> + hDeleteEntryFieldContent( NameText ) + + ' Name the control and append some Spaces which should be truncated. + printlog( CFN & "Naming control: " & cControl ) + NameText.setText( cControl ) + TabGeneralControl.typeKeys( "<RETURN>" ) + WaitSlot() + + if ( NameText.getText() = cControl ) then + printlog( CFN & "Name is set ok: " & cControl ) + hPBSetControlName() = true + exit function + endif + + ' If the name cannot be set this is in 99% of the cases a timing problem. + ' Here is a (costly) workaround. + qaerrorlog( CFN & "Name not set correctly, retrying" ) + Wait( 300 ) + NameText.setText( cControl ) + TabGeneralControl.typeKeys( "<RETURN>" ) + Wait( 300 ) + + ' Test again, leave function if good + if ( NameText.getText() = cControl ) then + printlog( CFN & "Name is set ok: " & cControl ) + hPBSetControlName() = true + exit function + endif + + warnlog( CFN & "Unable to set control name: " & cControl ) + hPBSetControlName() = false + + else + warnlog( "Unable to name the control." ) + hPBSetControlName() = false + endif + '///</ul> + +end function + +'******************************************************************************* + +function hPBGetControlName( cControl as string ) as boolean + + '///<h3>Verify that the expected control is open</h3> + '///<i>Use hPBSetControlName( string ) to set the name and when you reopen it + '///+ verify that you got the right control wit this function</i><br><br> + + '///<u>Input</u>: + '///<ol> + '///+<li>Name of the control (string)</li> + '///</ol> + + '///<u>Returns</u>: + '///<ol> + + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE: The control has the correct name</li> + '///+<li>FALSE: Any other condition</li> + '///</ul> + + '///</ol> + + '///<u>Description</u>: + '///<ul> + + dim cControlName as string + const CFN = "hPBGetControlName::" + + '///+<li>If "NameText" exists, retrieve its text</li> + kontext "TabGeneralControl" + if ( TabGeneralControl.exists( 1 ) ) then + if ( TabGeneralControl.isVisible() ) then + wait( 300 ) + cControlName = NameText.getText() + + '///+<li>Verify that the name is correct</li> + if ( cControlName = cControl ) then + printlog( CFN & "The name of the control is correct: " & cControl ) + hPBGetControlName() = true + else + warnlog( CFN & "Unexpected control name:" ) + printlog( CFN & "Found....: " & cControlName ) + printlog( CFN & "Expected.: " & cControl ) + hPBGetControlName() = false + endif + else + warnlog( CFN & "Dialog present but tabpage could not be accessed (TabGeneralControl)." ) + hPBGetControlName() = false + endif + else + warnlog( CFN & "Unable to get the name from the control, dialog not accessible (TabGeneralControl)." ) + hPBGetControlName() = false + endif + '///</ul> + +end function + +'******************************************************************************* + +function hSetPBTabPage( iPage as integer ) as boolean + + '///<h3>A small helper to switch between tabpages in the property-browser</h3> + '///<u>Input</u>: + '///<ol> + + '///+<li>Page-ID (integer)</li> + '///<ul> + '///+<li>1 = General page</li> + '///+<li>2 = Events page</li> + '///</ul> + + '///</ol> + + '///<u>Returns</u>: + '///<ol> + + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE on success</li> + '///+<li>FALSE on any error</li> + '///</ul> + + '///</ol> + + '///<u>Description</u>: + '///<ul> + + const CFN = "hSetPBTabPage::" + printlog( CFN & "Enter with option: " & iPage ) + + '///+<li>Switch to the requested page</li> + kontext "ControlPropertiesTabControl" + if ( not ControlPropertiesTabControl.exists( 3 ) ) then + printlog( CFN & "Exit: Control Properties Dialog is not open, aborting" ) + hSetPBTabPage() = false + exit function + else + if ( GVERBOSE ) then + printlog( CFN & "Control Properties Dialog is open" ) + endif + endif + + select case iPage + case 1 + + printlog( CFN & "Switching to control properties tabpage" ) + kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + + kontext "TabGeneralControl" + if ( nametext.exists( 5 ) ) then + printlog( CFN & "Exit: Control properties are open (true)" ) + hSetPBTabPage() = true + exit function + else + printlog( CFN & "Exit: Failed to open Control Properties (false)" ) + hSetPBTabPage() = false + exit function + endif + + case 2 + + printlog( CFN & "Switching to event assignment tabpage" ) + kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabEventsControl + + kontext "TabEventsControl" + if ( PBFocusGained.exists( 5 ) ) then + printlog( CFN & "Exit: Events page is open (true)" ) + hSetPBTabPage() = true + exit function + else + printlog( CFN & "Exit: Failed to open events-page (false)" ) + hSetPBTabPage() = false + exit function + endif + + case else + + printlog( CFN & "Invalid parameter passed to function: " & iPage ) + hSerPBTabPage() = false + exit function + + end select + '///</ul> + +end function + +'******************************************************************************* + +function hDeleteEntryFieldContent( oControl as object ) as boolean + + printlog( "Original name is: " & oControl.getText() ) + + oControl.typeKeys( "<HOME>" ) + oControl.typeKeys( "<SHIFT END>" ) + oControl.typeKeys( "<DELETE>" ) + + if ( oControl.getText() = "" ) then + hDeleteEntryFieldContent() = true + else + hDeleteEntryFieldContent() = false + endif + +end function diff --git a/testautomation/framework/tools/includes/private_environment.inc b/testautomation/framework/tools/includes/private_environment.inc new file mode 100644 index 000000000000..40851aa8bc1a --- /dev/null +++ b/testautomation/framework/tools/includes/private_environment.inc @@ -0,0 +1,335 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Tools to ease working with private environment +'* +'\****************************************************************************** + +function hGetPrivateHttpServer( _proxy as string, _port as string ) as boolean + + + '///<h3>Retrieve the name and port for a private http server</h3><br> + + '///<u>Function parameters:</u><br> + '///<ol> + + '///+<li>Fully qualified server name incl. domain (string)</li> + '///<ul> + '///+<li>The string comes without a protocol part (no http://)</li> + '///</ul> + + '///+<li>Server port (string)</li> + '///<ul> + '///+<li>Please remember limits for integer data type</li> + '///</ul> + + '///</ol> + + + '///<u>Returns:</u><br> + + '///<ol> + '///+<li>Error condition (boolean)</li> + '///<ul> + '///+<li>"TRUE": Data was retrieved successfully</li> + '///+<li>"FALSE": Any error </li> + '///</ul> + '///</ol> + + use "global\tools\includes\optional\t_key_tools.inc" + + const CFN = "hGetPrivateHttpServer::" + dim cFile as string + dim cDataSet( 100 ) as string + dim iErr as integer + + '///<u>Description:</u> + '///<ul> + '///+<li>Get the source file</li> + cFile = hGetPrivateInputFile( false ) + printlog( CFN & "Using input file: " & cFile ) + + '///+<li>Retrieve the information from the datafile</li> + iErr = hGetDataFileSection( cFile, cDataSet(), "http_proxy", "", "" ) + if ( iErr = 0 ) then + hGetPrivateHttpServer() = false + exit function + endif + + '///+<li>Extract the proxy name</li> + _proxy = hGetValueForKeyAsString( cDataSet(), "name" ) + + '///+<li>Append the domain</li> + _proxy = _proxy & hGetValueForKeyAsString( cDataSet(), "domain" ) + + '///+<li>Get the port</li> + _port = hGetValueForKeyAsString( cDataSet() , "port" ) + + '///+<li>Print a log</li> + printlog( CFN & _proxy & ":" & _port ) + '///</ul> + + hGetPrivateHttpServer() = true + +end function + +'******************************************************************************* + +function hGetPrivateFtpServer( _proxy as string, _port as string ) as boolean + + + '///<h3>Retrieve the name and port for a private ftp server</h3><br> + + '///<u>Function parameters:</u><br> + '///<ol> + + '///+<li>Fully qualified server name incl. domain (string)</li> + '///<ul> + '///+<li>The string comes without a protocol part (no ftp://)</li> + '///</ul> + + '///+<li>Server port (string)</li> + '///<ul> + '///+<li>Please remember limits for integer data type</li> + '///</ul> + + '///</ol> + + + '///<u>Returns:</u><br> + + '///<ol> + '///+<li>Error condition (boolean)</li> + '///<ul> + '///+<li>"TRUE": Data was retrieved successfully</li> + '///+<li>"FALSE": Any error </li> + '///</ul> + '///</ol> + + use "global\tools\includes\optional\t_key_tools.inc" + + const CFN = "hGetPrivateFtpServer::" + dim cFile as string + dim cDataSet( 100 ) as string + dim iErr as integer + + '///<u>Description:</u> + '///<ul> + '///+<li>Get the source file</li> + cFile = hGetPrivateInputFile( false ) + printlog( CFN & "Using input file: " & cFile ) + + '///+<li>Retrieve the information from the datafile</li> + iErr = hGetDataFileSection( cFile, cDataSet(), "ftp_proxy", "", "" ) + if ( iErr = 0 ) then + hGetPrivateFtpServer() = false + exit function + endif + + '///+<li>Extract the proxy name</li> + _proxy = hGetValueForKeyAsString( cDataSet(), "name" ) + + '///+<li>Append the domain</li> + _proxy = _proxy & hGetValueForKeyAsString( cDataSet(), "domain" ) + + '///+<li>Get the port</li> + _port = hGetValueForKeyAsString( cDataSet() , "port" ) + + '///+<li>Print a log</li> + printlog( CFN & _proxy & ":" & _port ) + '///</ul> + + hGetPrivateFtpServer() = true + +end function + +'******************************************************************************* + +function hGetPrivateSocksServer( _proxy as string, _port as string ) as boolean + + + '///<h3>Retrieve the name and port for a private socks server</h3><br> + + '///<u>Function parameters:</u><br> + '///<ol> + + '///+<li>Fully qualified server name incl. domain (string)</li> + + '///+<li>Server port (string)</li> + '///<ul> + '///+<li>Please remember limits for integer data type</li> + '///</ul> + + '///</ol> + + + '///<u>Returns:</u><br> + + '///<ol> + '///+<li>Error condition (boolean)</li> + '///<ul> + '///+<li>"TRUE": Data was retrieved successfully</li> + '///+<li>"FALSE": Any error </li> + '///</ul> + '///</ol> + + use "global\tools\includes\optional\t_key_tools.inc" + + const CFN = "hGetPrivateSocksServer::" + dim brc as boolean 'a multi purpose boolean returnvalue + dim cFile as string + dim cDataSet( 100 ) as string + dim iErr as integer + + '///<u>Description:</u> + '///<ul> + '///+<li>Get the source file</li> + cFile = hGetPrivateInputFile( false ) + + '///+<li>Retrieve the information from the datafile</li> + iErr = hGetDataFileSection( cFile, cDataSet(), "socks", "", "" ) + if ( iErr = 0 ) then + hGetPrivateSocksServer() = false + exit function + endif + + '///+<li>Extract the proxy name</li> + _proxy = hGetValueForKeyAsString( cDataSet(), "name" ) + + '///+<li>Append the domain</li> + _proxy = _proxy & hGetValueForKeyAsString( cDataSet(), "domain" ) + + '///+<li>Get the port</li> + _port = hGetValueForKeyAsString( cDataSet() , "port" ) + + '///+<li>Print a log</li> + printlog( CFN & _proxy & ":" & _port ) + '///</ul> + + hGetPrivateSocksServer() = true + +end function + +'******************************************************************************* + +function hGetPrivateInputPath( bVerbose as boolean ) as string + + + '///<h3>Switch the private input path from ../inc/ to ../input/</h3> + + '/// This is part of the effort to allow usage of private data such as + '///+ servernames, paths, login names etc. within a Local Area Network (LAN). + '/// If you have to maintain data of any sort that may not get out to the + '///+ public you will want to put your data into this directory.<br><br> + + '///<u>Input Value:</u><br> + '///<ol> + '///+<li>Toggle verbosity (boolean)</li> + '///<ul> + '///+<li>"TRUE": Print path</li> + '///+<li>"FALSE": Do not print path</li> + '///</ul> + '///</ol> + + '///<u>Return Value:</u><br> + '///<ol> + '///+<li>Path to the private input directory (string)</li> + '///<ul> + '///+<li>Function is not supposed to fail</li> + '///+<li>Fully qualified path to the input directory including last pathseparator</li> + '///</ul> + '///</ol> + + const CFN = "hGetPrivateInputPath::" + dim cPrivateInputPath as string + + '///<u>Description:</u> + '///<ul> + '///+<li>Get the ../inc-path from global variable (assuming path is valid)</li> + cPrivateInputPath = gTesttoolPath & gPrivateEnvironmentLocation + + '///+<li>Append input/ (platform specific)</li> + cPrivateInputPath = cPrivateInputPath & "input/" + cPrivateInputPath = convertpath( cPrivateInputPath ) + + '///+<li>Print the resulting path to the log</li> + if ( bVerbose ) then + printlog( CFN & "Private input directory is: " & cPrivateInputPath ) + endif + + hGetPrivateInputPath() = cPrivateInputPath + '///</ul> + +end function + +'******************************************************************************* + +function hGetPrivateInputFile( bVerbose as boolean ) as string + + + '///<h3>Retrieve the fully qualified path to the datafile</h3><br> + + '///<u>Input:</u> + '///<ol> + '///+<li>Toggle verbosity (boolean)</li> + '///<ul> + '///+<li>"TRUE": Print path</li> + '///+<li>"FALSE": Do not print path</li> + '///</ul> + '///</ol> + + + '///<u>Returns:</u> + + '///<ol> + '///+<li>Fully qualified path to the datafile (string)</li> + '///</ol> + + const CFN = "hGetPrivateInputFile::" + dim brc as boolean 'a multi purpose boolean returnvalue + dim cFile as string + + '///<u>Description:</u> + '///<ul> + '///+<li>Append pathseparator and filename to input path</li> + cFile = hGetPrivateInputPath( false ) & "framework_network.txt" + + '///+<li>Print path and filename to the log</li> + if ( bVerbose ) then + printlog( CFN & "Private datafile is: " & cFile ) + endif + + '///</ul> + + hGetPrivateInputFile() = cFile + +end function + + + diff --git a/testautomation/framework/tools/includes/scriptorganizer_tools.inc b/testautomation/framework/tools/includes/scriptorganizer_tools.inc new file mode 100644 index 000000000000..52503af25bd6 --- /dev/null +++ b/testautomation/framework/tools/includes/scriptorganizer_tools.inc @@ -0,0 +1,291 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Test scripting-organizers / document-attached scripts +'* +'\****************************************************************************** + +function hCreateScriptingObject( cName as string ) as boolean + + '///<h3>Create a new scripting object for the current module</h3> + '///<i>Starting point: Script organizer is open, module selected</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Name of the module (string)</li> + '///<ul> + '///+<li>Any name the organizer can accept</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition</li> + '///<ul> + '///+<li>TRUE on success</li> + '///+<li>FALSE on failure or invalid user input</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + + const CFN = "hNewScriptingObject::" + + '///+<li>Verify that the "Create..." button is enabled</li> + if ( PBCreate.isEnabled() ) then + + '///+<li>Click "Create..." to open the naming dialog</li> + hClickButton( PBCreate ) + + '///+<li>Name the new script</li> + Kontext "ScriptNameDlg" + if ( ScriptNameDlg.exists( 2 ) ) then + + EFObjectName.setText( cName ) + ScriptNameDlg.OK() + hCreateScriptingObject() = true + + endif + + else + printlog( CFN & "Button is disabled" ) + hCreateScriptingObject() = false + endif + + '///+<li>Verify that we are back on the script organizer</li> + kontext "ScriptOrganizer" + if ( not ScriptOrganizer.exists( 2 ) ) then + warnlog( CFN & "Could not return to ScriptOrganizer" ) + hCreateScriptingObject() = false + endif + + '///</ul> + +end function + +'******************************************************************************* + +function hRenameScriptingObject( cName as string ) as boolean + + '///<h3>Rename the selected script</h3> + '///<i>Starting point: Script organizer is open, a script is selected</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>New name of the script</li> + '///<ul> + '///+<li>Any name the script organizer does accept</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition</li> + '///<ul> + '///+<li>TRUE on success</li> + '///+<li>FALSE on failure or invalid user input</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hRenameScriptingObject::" + hRenameScriptingObject() = true + + '///+<li>Click "Rename..." to open the renaming dialog</li> + hClickButton( PBRename ) + + '///+<li>Name the new script</li> + Kontext "ScriptNameDlg" + if ( ScriptNameDlg.exists( 2 ) ) then + + EFObjectName.setText( cName ) + hCloseDialog( ScriptNameDlg, "ok" ) + + '///+<li>Test for any messagebox, try to close it with OK</li> + kontext "active" + if ( active.exists( 1 ) ) then + printlog( CFN & active.getText() ) + hRenameScriptingObject() = false + active.OK() + endif + + endif + + '///+<li>Verify that we are back on the script organizer</li> + kontext "ScriptOrganizer" + if ( not ScriptOrganizer.exists( 2 ) ) then + warnlog( CFN & "Could not return to ScriptOrganizer" ) + hRenameScriptingObject() = false + endif + '///</ul> + +end function + +'******************************************************************************* + +function hDeleteScript( cName as string , bSuccess as boolean ) as boolean + + '///<h3>Delete the selected script</h3> + '///<i>Starting point: Script organizer is open, a script is selected</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Name of the script (string)</li> + '///<ul> + '///+<li>For debugging purpose only, the name will be used for warnlogs</li> + '///+<li>May be an empty string (not recommended)</li> + '///</ul> + '///+<li>Expected result (boolean)</li> + '///<ul> + '///+<li>TRUE: The script is expected to be deleted without warnings/errors</li> + '///+<li>FALSE: The script should not be deletable</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean) - see description</li> + '///<ul> + '///+<li>TRUE on success (expected outcome)</li> + '///+<li>FALSE on failure</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hDeleteScript::" + + '///+<li>Test for the possible conditions:</li> + '///<ol> + '///+<li>Delete is correctly enabled (success)</li> + kontext "ScriptOrganizer" + if ( PBDelete.isEnabled() and bSuccess ) then + + hClickButton( PBDelete ) + kontext "active" + if ( Active.exists( 1 ) ) then + printlog( CFN & active.getText() ) + active.yes() + endif + + kontext "active" + if ( active.exists( 1 ) ) then + qaerrorlog( CFN & "Message: Failed to delete object: " & cName ) + printlog( CFN & active.getText() ) + active.ok() + endif + hDeleteScript() = true + + '///+<li>Delete is disabled correctly (success)</li> + elseif ( ( not PBDelete.isEnabled() ) and ( not bSuccess ) ) then + + printlog( CFN & "Delete-Button disabled for non-deletable object: " & cName ) + hDeleteScript() = true + + '///+<li>Delete is enabled but should not be (failure)</li> + elseif ( PBDelete.isEnabled() and ( not bSuccess ) ) then + + hClickButton( PBDelete ) + + kontext "active" + if ( active.exists( 1 ) ) then + printlog( CFN & "Delete-Button enabled for non deletable object" ) + printlog( CFN & active.getText() ) + active.yes() + endif + + kontext "active" + if ( active.exists( 2 ) ) then + printlog( CFN & "Message: Failed to delete object" ) + printlog( CFN & active.getText() ) + active.ok() + endif + hDeleteScript() = false + + '///+<li>Delete is incorrectly disabled (failure)</li> + elseif ( ( not PBDelete.isEnabled() ) and bSuccess ) then + + printlog( CFN & "Delete-Button disabled for deletable object" ) + hDeleteScript() = false + + else + + warnlog( CFN & "Unknown condition in if-statement" ) + hDeleteScript() = false + + endif + '///</ol> + '///</ul> + +end function + +'******************************************************************************* + +function hOpenScriptOrganizer( iDialog as integer ) as boolean + + '///<h3>Open the ScriptOrganizers and verify that they are open</h3> + '///<i>Starting point: Any document</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Dialog-ID (integer)</li> + '///<ul> + '///+<li>1 = BeanShell organizer</li> + '///+<li>2 = JavaScript organizer</li> + '///+<li>3 = Python script organizer</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition</li> + '///<ul> + '///+<li>TRUE if the expected organizer is open</li> + '///+<li>FALSE if the expected organizer is not open</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hOpenScriptOrganizer::" + + '///<li>Call the associated slot</li> + select case iDialog + case 1 : ToolsMacrosOrganizeMacrosBeanShell + case 2 : ToolsMacrosOrganizeMacrosJavaScript + case 3 : ToolsMacrosOrganizeMacrosPython + end select + + '///<li>Verify that the dialog is open, return TRUE if yes</li> + kontext "ScriptOrganizer" + if ( ScriptOrganizer.exists( 5 ) ) then + hOpenScriptOrganizer() = true + printlog( "Script Organizer is open" ) + else + hOpenScriptOrganizer() = false + warnlog( CFN & "Slot failed, dialog not open" ) + endif + + '///</ul> + +end function diff --git a/testautomation/framework/tools/includes/spadmin_tools.inc b/testautomation/framework/tools/includes/spadmin_tools.inc new file mode 100644 index 000000000000..ad41ccf017d3 --- /dev/null +++ b/testautomation/framework/tools/includes/spadmin_tools.inc @@ -0,0 +1,257 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : helper functions for SPAdmin +'* +'\****************************************************************************** + +function hGetPrinterPosition( cName as string, bWarn as boolean ) as integer + + '///<h3>Find a printer queue in the SpAdmin list</h3> + ' IN: + ' cName = Name of the queue to look for + ' bWarn = if TRUE we warn if the queue does not exist + + const CFN = "hGetPrinterPosition::" + + if ( cName = "" ) then + warnlog( CFN & "Invalid Parameter passed to function: Empty String" ) + hGetPrinterPosition() = -1 + exit function + endif + + dim iCurrentQueue as integer + dim bFound as boolean + dim iPrinterCount as integer + iPrintercount = LBPrinters.getItemCount() + + Kontext "SpAdmin" + bFound = false + + for iCurrentQueue = 1 to iPrinterCount + + wait( 200 ) + + LBPrinters.select( iCurrentQueue ) + if ( LBPrinters.getseltext() = cName ) then + bFound = true + exit for + endif + + next iCurrentQueue + + ' warn if queue was not found and we requested a warning + if ( not bFound and bWarn ) then + iCurrentQueue = 0 + printlog( CFN & "The specified printer queue could not be found" ) + endif + + ' print a message that the printer queue exists + if ( bFound ) then + printlog( CFN & "Printer Queue was found at pos " & iCurrentQueue ) + endif + + Kontext "SpAdmin" + hGetPrinterPosition() = iCurrentQueue + +end function + +'******************************************************************************* + +function hDelPrinter( cPrinterName as string ) as integer + + '///<h3>Delete a printer queue by its name in SpAdmin</h3> + + const CFN = "hDelPrinter::" + + ' delete a printer-queue from the printers-list by name. Only exact matches + ' will be removed. + + ' IN: + ' - Name of the queue + ' OUT: + ' -1 = Bad function call + ' 0 = Success + ' 1 = Confirmation Dialog for Delete is missing + ' 2 = Unable to press "OK" on Confirm-Delete Dialog + ' 3 = Printer queue does not exist so it was not deleted + + if ( cPrinterName = "" ) then + warnlog( CFN & "Invalid Parameter passed to function: Empty String" ) + hDelPrinter() = -1 + exit function + endif + + dim iPrinterPos as integer + + Kontext "SpAdmin" + iPrinterPos = hGetPrinterPosition( cPrinterName , true ) + + if ( iPrinterPos > 0 ) then + + LBPrinters.select( iPrinterPos ) + PBRemove.click() + + try + Kontext "Active" + if ( active.exists( 2 ) ) then + Active.Yes() + printlog( CFN & "Printer Queue deleted" ) + hDelPrinter() = 0 + else + warnlog( CFN & "Confirm Delete Dialog is missing" ) + hDelPrinter() = 1 + endif + catch + warnlog( CFN & "Unable to confirm printer deletion" ) + hDelPrinter() = 2 + endcatch + + else + + printlog( CFN & "The printer queue does not exist" ) + hDelPrinter() = 3 + + endif + + Kontext "SpAdmin" + +end function + +'******************************************************************************* + +function hGetSpadminPath() as string + + hGetSpadminPath() = convertpath( gNetzOfficePath & "program\spadmin" ) + +end function + +'******************************************************************************* + +function hShutdownOffice() + + hFileCloseAll() + FileExit( "SynchronMode", TRUE ) + Wait( 5000 ) + +end function + +'******************************************************************************* + +function hOpenSpadmin() as boolean + + dim cSpadminPath as string : cSpadminPath = hGetSpadminPath() + + try + start( cSpadminPath , "-enableautomation" ) + printlog( "Printer administration start-command was dispatched correctly" ) + hOpenSpAdmin() = true + catch + warnlog( "hOpenSpAdmin(): Failed to open printer administration tool" ) + hOpenSpAdmin() = false + endcatch + +end function + +'******************************************************************************** + +function hWaitForSpAdmin() as boolean + + kontext "SpAdmin" + if ( SpAdmin.exists( 10 ) ) then + printlog( "Printer administration tool is open" ) + hWaitForSpadmin() = true + sleep( 10 ) + else + warnlog( "hWaitForSpAdmin(): The dialog did not open within 10 seconds, aborting" ) + hWaitForSpadmin() = false + endif + +end function + +'******************************************************************************* + +function hCreateFaxDevice( cName as string ) as boolean + + '///<h3>Open the printer creation dialog and create a fax device</h3> + ' The function verifies that the device has been created and returns + ' TRUE on success + '///<ul> + + const CFN = "hCreateFaxDevice::" + + if ( cName = "" ) then + warnlog( CFN & "Invalid Parmeter passed to function: Empty String" ) + hCreateFaxDevice() = false + exit function + endif + + ' quickly greates a fax device accepting all defaults + '///+<li>Click on "New Printer"</li> + Kontext "SpAdmin" + PBNewPrinter.click() + + '///+<li>Click on "Next..."</li> + Kontext "SpPrinterWizard" + PBNext.click() + + '///+<li>Click on "Next..."</li> + Kontext "SpPrinterWizard" + PBNext.click() + + '///+<li>Enter "(PHONE)" as queue command</li> + Kontext "TabPWQueueCommand" + CBCommand.setText( """(PHONE)""" ) + + '///+<li>Click on "Next..."</li> + Kontext "SpPrinterWizard" + PBNext.click() + + '///+<li>Enter a Fax-Printer Name</li> + Kontext "TabPWPrinterName" + EFFaxName.setText( cName ) + + '///+<li>Finish the wizard by pressing OK</li> + Kontext "SpPrinterWizard" + SpPrinterWizard.ok() + + sleep( 1 ) + + '///+<li>Verify that the Queue has been created in SpAdmin</li> + Kontext "SpAdmin" + if ( hgetPrinterPosition( cName ) <> 0 ) then + hCreateFaxDevice() = true + printlog( CFN & "Successfully created Fax device" ) + else + hCreateFaxDevice() = false + warnlog( CFN & "Failed to create a Fax device" ) + endif + '///</ul> + +end function diff --git a/testautomation/framework/tools/includes/template_tools.inc b/testautomation/framework/tools/includes/template_tools.inc new file mode 100644 index 000000000000..20881f3fb85e --- /dev/null +++ b/testautomation/framework/tools/includes/template_tools.inc @@ -0,0 +1,454 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Helper functions to ease usage of templates +'* +'\****************************************************************************** + +function hFindTemplate( sTemplateName as string ) as integer + + '///<H3>Find a template by name in FileNewFromTemplate</H3> + '///<i>Starting point: Templates and Documents dialog</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li> Name of the template to search for (string)</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li> Index of the Template in the containing folder (integer)</li> + '///<ul> + '///+<li>1 ... n : Index of the template (Position in folder)</li> + '///+<li>0 : No template found by given name</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + const CFN = "hFindTemplate::" + + dim brc as boolean + brc = false + dim irc as integer + irc = 0 + + dim iObjectFolder as integer + dim iObjectFolders as integer + + dim iItemCount as integer + dim iCurrentItem as integer + dim cCurrentItem as string + + '///+<li>select the templates from the category list</li> + hSelectCategory( "TEMPLATES" ) + + '///+<li>run through every item in the list to find the template.</li> + ' NOTE: If the name of the template is not unique, the function will find + ' the first occurrence + ' NOTE: As we do not know the name of "My Templates" (it is localized) we + ' need to search all folders.. + iObjectFolders = FileList.getItemCount() + + '///<ul> + for iObjectFolder = 1 to iObjectFolders + + '///+<li>Select the (next) folder</li> + hSelectFileFolder( iObjectFolder , true ) + + '///+<li>Retrieve the number of items within the folder</li> + iItemCount = FileList.getItemCount() + + '///+<li>For each item in the folder do:</li> + '///<ul> + for iCurrentItem = 1 to iItemCount + + '///+<li>Select the (next) item</li> + FileList.select( iCurrentItem ) + + '///+<li>Get the name of the item</li> + cCurrentItem = FileList.getSelText() + + '///+<li>If this is the item we are searching for, exit</li> + if ( cCurrentItem = sTemplateName ) then + irc = iCurrentItem : if ( irc = 0 ) then irc = 1 ' strange hack + brc = true + exit for + endif + + next iCurrentItem + '///</ul> + + '///+<li>Exit the outer loop</li> + if ( brc ) then + exit for + endif + + '///+<li>Click "Up one level"</li> + UpOneLevel.click() + + next iObjectFolder + '///</ul> + + if ( brc ) then + printlog( CFN & "Template found: " & cCurrentItem ) + else + printlog( CFN & "Template could not be found." ) + endif + + '///+<li>Return the index of the requested template</li> + hFindTemplate() = irc + '///</ul> + +end function + +'******************************************************************************* + +function hSelectCategory( cCategory as string ) as boolean + + '///<h3>Select a category from the left pane of the templates dialog</h3> + '///<i>Requires: Templates and Documets dialog must be open</i><br> + '///<u>Input</u>: Category (string): + '///<ul> + '///+<li>NEWDOCUMENTS to select New Documents</li> + '///+<li>TEMPLATES to select Templates</li> + '///+<li>MYDOCUMENTS to select My Documents</li> + '///+<li>SAMPLES to select Samples</li> + '///</ul> + '///<u>Returns</u>: Alwas TRUE, no errorhandling + + Kontext "TemplateAndDocuments" + if ( TemplateAndDocuments.exists( 2 ) ) then + Wait( 500 ) + Category.typeKeys( "<HOME>" ) + wait( 500 ) + + if ( UCASE( cCategory ) = "NEWDOCUMENTS" ) then + ' do nothing, the selection should be on this item + + elseif ( UCASE( cCategory ) = "TEMPLATES" ) then + Category.typeKeys( "<DOWN>" ) + + elseif ( UCASE( cCategory ) = "MYDOCUMENTS" ) then + Category.typeKeys( "<DOWN>" ) + Category.typeKeys( "<DOWN>" ) + + elseif ( UCASE( cCategory ) = "SAMPLES" ) then + Category.typeKeys( "<DOWN>" ) + Category.typeKeys( "<DOWN>" ) + Category.typeKeys( "<DOWN>" ) + endif + + hSelectCategory() = true + else + warnlog( "TemplateAndDocuments dialog did not open" ) + endif + +end function + +'*************************************************************************** + +function hSelectFileFolder( iFolder as integer , bVerbose as boolean ) as integer + + '///<h3>Select a folder on the templates dialog's right pane by index</h3> + '///<i>Requires: Templates and Documents dialog must be open</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Index of the folder to be selected on the categories-pane (integer)</li> + '///<ul> + '///+<li>Must be > 0</li> + '///</ul> + '///+<li>Turn printlog on for debugging purpose (boolean)</li> + '///<ul> + '///+<li>TRUE : Be verbose</li> + '///+<li>FALSE : Run silent</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Number of items in the selected folder (integer)</li> + '///<ul> + '///+<li>Must be > 0</li> + '///</ul> + '///</ol> + + '///<u>Description</u>: + '///<ul> + dim iItems as integer + dim cFolder as string + + Kontext "TemplateAndDocuments" + + '///+<li>Select the entry with the given index</li> + FileList.select( iFolder ) + + '///+<li>Retrieve the name of the selected object</li> + cFolder = FileList.getText() + + '///+<li>Press return</li> + FileList.typeKeys( "<return>" ) + wait( 500 ) + + '///+<li>Get the number of items in the current folder</li> + iItems = FileList.getItemCount() + + '///+<li>Print a comment to the log if specified</li> + if ( bVerbose ) then + printlog( " * " & cFolder & " contains " & iItems & " items." ) + endif + + '///+<li>Return the number of items</li> + hSelectFileFolder() = iItems + '///</ul> + +end function + +'******************************************************************************* + +function hGetFileFolderName( iFolder as integer ) as string + + '///<h3>Get the name of the currently selected folder on templates dialog</h3> + '///<i>Requires: Templates and Documents dialog must be open</i><br> + '///<u>Input</u>: Index of the desired folder<br> + '///<u>Returns</u>: Name of the selected folder + + Kontext "TemplateAndDocuments" + FileList.select( iFolder ) + WaitSlot() + hGetFileFolderName() = FileList.getText() + WaitSlot() + +end function + +'******************************************************************************* + +function hSelectDocumentObject( iTitle as integer , iMode as integer ) as string + + const CFN = "hSelectDocumentObject::" + + '///<h3>Open or edit sample/template from the templates dialog</h3> + '///<i>Requires: Templates and Documents dialog must be open</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Index of the folder to be selected on the categories-pane (integer)</li> + '///<ul> + '///+<li>Valid positive index</li> + '///</ul> + '///+<li>Mode in which to open the template (integer)</li> + '///<ul> + '///+<li>0 = Do not open the object, just return its name</li> + '///+<li>1 = Open a new document based on the selected Template</li> + '///+<li>2 = edit the template (unsupported)</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ul> + '///+<li>The name of the selected item (string)</li> + '///</ul> + '///<u>Description</u>: + '///<ul> + + dim cTitle as string + dim brc as boolean + dim iObjectCount as integer + + Kontext "TemplateAndDocuments" + + '///+<li>Get the title of the selected object</li> + cTitle = hGetFileFolderName( iTitle ) + + '///+<li>Count the number of objects in the list</li> + iObjectCount = FileList.getItemCount() + printlog( CFN & "Title: " & cTitle ) + + select case iMode + case 0 ' do not load the document, return the title and exit the function + hSelectDocumentObject() = cTitle + exit function + case 1 ' open new document based on the template + WaitSlot() + kontext "TemplateAndDocuments" + FileList.typeKeys( "<return>" ) + WaitSlot( 5000 ) + + try + kontext "TemplateAndDocuments" + if ( TemplateAndDocuments.exists() ) then + '///+<li>If yes: Try to determine if it is a new folder</li> + if ( hIsObjectAFolder( iObjectCount ) ) then + hSelectDocumentObject() = "Folder" + exit function + endif + + endif + catch + endcatch + + case 2 : warnlog( "Unsupported option: Edit template" ) + + end select + + hFileWait() + hHandleActivesOnLoad( 2, false ) + brc = hHandleInitialDialogs() + + '///+<li>If all initial dialogs were handled correctly, return the title</li> + if ( brc ) then + hSelectDocumentObject() = cTitle + else + hSelectDocumentObject() = "" + endif + '///</ul> + +end function + +'******************************************************************************* + +function hIsTemplateDialogClosed() as boolean + + const CFN = "hIsTemplateDialogClosed::" + '///<h3>Test whether the Templates and Documents dialog is closed after executing an object</h3> + '///<i>Requires: Templates and Documents dialog must be open</i><br> + '///<u>Returns</u>: + '///<ul> + '///+<li>TRUE if the Templates and Documents dialog cannot be found</li> + '///+<li>FALSE if the selected object was a foder (Templates and Documents still open</li> + '///</ul> + + dim iTry as integer : iTry = 0 + + + if ( WaitSlot( 2000 ) = WSFinished ) then + kontext "TemplateAndDocuments" + try + if ( TemplateAndDocuments.exists() ) then + printlog( CFN & "Dialog still open. Maybe we opened a folder" ) + hIsTemplateDialogClosed() = false + exit function + else + printlog( CFN & "Regular object. Dialog is closed" ) + hIsTemplateDialogClosed() = true + exit function + endif + catch + warnlog( "Failure to query Templates and Documents dialog" ) + hIsTemplateDialogClosed() = true + endcatch + else + warnlog( "Slot not finished within 2000 msec" ) + hIsTemplateDialogClosed() = true + endif + +end function + +'******************************************************************************* + +function hIsObjectAFolder( iObjects as integer ) as boolean + + '///<h3>Test whether the "Chapters" folder has been selected</h3> + '///<i>E.g. the Chapters-folder belongs to a master document and must be skipped. + '///+ To didentify this folder, the number of items is checked (here: 4) which + '///+ should be unique (all other folders have more items)</i><br> + '///<i>Requires: Templates and Documents dialog must be open</i><br> + '///<u>Input</u>. Number of objects in the folder (integer)<br> + '///<u>Returns</u>: TRUE if number of items matches iObjects (boolean)<br> + '///<u>Description</u>: + '///<ul> + + ' NOTE: This function should only handle one folder called "Chapters" + ' below "Text Documents". We do not want to load the chapters + ' separately, they are a part of a Master-Document and will be + ' loaded at another time. + ' To find out whether we are in a new folder or not, the number + ' of objects in the parent folder is compared to the number in the + ' current. This is a hack with a good probability to work. + + const CFN = "hIsObjectAFolder::" + dim iCurrentObjects as integer + + if ( iObjects < 1 ) then + warnlog( CFN & "Invalid Objectcount passed to function: " & iObjects ) + warnlog( CFN & "Defaulting to 1 -> outcome is undefined" ) + iObjects = 1 + endif + + kontext "TemplateAndDocuments" + '///+<li>Compare the objectcount. If different, this is another folder</li> + '///+<li>If the number is unchanged, we have an unknown error -> crash</li> + iCurrentObjects = Filelist.getItemCount() + + if ( iCurrentObjects <> iObjects ) then + printlog( CFN & "Object appears to be a folder with " & iCurrentObjects & " items" ) + hIsObjectAFolder() = true + else + warnlog( CFN & "Unknown error: Objectcount is unchanged" ) + hIsObjectAFolder() = false + endif + + '///</ul> + +end function + +'******************************************************************************* + +function hDeleteUserTemplates() as integer + + ' Recommendation: Use outside of testcase + + '///<h3>Delete all files located in the user templates directory</h3> + '///<i>Uses hDeleteFile tzo remove all files below gOfficePath\user\template</i><br> + '///<u>Input</u>: Nothing<br> + '///<u>Returns</u>: Number of deleted objects<br> + '///<u>Description</u>: + '///<ul> + + const CFN = "hDeleteUserTemplates::" + + dim iFileCount as integer + dim aFileList( 200 ) as string + dim sPath as string + dim iCounter as integer + + '///+<li>Set the path to the user-templates (default location)</li> + sPath = convertpath( gOfficePath & "user\template" ) + + '///+<li>Load the list of files into an array</li> + iFileCount = GetFileList( sPath, "*.*", aFileList() ) + printlog( CFN & "Found " & iFileCount & " file(s)." ) + + '///+<li>Delete each file and print the result to the log</li> + for iCounter = 1 to iFileCount + + hDeleteFile( aFileList( iCounter ) ) + + next iCounter + + '///+<li>Return the number of files that was found in the templates directory</li> + hDeleteUserTemplates() = iFileCount + + '///</ul> + +end function diff --git a/testautomation/framework/tools/includes/toolbar_tools.inc b/testautomation/framework/tools/includes/toolbar_tools.inc new file mode 100644 index 000000000000..d3539abf8a37 --- /dev/null +++ b/testautomation/framework/tools/includes/toolbar_tools.inc @@ -0,0 +1,516 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : global update test (Standardbar) +'* +'\*************************************************************************** + +function hAccessStandardBar() as boolean + + '///<h3>Verify that the Standard Bar exists</h3> + '///<i>This function works for all gApplications</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE if StandardBar exists</li> + '///+<li>FALSE if standardBar does not exist</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + const CFN = "hAccessStandardBar::" + dim brc as boolean + + printlog( CFN & "Enter" ) + + '///+<li>Open a new document</li> + hCreateDocument() + + '///+<li>Try to access the standardbar (query .exists())</li> + 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 + + '///+<li>Close the navigator</li> + kontext "Navigator" + hCloseDialog( Navigator, "close,optional" ) + + '///+<li>Close the document</li> + hDestroyDocument() + hAccessStandardBar() = brc + printlog( CFN & "Exit" ) + '///</ul> + +end function + +'******************************************************************************* + +function hResetStandardBar() as boolean + + '///<h3>Reset the Standard Bar to default configuration</h3> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>Always TRUE as no errorconditions are handled yet</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + 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" ) + + '///+<li>Create a new document</li> + hInitSingleDoc() + printlog " - Standardbar" + + kontext "standardbar" + if ( Standardbar.exists() ) then + + '///+<li>Open the context menu on Standardbar</li> + Standardbar.OpenContextmenu + sleep( MIN_STATIC_DELAY ) + + '///+<li>Click on 2. entry (Cutomize Toolbar)</li> + hMenuselectNr ( TOOLBAR_MENUITEM_CUSTOMIZE ) + sleep( MIN_STATIC_DELAY ) + + kontext + Active.SetPage TabCustomizeToolbars + sleep( MIN_STATIC_DELAY ) + + '///+<li>Toggle to 'Toolbars' tab page.</li> + kontext "TabCustomizeToolbars" + if TabCustomizeToolbars.Exists( DEFAULT_DELAY ) then + sleep( MIN_STATIC_DELAY ) + + '///+<li>Press in first section '... Toolbars' the 'toolbar'-button</li> + MenuBtn.Click + sleep( MIN_STATIC_DELAY ) + + '///+<li>A drop down menu will be opened.</li> + '///+<li>Select the first enabled menu entry which should be 'Restore...'</li> + hMenuSelectNr( MENUITEM_RESTORE ) + sleep( MIN_STATIC_DELAY ) + + kontext + if ( active.exists( DEFAULT_DELAY ) ) then + if ( Active.GetRT = EXPECTED_RESOURCE_ID ) then + + '///+<li>Press Yes button on verification dialog.</li> + Active.Yes() + end if + else + warnlog( "No verification comes up if the RESET button has been pressed!" ) + end if + + '///+<li>Close 'Toolbars' tab page and the dialog with OK.</li> + 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 + + '///+<li>Close document.</li> + hDestroyDocument() + hResetStandardBar() = true + printlog( CFN & "Exit" ) + '///</ul> + +end function + +'******************************************************************************* + +function hStandardbarItemGetCount() as integer + + '///<h3>Update test: Get the number of items in the StandardBar</h3> + '///<i>Starting point: Any plain document</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Number of items on the toolbar (integer)</li> + '///<ul> + '///+<li>No errorhandling is done. Beware.</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim iToolbarItemsCurrent as integer + const DEFAULT_TOOLBAR_ITEMCOUNT = 30 + const WEBLOG_PUBLISHER = 2 + + const CFN = "hStandardbarItemGetCount::" + + gApplication = "WRITER" + printlog( CFN & "Enter" ) + + '///+<li>Look for additional icons on the standardbar (through extensions)</li> + printlog( CFN & "Count all items at the Standardbar" ) + + '///+<li>Open the context menu on the Standardbar</li> + Kontext "Standardbar" + Standardbar.OpenContextmenu() + + '///+<li>Select the 1. entry</li> + hMenuselectNr( 1 ) + + '///+<li>Count all entries ( there must be 30 entries )</li> + 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 + + '///+<li>close the context menu</li> + hMenuClose() + hStandardbarItemGetCount() = iToolbarItemsCurrent + printlog( CFN & "Exit" ) + '///</ul> + +end function + +'******************************************************************************* + +function hToggleToolbarItem( iMenuPos as integer ) + + '///<h3>Update test: Toggle an icon on the Standardbar (on/off)</h3> + '///<i>Starting point: Any plain document</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Position of the item in the menu (integer)</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hToggleToolbarItem::" + const INVISIBLE_ITEMS_MODIFIER = 3 + dim iItemsInMenu as integer + + printlog( CFN & "Enter with option (Menu position): " & iMenuPos ) + + '///+<li>Open the context menu of the standard bar</li> + Kontext "Standardbar" + Standardbar.OpenContextmenu() + + '///+<li>Retrieve the number of items in the menu</li> + 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 + '///+<li>Take the number of items -3, select the entry</li> + hMenuselectNr( iItemsInMenu - INVISIBLE_ITEMS_MODIFIER ) + + '///+<li>Select the provided menu position</li> + hMenuselectNr( iMenuPos ) + printlog( CFN & "Exit" ) + '///</ul> + +end function + +'******************************************************************************* + +function hStandardbarLoadUrl() as boolean + + '///<h3>Update test: Access the url-entryfield</h3> + '///<i>Starting point: Any plain document</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + + ' 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" ) + + '///+<li>Write to URL-Filed (fails: Entryfiled is not visible)</li> + 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 + + '///+<li>add the control to the standardbar</li> + printlog( CFN & "activate load URL" ) + hToggleToolbarItem( ITEM_MENU_POSITION ) + + '///+<li>verify its existence by entering some text</li> + 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 + + '///+<li>remove the control from the standardbar</li> + printlog( CFN & "Deactivate load URL" ) + hToggleToolbarItem( ITEM_MENU_POSITION ) + Kontext "Standardbar" + + '///+<li>try to modify non existing object, failure expected</li> + 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" ) + '///</ul> + +end function + +'******************************************************************************* + +function hStandardbarNewDialog() + + '///<h3>Update test: New from Template via StandardBar</h3> + '///<i>Starting point: Plain document</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + 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" ) + + '///+<li>Click on "New from Template"-button (fails, it is not visible)</li> + 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 + + '///+<li>add the control to the standardbar</li> + printlog( CFN & "activate New from Template button" ) + hToggleToolbarItem( ITEM_MENU_POSITION ) + + '///+<li>click the button</li> + for iTry = 1 to TEMPLATE_DIALOG_MAX_RETRIES + + Kontext "Standardbar" + hClickButton( NeuDialog ) + + '///+<li>handle possible dialogs (there should never be one)</li> + 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 + + '///+<li>close the templates and samples dialog</li> + 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 + + + '///+<li>finally remove the button from the toolbar</li> + printlog( CFN & "Deactivate New from Template button" ) + hToggleToolbarItem( ITEM_MENU_POSITION ) + Kontext "Standardbar" + '///</ul> + +end function + +'******************************************************************************* + +function hStandardbarSaveAs() + + '///<h3>Update test: SaveAs button on StandardBar</h3> + '///<i>Starting point: Any plain document</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Description</u>: + '///<ul> + + + dim bBreakOnError as boolean + + const ITEM_MENU_POSITION = 6 + const CFN = "hStandardbarSaveAs::" + + printlog( CFN & "Enter" ) + + '///+<li>Click on SaveAs (fails, item is not visible)</li> + 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 + + '///+<li>Add the control to the standardbar</li> + printlog( CFN & "Activate 'Save As' button" ) + hToggleToolbarItem( ITEM_MENU_POSITION ) + + '///+<li>Click the button</li> + Kontext "Standardbar" + hWaitForObject( SpeichernAls , 5000 ) + SpeichernAls.click() + + '///+<li>Close the save-as dialog</li> + 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 + + '///+<li>Remove the button from the toolbar</li> + printlog( CFN & "Deactivate 'Save as' button" ) + hToggleToolbarItem( ITEM_MENU_POSITION ) + + endif + + Kontext "Standardbar" + printlog( CFN & "Exit" ) + '///</ul> + +end function + + + + diff --git a/testautomation/framework/tools/includes/webtools.inc b/testautomation/framework/tools/includes/webtools.inc new file mode 100644 index 000000000000..7904c4532de1 --- /dev/null +++ b/testautomation/framework/tools/includes/webtools.inc @@ -0,0 +1,153 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Tools to ease working with web functionality +'* +'\****************************************************************************** + +function hSetProxies( HTTP_Server as string, HTTP_Port as string, _ + FTP_Server as string, FTP_Port as string, _ + NoProxyFor as string ) as integer + + use "global\tools\includes\optional\t_control_objects.inc" + + '///<h3>Configure proxy settings via Tools/Options Internet page</h3> + '///<i>Starting point is a plain document of any type</i><br> + '///<i>If all fields are empty The proxy will be set to "None"</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>HTTP Server name (string)</li> + '///<ul> + '///+<li>As name, e.g. myProxy.com (FQDN recommended)</li> + '///+<li>As IP, e.g. 192.168.1.254</li> + '///+<li>Non optional parameter which may be an empty string</li> + '///+<li>Requires HTTP Server port to be set</li> + '///</ul> + '///+<li>HTTP Server port</li> + '///<ul> + '///+<li>e.g. 8080, 3128</li> + '///+<li>Non optional parameter which may be an empty string</li> + '///</ul> + '///+<li>FTP Server name (string)</li> + '///<ul> + '///+<li>As name, e.g. myProxy.com (FQDN recommended)</li> + '///+<li>As IP, e.g. 192.168.1.254</li> + '///+<li>Non optional parameter which may be an empty string</li> + '///+<li>Requires FTP Server port to be set</li> + '///</ul> + '///+<li>FTP Server port</li> + '///<ul> + '///+<li>e.g. 8080, 3128</li> + '///+<li>Non optional parameter which may be an empty string</li> + '///</ul> + '///+<li>Exclude domains (string)</li> + '///<ul> + '///+<li>e.g. .Sun.COM;.Germany.Sun.Com;MyServer.Sun.Com</li> + '///+<li>Non optional parameter which may be an empty string</li> + '///</ul> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcondition</li> + '///<ul> + '///+<li>0 = Successfully set/unset proxies</li> + '///+<li>1 - 5 = Number of failed actions</li> + '///</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hSetProxies::" + dim iControlStatus as integer + dim irc as integer + irc = 0 + + '///+<li>Open Tools/Options</li> + ToolsOptions + + '///+<li>Go to the Proxy Settings (Internet/Proxy)</li> + hToolsOptions( "Internet", "Proxy" ) + + '///+<li>Select Manual Proxy (3. Item in the list)</li> + ProxyServer.select( 3 ) + + '///+<li>Set the new values</li> + '///<ol> + + '///+<li>HTTP-Proxy</li> + iControlStatus = hSetControlValue( HTTPProxy , HTTP_Server ) + if ( iControlStatus <> 0 ) then + qaerrorlog( CFN & "Failed to set HTTP-Proxy" ) + irc = irc + 1 + endif + + '///+<li>HTTP-Port</li> + iControlStatus = hSetControlValue( HTTPPort , HTTP_Port ) + if ( iControlStatus <> 0 ) then + qaerrorlog( CFN & "Failed to set HTTP-Port" ) + irc = irc + 1 + endif + + '///+<li>FTP-Proxy</li> + iControlStatus = hSetControlValue( FTPProxy , FTP_Server ) + if ( iControlStatus <> 0 ) then + qaerrorlog( CFN & "Failed to set FTP-Proxy" ) + irc = irc + 1 + endif + + '///+<li>FTP-Port</li> + iControlStatus = hSetControlValue( FTPPort , FTP_Port ) + if ( iControlStatus <> 0 ) then + qaerrorlog( CFN & "Failed to set FTP-Port" ) + irc = irc + 1 + endif + + '///+<li>Exclusion list</li> + iControlStatus = hSetControlValue( NoProxy , NoProxyFor ) + if ( iControlStatus <> 0 ) then + qaerrorlog( CFN & "Failed to set exclusion list" ) + irc = irc + 1 + endif + '///</ol> + + if ( irc = 0 ) then + printlog( CFN & "Successfully updated proxy configuration" ) + endif + + '///+<li>Close Tools/Options</li> + Kontext "ExtrasOptionenDlg" + ExtrasOptionenDlg.OK() + + hSetProxies() = irc + '///</ul> + + +end function + + diff --git a/testautomation/framework/tools/includes/window_tools.inc b/testautomation/framework/tools/includes/window_tools.inc new file mode 100644 index 000000000000..649935dd574a --- /dev/null +++ b/testautomation/framework/tools/includes/window_tools.inc @@ -0,0 +1,86 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : Tools to handle windows/frames +'* +'\****************************************************************************** + +function hMaximizeDocument() as boolean + + + '///<h3>Maximize a document window</h3> + '///<i>Note</i>: The function runs silent (no logs written)<br><br> + '///<u>Return Value:</u><br> + + '///<ol> + '///+<li>Errorcondition (boolean)</li> + '///<ul> + '///+<li>TRUE if the window claims to have been maximized</li> + '///+<li>FALSE on invalid gApplication (with warning)</li> + '///+<li>FALSE if the window thinks it has not been maximized</li> + '///</ul> + '///</ol> + + const CFN = "hMaximizeDocument::" + dim brc as boolean 'a multi purpose boolean returnvalue + + '///<u>Description:</u> + '///<ul> + '///+<li>Maximize the documentwindow depending on gApplication</li> + select case ( ucase( gApplication ) ) + case "WRITER" : Kontext "DocumentWriter" + DocumentWriter.maximize() + brc = DocumentWriter.isMaximized() + case "CALC" : Kontext "DocumentCalc" + DocumentCalc.maximize() + brc = DocumentCalc.isMaximized() + case "IMPRESS" : Kontext "DocumentImpress" + DocumentImpress.maximize() + brc = DocumentImpress.isMaximized() + case "DRAW" : Kontext "DocumentDraw" + DocumentDraw.maximize() + brc = DocumentDraw.isMaximized() + case "MATH" : Kontext "DocumentMath" + DocumentMath.maximize() + brc = DocumentMath.isMaximized() + case "MASTERDOCUMENT" : Kontext "DocumentWriter" + DocumentWriter.maximize() + brc = DocumentWriter.isMaximized() + case "HTML" : Kontext "DocumentWriter" + DocumentWriter.maximize() + brc = DocumentWriter.isMaximized() + case else : qaerrorlog( CFN & "Invalid documenttype" ) + brc = false + end select + + '///</ul> + + hMaximizeDocument() = brc + +end function diff --git a/testautomation/framework/tools/includes/wizards.inc b/testautomation/framework/tools/includes/wizards.inc new file mode 100644 index 000000000000..a32a77f4518f --- /dev/null +++ b/testautomation/framework/tools/includes/wizards.inc @@ -0,0 +1,274 @@ +'encoding UTF-8 Do not remove or change this line! +'******************************************************************************* +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/****************************************************************************** +'* +'* owner : gregor.hartmann@oracle.com +'* +'* short description : helper functions for the wizards +'* +'\****************************************************************************** + +function hWaitForWizard() as integer + + const CFN = "hWaitForWizard::" + const MAXTRIES = 10 + + '///<h3>Wait for any wizard to open</h3> + '///<i>Uses: framework/tools/input/menuentries.txt</i><br> + '///<i>NOTE: Not all wizards are known to this function yet.</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Unique ID of the open wizard</li> + '///<ul> + '///+<li>0: In case of any error</li> + '///+<li>1-n: The unique ID of the currently open wizard (integer)</li> + '///+</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + dim iOpen as integer + dim iWait as integer + + '///+<li>Determine the open wizard by trying wizard.exists()</li> + for iWait = 1 to MAXTRIES + + iOpen = 0 + + kontext "AutopilotLetter" + if ( AutopilotLetter.exists() ) then + printlog( CFN & "Autopilot Letter is open" ) + iOpen = hGetWizardParams( "LETTER" , "ID" ) + exit for + endif + + kontext "AutopilotFax" + if ( AutopilotFax.exists() ) then + printlog( CFN & "Autopilot Fax is open" ) + iOpen = hGetWizardParams( "FAX" , "ID" ) + exit for + endif + + kontext "AutopilotAgenda" + if ( AutopilotAgenda.exists() ) then + printlog( CFN & "Autopilot Agenda is open" ) + iOpen = hGetWizardParams( "AGENDA" , "ID" ) + exit for + endif + + Kontext "MailMergeWizard" + if ( MailMergeWizard.exists() ) then + printlog( CFN & "Mailmerge Wizard is open" ) + iOpen = hGetWizardParams( "MAILMERGE" , "ID" ) + exit for + endif + + Kontext "AutopilotPraesentation1" + if ( AutopilotPraesentation1.exists() ) then + printlog( CFN & "Presentation Wizard is open" ) + iOpen = hGetWizardParams( "IMPRESS" , "ID" ) + exit for + endif + + Kontext "AutoPilotEuroKonverter" + if ( AutoPilotEuroKonverter.exists() ) then + printlog( CFN & "Euro Converter is open" ) + iOpen = hGetWizardParams( "EUROCONV" , "ID" ) + exit for + endif + + Kontext "DocumentConverter" + if ( DocumentConverter.exists( 1 ) ) then + printlog( CFN & "Document Converter is open" ) + iOpen = hGetWizardParams( "DOCCONV" , "ID" ) + exit for + endif + + next iWait + + hWaitForWizard() = iOpen + '///</ul> + +end function + +'******************************************************************************* + +function hSetTemplateSavePath( cFile as string ) as integer + + '///<h3>Set the template save-path</h3> + '///<i>Starting point: Last page on FAX-, AGENDA- or LETTERWIZARD</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Fully qualified path to target template name (string)</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcode (integer)</li> + '///<ul> + '///+<li>0: No errors, path has been set correctly</li> + '///+<li>1: The "SaveAs"-dialog did not open</li> + '///+<li>2: The "SaveAs"-button could not be clicked</li> + '///+<li>-1: Incorrect call to function</li> + '///+</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + const CFN = "hSetTemplateSavePath::" + + dim iErr as integer + + '///+<li>Validate function parameter</li> + if ( cFile = "" ) then + printlog( CFN & "Invalid parameter passed to function: Empty Path" ) + hSetTemplateSavePath() = -1 + exit function + endif + + printlog( CFN & "Open the file-save-dialog" ) + + '///+<li>Click on the save-as button</li> + try + SaveAsButton.click() + + kontext "SpeichernDlg" + if ( SpeichernDlg.exists( 2 ) ) then + printlog( CFN & "File Save dialog shown. Good." ) + iErr = 0 + else + qaerrorlog( "#i49515# FileSave dialog does not open" ) + iErr = 1 + endif + catch + qaerrorlog( "#i58297# Cannot click SaveAs button" ) + iErr = -1 + endcatch + + '///+<li>Enter a filename</li> + '///+<li>Save the file</li> + if ( iErr = 0 ) then + call dialogtest( SpeichernDlg ) + + printlog( CFN & "Name the file" ) + DateiName.setText( cFile ) + + printlog( CFN & "Save the template" ) + speichern.click() + endif + + hSetTemplateSavePath() = iErr + '///</ul> + +end function + +'******************************************************************************* + +function hHandleSaveError() as integer + + const CFN = "hHandleSaveError::" + + '///<h3>Handle errors while saving a template</h3> + '///<i>Starting point: Save-As dialog from last page on FAX-, AGENDA- or LETTERWIZARD</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Errorcode (integer)</li> + '///<ul> + '///+<li>0: No unexpected dialogs were displayed</li> + '///+<li>1: Unexpected Active closed by clicking YES</li> + '///+<li>2: Unexpected Active closed by clicking OK</li> + '///+</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + '///<li>Check for unexpected messagebox: file could not be saved</li> + '///<li>Close the dialog either with YES or OK</li> + '///</ul> + + kontext "active" + if ( active.exists( 2 ) ) then + printlog( CFN & "Unexpected MsgBox: " & active.getText() ) + try + active.ok() + hHandleSaveError() = 2 + catch + active.yes() + hHandleSaveError() = 1 + endcatch + else + hHandleSaveError() = 0 + endif + +end function + +'******************************************************************************* + +function hClickNextButton() as boolean + + '///<h3>Click the Next-Button on some wizards</h3> + '///<i>Starting point: Last page on FAX-, AGENDA- or LETTERWIZARD</i><br> + '///<i>Refer to inline documentation for further information</i><br> + '///<u>Input</u>: + '///<ol> + '///+<li>Nothing</li> + '///</ol> + '///<u>Returns</u>: + '///<ol> + '///+<li>Status (boolean)</li> + '///<ul> + '///+<li>TRUE: Everything is ok</li> + '///+<li>FALSE: Any error</li> + '///+</ul> + '///</ol> + '///<u>Description</u>: + '///<ul> + + + const CFN = "hClickNextButton::" + hClickNextButton() = true + + '///+<li>Click the "Next"-button</li> + if ( hClickButton( NextButton ) = -1 ) then + hClickNextButton() = false + else + '///+<li>Handle the "Document Creation"-dialog (Mailmerge Wizard)</li> + kontext "active" + if ( active.exists( 1 ) ) then + ' The dialog must disappear within 10 seconds + if ( not active.notExists( 10 ) ) then hClickNextButton() = false + endif + endif + '///</ul> + +end function + |