summaryrefslogtreecommitdiff
path: root/testautomation/framework/optional/includes/basic_modulenames.inc
diff options
context:
space:
mode:
Diffstat (limited to 'testautomation/framework/optional/includes/basic_modulenames.inc')
-rwxr-xr-x[-rw-r--r--]testautomation/framework/optional/includes/basic_modulenames.inc310
1 files changed, 106 insertions, 204 deletions
diff --git a/testautomation/framework/optional/includes/basic_modulenames.inc b/testautomation/framework/optional/includes/basic_modulenames.inc
index 28c260642482..f874fd93976a 100644..100755
--- a/testautomation/framework/optional/includes/basic_modulenames.inc
+++ b/testautomation/framework/optional/includes/basic_modulenames.inc
@@ -33,68 +33,50 @@
testcase tBasicIdeModuleNames
+ printlog( "Modulenames in BASIC IDE" )
+
+ const CMODULE_VALID1 = "tValidName"
+ const CMODULE_VALID2 = "tValidToo"
+ const TEST_MACRO = "TTMacro1"
+
+ const RC_SUCCESS = 0
+ const RC_FAILURE = 1
+ const ERR_NO_LINES_INSERTED = 0
- dim rc as integer
- dim brc as boolean
- dim i as integer
dim iCurrentName as integer
- const CMODULE = "TModuleNames"
dim cTabName as string
gApplication = "WRITER"
hCreateDocument()
- ' ------ prerequisites ---------
-
- brc = hInitBasicIde( CMODULE )
-
-
- brc = hInsertMacro( 1 )
- if ( rc <> 0 ) then
- warnlog( "Failed to insert macro" )
- endif
+ hInitBasicIde( CMODULE_VALID1 )
+ if ( hInsertMacroFromFile( TEST_MACRO ) > ERR_NO_LINES_INSERTED ) then
- cTabName = hGetTabNameFromOrganizer()
+ cTabName = hGetTabNameFromOrganizer()
+
+ Randomize
+ iCurrentName = Int( 24 * RND ) + 1 ' Range from 1 to 24
+
+ printlog( "Trying with invalid modulename" )
+ cTabName = hCreateInvalidModuleName( iCurrentName )
+ hRenameTab( cTabName )
+ if ( hHandleInvalidNameWarning( cTabname ) ) then
+ printlog( "Warning for invalid modulename displayed" )
+ else
+ warnlog( "Warning for invalid modulename is missing" )
+ endif
- Randomize
- iCurrentName = Int( 24 * RND ) + 1 ' Range from 1 to 24
-
- cTabName = hCreateInvalidModuleName( iCurrentName )
- rc = hRenameTab( cTabName )
- if ( rc = 1 ) then
- hHandleInvalidNameWarning( cTabname )
- else
- warnlog( "Warning missing" )
- endif
-
- cTabname = CMODULE
- rc = hRenameTab( cTabname )
- if ( rc <> 0 ) then
- brc = hHandleInvalidNameWarning( cTabname )
- if ( brc ) then
- warnlog( "Failed to set valid name" )
- endif
- endif
+ printlog( "Trying with valid modulename" )
+ hRenameTab( CMODULE_VALID2 )
+ if ( hHandleInvalidNameWarning( CMODULE_VALID2 ) ) then
+ warnlog( "Failed to set valid modulename" )
+ endif
-
- cTabname = hCreateInvalidModuleName( 0 )
- rc = hRenameTab( cTabName )
- if ( rc <> 0 ) then
- brc = hHandleInvalidNameWarning( cTabname )
- if ( brc ) then
- warnlog( "Failed to set valid name" )
- endif
- endif
-
-
- rc = hTestMacro( 1 )
- if ( rc <> 1 ) then
- warnlog( "The open macro-module is not the one that was expected" )
+ else
+ warnlog( "Failed to insert macro" )
endif
- hCloseBasicIDE()
-
- hDestroyDocument()
+ hFileCloseAll()
endcase
@@ -102,204 +84,124 @@ endcase
testcase tInvalidModuleNames
+ printlog( "Modulenames in BASIC Organizer" )
+
+ const MAX_WAIT = 2
+ const OK_BUTTON_ONLY = 1
- dim brc as boolean
- dim cMsg as string
dim iCurrentName as Integer
-
dim sSeparator as String
dim cModuleName as string
- hBasicModuleCreateNew()
-
-
Randomize
iCurrentName = Int( 24 * RND ) + 1 ' Range from 1 to 24
-
cModuleName = hCreateInvalidModuleName( iCurrentName )
- printlog( "" )
printlog( "Trying module name: " & cModuleName )
- brc = hNameBasicModule( cModuleName )
-
- if ( brc ) then
+ hCreateDocument()
+ ToolsMacro_uno
+
+ ' hCreateModuleForDoc should usually end with the BASIC IDE open
+ ' but we want it to fail by providing an invalid module name
+ if ( hCreateModuleForDoc( cModuleName ) ) then
warnlog( "Basic-Ide should not open for invalid module names" )
-
- ' try to recover and continue for other names
- brc = hCloseBasicIde()
- brc = hDestroyDocument
- brc = hBasicModuleCreateNew()
-
- ' if we cannot recover, exit the test
- if ( not brc ) then
- goto endsub
+ else
+ kontext "Active"
+ if ( Active.exists( MAX_WAIT ) ) then
+ if( Active.getButtonCount() = OK_BUTTON_ONLY ) then
+
+ printlog( "Messagebox <Invalid name> displayed: " & Active.getText() )
+ hCloseDialog( Active, "ok" )
+
+ kontext "NeuesModul"
+ if ( NeuesModul.exists( MAX_WAIT ) ) then
+ hCloseDialog( NeuesModul, "cancel" )
+
+ kontext "Makro"
+ if ( Makro.exists() ) then
+ hCloseDialog( Makro, "close" )
+ else
+ warnlog( "Test should be back on macro dialog" )
+ endif
+ else
+ warnlog( "<NeuesModul> dialog should show after failed naming attempt" )
+ endif
+ else
+ warnlog( "Unexpected messagebox: " & Active.getText() )
+ hCloseDialog( Active, "close" )
+ endif
+ else
+ warnlog( "<Invalid name> Messagebox missing" )
endif
endif
+ hFileCloseAll()
- printlog( "Close the naming dialog (cancel)" )
- kontext "neuesmodul"
- if ( NeuesModul.Exists() ) then
- NeuesModul.Cancel()
- endif
-
- printlog( "Clsoe macro dialog (if it exists)" )
- kontext "makro"
- if ( Makro.Exists() ) then
- Makro.Close()
- endif
-
- printlog( "Close the document" )
- brc = hDestroyDocument()
-
endcase
'*******************************************************************************
testcase tValidModuleNames
+ printlog( "Valid modulenames in BASIC Organizer: Names that are BASIC keywords" )
- dim brc as boolean
- dim cMsg as string
dim iCurrentName as Integer
-
- dim sKeyword as String
-
- hBasicModuleCreateNew()
+ dim sModuleName as String
Randomize
iCurrentName = Int( 8 * RND ) + 1 ' Range from 1 to 8
select case iCurrentName
- case 1 : sKeyword = "option"
- case 2 : sKeyword = "sub"
- case 3 : sKeyword = "function"
- case 4 : sKeyword = "end"
- case 5 : sKeyword = "exit"
- case 6 : sKeyword = "_underscore1"
- case 7 : sKeyword = "underscore_2"
- case 8 : sKeyWord = "ThisIsQuiteALongNameForAModuleDontYouThink"
+ case 1 : sModuleName = "option"
+ case 2 : sModuleName = "sub"
+ case 3 : sModuleName = "function"
+ case 4 : sModuleName = "end"
+ case 5 : sModuleName = "exit"
+ case 6 : sModuleName = "_underscore1"
+ case 7 : sModuleName = "underscore_2"
+ case 8 : sModuleName = "ThisIsQuiteALongNameForAModuleDontYouThink"
end select
- printlog( "" )
- printlog( "Trying module name: " & sKeyword )
-
- brc = hNameBasicModule( sKeyword )
-
- if ( brc ) then
-
- ' try to recover and continue for other names
- brc = hCloseBasicIde()
- brc = hDestroyDocument
- brc = hBasicModuleCreateNew()
-
- ' if we cannot recover, exit the test
- if ( not brc ) then
- goto endsub
- endif
- endif
-
- printlog( "Close the naming dialog (cancel)" )
- kontext "neuesmodul"
- if ( NeuesModul.Exists() ) then
- NeuesModul.Cancel()
- endif
+ hCreateDocument()
+ ToolsMacro_uno
- printlog( "Clsoe macro dialog (if it exists)" )
- kontext "makro"
- if ( Makro.Exists() ) then
- Makro.Close()
+ if ( hCreateModuleForDoc( sModuleName ) ) then
+ printlog( "The module name was accepted: " & sModuleName )
+ hFileCloseAll()
+ else
+ warnlog( "The module name was not accepted: " & sModuleName )
+ goto endsub
endif
- printlog( "Close the document" )
- brc = hDestroyDocument()
-
endcase
'*******************************************************************************
-function hBasicModuleCreateNew() as boolean
+function hHandleInvalidNameWarning( cTabName as string ) as boolean
+ const CFN = "hHandleInvalidNameWarning(): "
+ const MAX_WAIT = 1
- dim brc as boolean
- brc = false
-
- dim iPos as integer
-
- const CFN = "hBasicModuleCreateNew::"
+ kontext "Active"
+ if ( Active.exists( MAX_WAIT ) ) then
- gApplication = "WRITER"
- brc = hCreateDocument()
-
- brc = hOpenBasicOrganizerFromDoc()
- if ( not brc ) then
- warnlog( CFN & "Could not open the BASIC Macro Organizer, aborting" )
- hDestroyDocument()
- endif
-
- if ( brc ) then
- iPos = hSelectTheLastNode( MakroAus )
- if ( not Neu.isEnabled() ) then
- warnlog( CFN & "New button is disabled for the current module, aborting" )
- kontext "Makro"
- Makro.cancel()
- brc = hDestroyDocument()
- endif
- endif
-
- if ( brc ) then
-
- printlog( "Click 'New'" )
- Neu.Click()
+ printlog( "Invalid name message displayed" & Active.getText() )
+ hCloseDialog( Active, "ok" )
+ hHandleInvalidNameWarning() = true
- kontext "NeuesModul"
- if ( Neuesmodul.exists() ) then
- brc = true
- printlog( CFN & "Naming dialog is open"
+ kontext "Active"
+ if ( Active.exists( MAX_WAIT ) ) then
+ printlog( "Unexpected messagebox displayed: " & Active.getText() )
+ hHandleInvalidNameWarning() = false
endif
- endif
-
- hBasicModuleCreateNew() = brc
-
-end function
-
-'*******************************************************************************
-
-function hHandleInvalidNameWarning( cTabName as string ) as boolean
+ kontext "BasicIDE"
+ tabbar.typekeys( "<ESCAPE>" , true )
- dim brc as boolean : brc = false
- dim iTry as integer
-
- const CFN = "hHandleInvalidNameWarning::"
-
- kontext "Active"
- for iTry = 1 to 5
-
- if ( active.exists( 1 ) ) then
-
- if ( brc ) then
- warnlog( CFN & "Too many invalid name warnings" )
- endif
-
- printlog( CFN & "Message: " & active.getText() )
-
- active.ok()
- brc = true
-
- else
-
- if ( not brc ) then
- warnlog( CFN & "Invalid name warning missing" )
- endif
-
- endif
-
- next iTry
-
- kontext "basicide"
- tabbar.typekeys( "<ESCAPE>" , true )
- hHandleInvalidNameWarning() = brc
+ else
+ printlog( "Invalid name warning not displayed" )
+ hHandleInvalidNameWarning() = false
+ endif
end function