1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 ' Copyright 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/************************************************************************
28 '* owner : gregor.hartmann@oracle.com
30 '* short description : Test modulenames on the tabbar
32 '\******************************************************************************
34 testcase tBasicIdeModuleNames
36 printlog( "Modulenames in BASIC IDE" )
38 const CMODULE_VALID1 = "tValidName"
39 const CMODULE_VALID2 = "tValidToo"
40 const TEST_MACRO = "TTMacro1"
44 const ERR_NO_LINES_INSERTED = 0
46 dim iCurrentName as integer
47 dim cTabName as string
49 gApplication = "WRITER"
52 hInitBasicIde( CMODULE_VALID1 )
53 if ( hInsertMacroFromFile( TEST_MACRO ) > ERR_NO_LINES_INSERTED ) then
55 cTabName = hGetTabNameFromOrganizer()
58 iCurrentName = Int( 24 * RND ) + 1 ' Range from 1 to 24
60 printlog( "Trying with invalid modulename" )
61 cTabName = hCreateInvalidModuleName( iCurrentName )
62 hRenameTab( cTabName )
63 if ( hHandleInvalidNameWarning( cTabname ) ) then
64 printlog( "Warning for invalid modulename displayed" )
66 warnlog( "Warning for invalid modulename is missing" )
69 printlog( "Trying with valid modulename" )
70 hRenameTab( CMODULE_VALID2 )
71 if ( hHandleInvalidNameWarning( CMODULE_VALID2 ) ) then
72 warnlog( "Failed to set valid modulename" )
76 warnlog( "Failed to insert macro" )
83 '*******************************************************************************
85 testcase tInvalidModuleNames
87 printlog( "Modulenames in BASIC Organizer" )
90 const OK_BUTTON_ONLY = 1
92 dim iCurrentName as Integer
93 dim sSeparator as String
94 dim cModuleName as string
97 iCurrentName = Int( 24 * RND ) + 1 ' Range from 1 to 24
98 cModuleName = hCreateInvalidModuleName( iCurrentName )
99 printlog( "Trying module name: " & cModuleName )
104 ' hCreateModuleForDoc should usually end with the BASIC IDE open
105 ' but we want it to fail by providing an invalid module name
106 if ( hCreateModuleForDoc( cModuleName ) ) then
107 warnlog( "Basic-Ide should not open for invalid module names" )
110 if ( Active.exists( MAX_WAIT ) ) then
111 if( Active.getButtonCount() = OK_BUTTON_ONLY ) then
113 printlog( "Messagebox <Invalid name> displayed: " & Active.getText() )
114 hCloseDialog( Active, "ok" )
117 if ( NeuesModul.exists( MAX_WAIT ) ) then
118 hCloseDialog( NeuesModul, "cancel" )
121 if ( Makro.exists() ) then
122 hCloseDialog( Makro, "close" )
124 warnlog( "Test should be back on macro dialog" )
127 warnlog( "<NeuesModul> dialog should show after failed naming attempt" )
130 warnlog( "Unexpected messagebox: " & Active.getText() )
131 hCloseDialog( Active, "close" )
134 warnlog( "<Invalid name> Messagebox missing" )
142 '*******************************************************************************
144 testcase tValidModuleNames
146 printlog( "Valid modulenames in BASIC Organizer: Names that are BASIC keywords" )
148 dim iCurrentName as Integer
149 dim sModuleName as String
152 iCurrentName = Int( 8 * RND ) + 1 ' Range from 1 to 8
154 select case iCurrentName
155 case 1 : sModuleName = "option"
156 case 2 : sModuleName = "sub"
157 case 3 : sModuleName = "function"
158 case 4 : sModuleName = "end"
159 case 5 : sModuleName = "exit"
160 case 6 : sModuleName = "_underscore1"
161 case 7 : sModuleName = "underscore_2"
162 case 8 : sModuleName = "ThisIsQuiteALongNameForAModuleDontYouThink"
168 if ( hCreateModuleForDoc( sModuleName ) ) then
169 printlog( "The module name was accepted: " & sModuleName )
172 warnlog( "The module name was not accepted: " & sModuleName )
178 '*******************************************************************************
180 function hHandleInvalidNameWarning( cTabName as string ) as boolean
182 const CFN = "hHandleInvalidNameWarning(): "
186 if ( Active.exists( MAX_WAIT ) ) then
188 printlog( "Invalid name message displayed" & Active.getText() )
189 hCloseDialog( Active, "ok" )
190 hHandleInvalidNameWarning() = true
193 if ( Active.exists( MAX_WAIT ) ) then
194 printlog( "Unexpected messagebox displayed: " & Active.getText() )
195 hHandleInvalidNameWarning() = false
199 tabbar.typekeys( "<ESCAPE>" , true )
202 printlog( "Invalid name warning not displayed" )
203 hHandleInvalidNameWarning() = false
208 '*******************************************************************************
210 function hCreateInvalidModuleName( iName as integer ) as string
213 dim sSeparator as string
215 ' Note: We cannot test for "<" and ">" because these are the characters
216 ' that identify keystrokes for the .typeKeys() method.
219 case 0 : sSeparator = "_"
220 case 1 : sSeparator = "-"
221 case 2 : sSeparator = "."
222 case 3 : sSeparator = ","
223 case 4 : sSeparator = "+"
224 case 5 : sSeparator = ":"
225 case 6 : sSeparator = "!"
226 case 7 : sSeparator = "$"
227 case 8 : sSeparator = "("
228 case 9 : sSeparator = ")"
229 case 10 : sSeparator = "="
230 case 11 : sSeparator = "?"
231 case 12 : sSeparator = "*"
232 case 13 : sSeparator = " "
233 case 14 : sSeparator = "&"
234 case 15 : sSeparator = "\"
235 case 16 : sSeparator = "/"
236 case 17 : sSeparator = "ยง"
237 case 18 : sSeparator = """"
238 case 19 : sSeparator = "'"
239 case 20 : sSeparator = "@"
240 case 21 : sSeparator = "["
241 case 22 : sSeparator = "]"
242 case 23 : sSeparator = "%"
243 case 24 : sSeparator = CHR$( 387 )
244 case else : sSeparator = ""
247 hCreateInvalidModuleName() = "ttModule" & sSeparator & "X"