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 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: basic_dialog_i18n_defaults.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:13 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : joerg.skottke@sun.com
36 '* short description : Test correct handling of the default language
38 '\******************************************************************************
40 testcase tBasicDialogI18nDefaults
42 '///<h1>Test correct handling of the default language</h1>
43 '///<i>This test verifies that - if the user adds localization to the dialogs -
44 '///+ these are handled in a sensible way. This means that a) the first
45 '///+ language automatically becomes default, b) the languages really make it
46 '///+ from the language selection to the Manage UI Languages dialog and the
47 '///+ the listbox of the translation toolbar in the BASIC IDE. Switching
48 '///+ languages is tested, as well as the states of the three action buttons on
49 '///+ the Manage UI Languages dialog.</i><br>
51 const MODULE_NAME = "defmod"
52 const FILE_NAME = "basic_defaults.odt"
54 dim cWorkPath as string
55 cWorkPath = hGetWorkPath() & FILE_NAME
60 dim cDefLangSelect as string ' Default language from Select Default Language Dialog
61 dim cDefLangDialog as string ' Default language from Manage UI Languages dialog
62 dim cDefLangToolbar as string ' Default language from Translation Toolbar
63 dim cTmpLangString as string ' Temporary language string for comparision
64 dim cAdditionalLanguage as string
66 dim iLangCount as integer
69 printlog( "Preparing testenvironment" )
70 printlog( "Workfile is: " & cWorkPath )
72 '///+<li>Create a new document</li>
73 brc = hCreateDocument()
75 warnlog( "Failed to create a new document, aborting" )
79 '///+<li>Save the file, overwrite existing if found</li>
80 brc = hFileSaveAsWithFilterKill( cWorkPath , "writer8" )
82 '///+<li>Open the basic organizer</li>
83 '///+<li>Create a new module for the current document</li>
84 '///+<li>Click to edit the module</li>
85 '///+<li>Create a dialog, switch to it and ensure that the ToolsCollectionBar is open</li>
86 brc = hInitFormControls( MODULE_NAME )
88 warnlog( "Ups, bad again..." )
91 printlog( "Dialog Editor is open, ToolsCollectionBar is visible. Good." )
94 printlog( "Starting test (check control states, add default language)" )
96 '///+<li>Verify that the Translation Bar is hidden by default"</li>
97 kontext "TranslationBar"
98 if ( TranslationBar.exists( 1 ) ) then
99 warnlog( "The TranslationBar should not be exist/visible by default" )
101 printlog( "The TranslationBar is hidden. Good." )
104 Kontext "ToolsCollectionBar"
105 ManageLanguage.click()
107 '///+<li>On the now open Language dialog test the default states of the controls</li>
108 kontext "ManageUILanguages"
109 if ( not ManageUILanguages.exists( 2 ) ) then
110 warnlog( "ManageUILanguages Dialog is not open, aborting test" )
114 printlog( "ManageUILanguages Dialog is open" )
117 '///+<li>There should be no languages listed yet but a hint on how to continue</li>
118 iLangCount = PresentLanguages.getItemCount()
119 if ( iLangCount <> 1 ) then
120 warnlog( "There should only be one single entry in the languages listbox" )
121 printlog( "Currently " & iLangCount & " entries are listed" )
124 '///+<li>"Add..." should be enabled</li>
125 if ( not add.isEnabled() ) then
126 warnlog( "Add button should be enabled" )
129 '///+<li>"Delete" should be disabled</li>
130 if ( delete.isEnabled() ) then
131 warnlog( "Delete button should be disabled" )
135 '///+<li>"Default" should be disabled</li>
136 if ( Default.isEnabled() ) then
137 warnlog( "Default button should be disabled" )
142 '///+<li>Select the first and only entry in the list, it should not change the button states</li>
143 printlog( "Select the first/only entry to see whether the button states change" )
144 PresentLanguages.select( 1 )
145 printlog( "Entry is: " & PresentLanguages.getSelText() )
148 '///+<li>"Add..." should be enabled</li>
149 if ( not add.isEnabled() ) then
150 warnlog( "Add button should be enabled" )
153 '///+<li>"Delete" should be disabled</li>
154 if ( Delete.isEnabled() ) then
155 warnlog( "Delete button should be disabled" )
158 '///+<li>"Default" should be disabled</li>
159 if ( Default.isEnabled() ) then
160 warnlog( "Default button should be disabled" )
164 '///+<li>Click "Add..." to add a default language</li>
165 printlog( "Add default language" )
166 kontext "ManageUILanguage"
169 kontext "SetDefaultLanguage"
170 if ( not SetDefaultLanguage.exists( 2 ) ) then
171 warnlog( "Default language selection dialog did not open" )
172 kontext "ManageUILanguages"
173 ManageUILanguages.close()
177 kontext "SetDefaultLanguage"
178 cDeflangSelect = DefaultLanguageListbox.getSelText()
179 iLangCount = DefaultLanguageListbox.getItemCount()
180 printlog( "Default language is: " & cDeflangSelect )
181 printlog( "Total languages listed: " & iLangCount )
182 SetDefaultLanguage.ok()
185 '///+<li>Test the language string and the states of the buttons on the dialog</li>
186 kontext "ManageUILanguages"
188 '///+<li>There should be exactly one language listed</li>
189 iLangCount = PresentLanguages.getItemCount()
190 if ( iLangCount <> 1 ) then
191 warnlog( "There should only be one single entry in the languages listbox" )
192 printlog( "Currently " & iLangCount & " entries are listed" )
195 PresentLanguages.select( 1 )
196 cDefLangDialog = PresentLanguages.getSelText()
197 if ( instr( cDefLangSelect, cDefLangDialog ) <> 0 ) then
198 warnlog( "The default language was not transported to the languages list" )
200 printlog( "Ok, the string was copied correctly" )
202 printlog( "Select.: " & cDefLangSelect )
203 printlog( "Dialog.: " & cDefLangDialog )
206 '///+<li>"Add..." should be enabled</li>
207 if ( not add.isEnabled() ) then
208 warnlog( "Add button should be enabled" )
211 '///+<li>"Delete" should be enabled</li>
212 if ( not Delete.isEnabled() ) then
213 warnlog( "Delete button should be enabled" )
216 if ( active.exists( 1 ) ) then
217 printlog( "Removal warning is displayed. Good." )
220 warnlog( "Removal warning not displayed" )
224 '///+<li>"Default" should be disabled</li>
225 if ( Default.isEnabled() ) then
226 warnlog( "Default button should be disabled" )
230 '///+<li>Close the Manage UI Languages Dialog</li>
231 kontext "ManageUILanguages"
232 ManageUILanguages.close()
236 '///+<li>Test the Translation Bar</li>
238 kontext "TranslationBar"
239 printlog( "Testing the TranslationBar ..." )
240 if ( TranslationBar.exists() ) then
241 printlog( "TranslationBar exists." )
243 '///+<li>Verify that the translation bar is visible</li>
244 if ( TranslationBar.isVisible() ) then
245 printlog( "TranslationBar is visible." )
247 '///+<li>Verify that the languages listbox is enabled</li>
248 if ( currentLanguage.isEnabled() ) then
249 printlog( "Languages list is enabled." )
251 '///+<li>Verify that the default language is the only item in the listbox</li>
252 if ( CurrentLanguage.getItemCount() = 1 ) then
253 printlog( "Exactly one item in listed in the listbox, good." )
255 ' Note that we need to test for a substring as the [default] marker
256 ' is not copied from the Select Default languages dialog
257 cDefLangToolbar = CurrentLanguage.getSelText()
258 if ( instr( cDefLangToolbar, cDefLangSelect ) <> 0 ) then
259 printlog( "The correct entry is in the languages list. Good." )
261 warnlog( "The default language should be listed and selected." )
263 printlog( "Select.: " & cDefLangSelect )
264 printlog( "Toolbar: " & cDefLangToolbar )
266 if ( cDefLangToolbar <> cDefLangDialog ) then
267 warnlog( "The default language did not copy to the toolbar" )
269 printlog( "The default language was copied ok." )
271 printlog( "Dialog.: " & cDefLangDialog )
272 printlog( "Toolbar: " & cDefLangToolbar )
275 warnlog( "There are too many entries in the languages list." )
278 warnlog( "The languages listbox is disabled." )
281 warnlog( "The Translation Bar is not visible." )
284 warnlog( "The Translation Bar does not exist." )
289 '///+<li>Reopen ManageUILanguages dialog - this time by clicking the icon on the TranslationBar</li>
290 printlog( "Click ManageLanguages-button on the TranslationBar" )
291 kontext "TranslationBar"
293 ManageLanguage.click()
295 '///+<li>The Manage UI Languages dialog should pop open</li>
296 kontext "ManageUILanguages"
297 if ( not ManageUILanguages.exists( 2 ) ) then
298 warnlog( "Failed to open Manage Languages dialog" )
301 '///+<li>Verify that exactly one language is listed</li>
302 iLangCount = PresentLanguages.getItemCount()
303 if ( iLangCount <> 1 ) then
304 warnlog( "There should only be one single entry in the languages listbox" )
305 printlog( "Currently " & iLangCount & " entries are listed" )
308 '///+<li>Verify that it is marked as the default language</li>
309 PresentLanguages.select( 1 )
310 cTmpLangString = Presentlanguages.getSeltext()
311 if ( cTmpLangString <> cDefLangDialog ) then
312 warnlog( "The dialog forgot the default language" )
314 printlog( "The dialog remembers the default language. Good." )
316 printlog( "Expected: " & cDefLangDialog )
317 printlog( "Found...: " & cTmpLangString )
319 '///+<li>Add another language, click on "Add..."</li>
320 kontext "ManageUILanguages"
323 kontext "AddUserInterface"
324 if ( not AddUserInterface.exists( 1 ) ) then
325 warnlog( "Cannot add another language, the dialog is not open" )
326 kontext "ManageUILanguages"
327 ManageUILanguages.close()
331 '///+<li>Select the first language from the list (Check the Checkbox)</li>
332 AddNewControl.select( 1 )
333 cAdditionalLanguage = AddNewControl.getSelText()
334 printlog( "Adding language: " & cAdditionalLanguage )
335 AddNewControl.check()
337 '///+<li>Click OK to add the language</li>
338 AddUserInterface.ok()
340 kontext "ManageUILanguages"
341 if ( not ManageUILanguages.exists( 1 ) ) then
342 warnlog( "Could not return to Manage UI Languages dialog" )
346 '///+<li>Verify that the language shows up in the Manage UI Languages dialog" )
347 kontext "ManageUILanguages"
348 iLangCount = PresentLanguages.getItemCount()
349 if ( iLangCount <> 2 ) then
350 warnlog( "There should be exactly two languages listed in the listbox" )
351 printlog( "Currently " & iLangCount & " entries are listed" )
354 printlog( "Two languages listed in Manage UI Languages dialog. Good." )
357 '///+<li>Verify that additional language is at position 2 (default is first)</li>
358 printlog( "Verify language in Manage UI Language dialog" )
359 PresentLanguages.select( 2 )
360 cTmpLangString = Presentlanguages.getSelText()
361 if ( cTmpLangString = cAdditionalLanguage ) then
362 printlog( "Found correct language at pos 2. Good" )
364 warnlog( "The language is not listed at the expected position" )
366 printlog( "Expected: " & cAdditionalLanguage )
367 printlog( "Found...: " & cTmpLangString )
369 '///+<li>Switch the default to the newly added language</li>
370 printlog( "Select second language and make it default" )
371 PresentLanguages.select( 2 )
373 cAdditionalLanguage = PresentLanguages.getSelText()
375 '///+<li>Close the Manage UI Languages dialog</li>
376 printlog( "Close the Manage UI Languages dialog" )
377 kontext "ManageUILanguages"
378 ManageUILanguages.close()
380 '///+<li>Verify that the change in default makes it to the translation bar</li>
381 printlog( "Verify that the new default is on pos 2 in the TranslationBar list" )
382 kontext "TranslationBar"
383 CurrentLanguage.select( 2 )
384 cDefLangToolbar = CurrentLanguage.getSelText()
385 if ( cDefLangToolbar = cAdditionalLanguage ) then
386 printlog( "Found correct language at pos 2. Good." )
388 warnlog( "The language is not listed at the expected position" )
390 printlog( "Expected: " & cAdditionalLanguage )
391 printlog( "Found...: " & cDefLangToolbar )
393 '///+<li>The new default should be at pos 2 of the Manage UI Language dialog</li>
394 printlog( "Verify that the list on the Manage UI Language is still unsorted" )
395 printlog( "The dafault language should be at pos 2" )
396 ManageLanguage.click()
397 kontext "ManageUILanguages"
398 PresentLanguages.select( 2 )
399 cTmpLangString = Presentlanguages.getSelText()
400 if ( cTmpLangString = cAdditionalLanguage ) then
401 printlog( "Found correct language at pos 2. Good" )
403 warnlog( "The language is not listed at the expected position" )
405 printlog( "Expected: " & cAdditionalLanguage )
406 printlog( "Found...: " & cTmpLangString )
408 '///+<li>Delete the default language</li>
409 printlog( "Delte the current default language" )
412 '///+<li>Handle the warning</li>
413 printlog( "There should be a deletion warning" )
415 if ( Active.exists( 2 ) ) then
416 cMsg = active.getText()
417 cMsg = hRemoveLineBreaks( cMsg )
418 printlog( "Message: " & cMsg )
421 warnlog( "Deletion Warning missing" )
424 '///+<li>Verify that there is only one item left</li>
425 printlog( "Verify deletion, the remaining language must be default now" )
426 kontext "ManageUILanguages"
427 iLangCount = PresentLanguages.getItemCount()
428 if ( iLangCount <> 1 ) then
429 warnlog( "Only the default language should be listed" )
430 printlog( "Currently " & iLangCount & " entries are listed" )
433 '///+<li>Verify that this is the first language and that it is default</li>
434 PresentLanguages.select( 1 )
435 cTmpLangString = Presentlanguages.getSeltext()
436 if ( cTmpLangString <> cDefLangDialog ) then
437 warnlog( "The dialog forgot the default language" )
439 printlog( "The dialog sets the default language. Good." )
441 printlog( "Expected: " & cDefLangDialog )
442 printlog( "Found...: " & cTmpLangString )
444 '///+<li>Select the first and only entry in the list, it should not change the button states</li>
445 printlog( "verify button states" )
448 '///+<li>"Add..." should be enabled</li>
449 if ( not add.isEnabled() ) then
450 warnlog( "Add button should be enabled" )
453 '///+<li>"Delete" should be disabled</li>
454 if ( not Delete.isEnabled() ) then
455 warnlog( "Delete button should be enabled" )
458 '///+<li>"Default" should be disabled</li>
459 if ( Default.isEnabled() ) then
460 warnlog( "Default button should be disabled" )
464 '///+<li>Test exit, cleanup</li>
468 printlog( "Test exit, cleanup" )
470 '///+<li>Close Manage UI Languages dialog" )
471 kontext "ManageUILanguages"
472 if ( ManageUILanguages.exists() ) then
473 ManageUILanguages.close()
476 '///+<li>Close the BASIC IDE</li>
478 '///+<li>Close the document</li>
480 '///+<li>Delete the workfile</li>
481 hDeleteFile( cWorkPath )