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 correct handling of the default language
32 '\******************************************************************************
34 testcase tBasicDialogI18nDefaults
37 const MODULE_NAME = "defmod"
38 const FILE_NAME = "basic_defaults.odt"
40 dim cWorkPath as string
41 cWorkPath = hGetWorkPath() & FILE_NAME
46 dim cDefLangSelect as string ' Default language from Select Default Language Dialog
47 dim cDefLangDialog as string ' Default language from Manage UI Languages dialog
48 dim cDefLangToolbar as string ' Default language from Translation Toolbar
49 dim cTmpLangString as string ' Temporary language string for comparision
50 dim cAdditionalLanguage as string
52 dim iLangCount as integer
54 printlog( "Preparing testenvironment" )
55 printlog( "Workfile is: " & cWorkPath )
57 brc = hCreateDocument()
59 warnlog( "Failed to create a new document, aborting" )
63 brc = hFileSaveAsWithFilterKill( cWorkPath , "writer8" )
65 brc = hInitFormControls( MODULE_NAME )
67 warnlog( "Ups, bad again..." )
70 printlog( "Dialog Editor is open, ToolsCollectionBar is visible. Good." )
73 printlog( "Starting test (check control states, add default language)" )
75 kontext "TranslationBar"
76 if ( TranslationBar.exists( 1 ) ) then
77 warnlog( "The TranslationBar should not be exist/visible by default" )
79 printlog( "The TranslationBar is hidden. Good." )
82 Kontext "ToolsCollectionBar"
83 ManageLanguage.click()
85 kontext "ManageUILanguages"
86 if ( not ManageUILanguages.exists( 2 ) ) then
87 warnlog( "ManageUILanguages Dialog is not open, aborting test" )
91 printlog( "ManageUILanguages Dialog is open" )
93 iLangCount = PresentLanguages.getItemCount()
94 if ( iLangCount <> 1 ) then
95 warnlog( "There should only be one single entry in the languages listbox" )
96 printlog( "Currently " & iLangCount & " entries are listed" )
99 if ( not add.isEnabled() ) then
100 warnlog( "Add button should be enabled" )
103 if ( delete.isEnabled() ) then
104 warnlog( "Delete button should be disabled" )
108 if ( Default.isEnabled() ) then
109 warnlog( "Default button should be disabled" )
113 printlog( "Select the first/only entry to see whether the button states change" )
114 PresentLanguages.select( 1 )
115 printlog( "Entry is: " & PresentLanguages.getSelText() )
117 if ( not add.isEnabled() ) then
118 warnlog( "Add button should be enabled" )
121 if ( Delete.isEnabled() ) then
122 warnlog( "Delete button should be disabled" )
125 if ( Default.isEnabled() ) then
126 warnlog( "Default button should be disabled" )
129 printlog( "Add default language" )
130 kontext "ManageUILanguage"
133 kontext "SetDefaultLanguage"
134 if ( not SetDefaultLanguage.exists( 2 ) ) then
135 warnlog( "Default language selection dialog did not open" )
136 kontext "ManageUILanguages"
137 ManageUILanguages.close()
141 kontext "SetDefaultLanguage"
142 cDeflangSelect = DefaultLanguageListbox.getSelText()
143 iLangCount = DefaultLanguageListbox.getItemCount()
144 printlog( "Default language is: " & cDeflangSelect )
145 printlog( "Total languages listed: " & iLangCount )
146 SetDefaultLanguage.ok()
149 kontext "ManageUILanguages"
150 iLangCount = PresentLanguages.getItemCount()
151 if ( iLangCount <> 1 ) then
152 warnlog( "There should only be one single entry in the languages listbox" )
153 printlog( "Currently " & iLangCount & " entries are listed" )
156 PresentLanguages.select( 1 )
157 cDefLangDialog = PresentLanguages.getSelText()
158 if ( instr( cDefLangSelect, cDefLangDialog ) <> 0 ) then
159 warnlog( "The default language was not transported to the languages list" )
161 printlog( "Ok, the string was copied correctly" )
163 printlog( "Select.: " & cDefLangSelect )
164 printlog( "Dialog.: " & cDefLangDialog )
167 if ( not add.isEnabled() ) then
168 warnlog( "Add button should be enabled" )
171 if ( not Delete.isEnabled() ) then
172 warnlog( "Delete button should be enabled" )
175 if ( active.exists( 1 ) ) then
176 printlog( "Removal warning is displayed. Good." )
179 warnlog( "Removal warning not displayed" )
183 if ( Default.isEnabled() ) then
184 warnlog( "Default button should be disabled" )
187 kontext "ManageUILanguages"
188 ManageUILanguages.close()
192 kontext "TranslationBar"
193 printlog( "Testing the TranslationBar ..." )
194 if ( TranslationBar.exists() ) then
195 printlog( "TranslationBar exists." )
197 if ( TranslationBar.isVisible() ) then
198 printlog( "TranslationBar is visible." )
200 if ( currentLanguage.isEnabled() ) then
201 printlog( "Languages list is enabled." )
203 if ( CurrentLanguage.getItemCount() = 1 ) then
204 printlog( "Exactly one item in listed in the listbox, good." )
206 ' Note that we need to test for a substring as the [default] marker
207 ' is not copied from the Select Default languages dialog
208 cDefLangToolbar = CurrentLanguage.getSelText()
209 if ( instr( cDefLangToolbar, cDefLangSelect ) <> 0 ) then
210 printlog( "The correct entry is in the languages list. Good." )
212 warnlog( "The default language should be listed and selected." )
214 printlog( "Select.: " & cDefLangSelect )
215 printlog( "Toolbar: " & cDefLangToolbar )
217 if ( cDefLangToolbar <> cDefLangDialog ) then
218 warnlog( "The default language did not copy to the toolbar" )
220 printlog( "The default language was copied ok." )
222 printlog( "Dialog.: " & cDefLangDialog )
223 printlog( "Toolbar: " & cDefLangToolbar )
226 warnlog( "There are too many entries in the languages list." )
229 warnlog( "The languages listbox is disabled." )
232 warnlog( "The Translation Bar is not visible." )
235 warnlog( "The Translation Bar does not exist." )
239 printlog( "Click ManageLanguages-button on the TranslationBar" )
240 kontext "TranslationBar"
242 ManageLanguage.click()
244 kontext "ManageUILanguages"
245 if ( not ManageUILanguages.exists( 2 ) ) then
246 warnlog( "Failed to open Manage Languages dialog" )
249 iLangCount = PresentLanguages.getItemCount()
250 if ( iLangCount <> 1 ) then
251 warnlog( "There should only be one single entry in the languages listbox" )
252 printlog( "Currently " & iLangCount & " entries are listed" )
255 PresentLanguages.select( 1 )
256 cTmpLangString = Presentlanguages.getSeltext()
257 if ( cTmpLangString <> cDefLangDialog ) then
258 warnlog( "The dialog forgot the default language" )
260 printlog( "The dialog remembers the default language. Good." )
262 printlog( "Expected: " & cDefLangDialog )
263 printlog( "Found...: " & cTmpLangString )
265 kontext "ManageUILanguages"
268 kontext "AddUserInterface"
269 if ( not AddUserInterface.exists( 1 ) ) then
270 warnlog( "Cannot add another language, the dialog is not open" )
271 kontext "ManageUILanguages"
272 ManageUILanguages.close()
276 AddNewControl.select( 1 )
277 cAdditionalLanguage = AddNewControl.getSelText()
278 printlog( "Adding language: " & cAdditionalLanguage )
279 AddNewControl.check()
281 AddUserInterface.ok()
283 kontext "ManageUILanguages"
284 if ( not ManageUILanguages.exists( 1 ) ) then
285 warnlog( "Could not return to Manage UI Languages dialog" )
289 kontext "ManageUILanguages"
290 iLangCount = PresentLanguages.getItemCount()
291 if ( iLangCount <> 2 ) then
292 warnlog( "There should be exactly two languages listed in the listbox" )
293 printlog( "Currently " & iLangCount & " entries are listed" )
296 printlog( "Two languages listed in Manage UI Languages dialog. Good." )
299 printlog( "Verify language in Manage UI Language dialog" )
300 PresentLanguages.select( 2 )
301 cTmpLangString = Presentlanguages.getSelText()
302 if ( cTmpLangString = cAdditionalLanguage ) then
303 printlog( "Found correct language at pos 2. Good" )
305 warnlog( "The language is not listed at the expected position" )
307 printlog( "Expected: " & cAdditionalLanguage )
308 printlog( "Found...: " & cTmpLangString )
310 printlog( "Select second language and make it default" )
311 PresentLanguages.select( 2 )
313 cAdditionalLanguage = PresentLanguages.getSelText()
315 printlog( "Close the Manage UI Languages dialog" )
316 kontext "ManageUILanguages"
317 ManageUILanguages.close()
319 printlog( "Verify that the new default is on pos 2 in the TranslationBar list" )
320 kontext "TranslationBar"
321 CurrentLanguage.select( 2 )
322 cDefLangToolbar = CurrentLanguage.getSelText()
323 if ( cDefLangToolbar = cAdditionalLanguage ) then
324 printlog( "Found correct language at pos 2. Good." )
326 warnlog( "The language is not listed at the expected position" )
328 printlog( "Expected: " & cAdditionalLanguage )
329 printlog( "Found...: " & cDefLangToolbar )
331 printlog( "Verify that the list on the Manage UI Language is still unsorted" )
332 printlog( "The dafault language should be at pos 2" )
333 ManageLanguage.click()
334 kontext "ManageUILanguages"
335 PresentLanguages.select( 2 )
336 cTmpLangString = Presentlanguages.getSelText()
337 if ( cTmpLangString = cAdditionalLanguage ) then
338 printlog( "Found correct language at pos 2. Good" )
340 warnlog( "The language is not listed at the expected position" )
342 printlog( "Expected: " & cAdditionalLanguage )
343 printlog( "Found...: " & cTmpLangString )
345 printlog( "Delte the current default language" )
348 printlog( "There should be a deletion warning" )
350 if ( Active.exists( 2 ) ) then
351 cMsg = active.getText()
352 cMsg = hRemoveLineBreaks( cMsg )
353 printlog( "Message: " & cMsg )
356 warnlog( "Deletion Warning missing" )
359 printlog( "Verify deletion, the remaining language must be default now" )
360 kontext "ManageUILanguages"
361 iLangCount = PresentLanguages.getItemCount()
362 if ( iLangCount <> 1 ) then
363 warnlog( "Only the default language should be listed" )
364 printlog( "Currently " & iLangCount & " entries are listed" )
367 PresentLanguages.select( 1 )
368 cTmpLangString = Presentlanguages.getSeltext()
369 if ( cTmpLangString <> cDefLangDialog ) then
370 warnlog( "The dialog forgot the default language" )
372 printlog( "The dialog sets the default language. Good." )
374 printlog( "Expected: " & cDefLangDialog )
375 printlog( "Found...: " & cTmpLangString )
377 printlog( "verify button states" )
379 if ( not add.isEnabled() ) then
380 warnlog( "Add button should be enabled" )
383 if ( not Delete.isEnabled() ) then
384 warnlog( "Delete button should be enabled" )
387 if ( Default.isEnabled() ) then
388 warnlog( "Default button should be disabled" )
393 printlog( "Test exit, cleanup" )
395 kontext "ManageUILanguages"
396 if ( ManageUILanguages.exists() ) then
397 ManageUILanguages.close()
402 hDeleteFile( cWorkPath )