jl165 merging heads
[LibreOffice.git] / testautomation / framework / optional / includes / basic_dialog_i18n_copy_control.inc
blobf9b28ff6718086e8204b4d8360f0218ff9411e2f
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 : Copy a control with i18n data
32 '\******************************************************************************
34 testcase tBasicDialogI18nCopyControl
37     const COMMAND_BUTTON = 1            ' id of the command button (formcontrols.inc)
38     const DIALOG_NAME = "DialogExport"  ' Name of the first module
39     const LANGUAGES_TO_COPY = 5         ' Only copy n languages
40     const TARGET_DIALOG = "Target"      ' The name of the dialog the control is pasted to
41     const DEFAULT_TIMEOUT = 2
42     
43     dim cLanguageList( LANGUAGES_TO_COPY ) as string ' Note: Index 0 is used
44     dim iCurrentLanguage as integer
45     
46     ' These are the strings used to simulate localized text
47     dim cIDStrings( 5 ) as string
48         cIDStrings( 0 ) = "language_a"
49         cIDStrings( 1 ) = "language_b"
50         cIDStrings( 2 ) = "language_c"
51         cIDStrings( 3 ) = "language_d"
52         cIDStrings( 4 ) = "language_e"
53         cIDStrings( 5 ) = "language_f"
54         
55     dim cTempString as string
56         
57     ' These are the IDE internal coordinates of the control, used to restore
58     ' identical coordinates in the source and target dialogs
59     dim iOriginalCoordinates( 4 ) as integer
60     
61     hCreateDocument()
63     printlog( "Test init: Setting up environment" )
64     if ( hInitFormControls( DIALOG_NAME ) ) then
66         printlog( "Draw a commandbutton on the dialog" )
67         hDrawControlOnDialog( COMMAND_BUTTON )
69         printlog( "Open the property browser" )
70         hOpenPropertyBrowser()
71         kontext "TabGeneralControl"
72         printlog( "Get internal coordinates for the control" )
73         iOriginalCoordinates( 1 ) = height.getText()
74         iOriginalCoordinates( 2 ) = width.getText()
75         iOriginalCoordinates( 3 ) = PosX.getText()
76         iOriginalCoordinates( 4 ) = PosY.getText()
77         printlog( "Height: " & iOriginalCoordinates( 1 ) )
78         printlog( "Width.: " & iOriginalCoordinates( 2 ) )
79         printlog( "Pos X.: " & iOriginalCoordinates( 3 ) )
80         printlog( "Pos Y.: " & iOriginalCoordinates( 4 ) )
81         hClosePropertyBrowser()
83         qaerrorlog( "#i80456# properties button not enabled when a formcontrol is inserted via keyboard" )
85         kontext "ToolsCollectionBar"
86         printlog( "Click <Manage Languages>" )
87         ManageLanguage.click()
89         kontext "ManageUILanguages"
90         if ( ManageUILanguages.exists( DEFAULT_TIMEOUT ) ) then
92             printlog( "Click <Add>" )
93             hClickButton( Add )
95             kontext "SetDefaultLanguage"
96             if ( SetDefaultLanguage.exists( DEFAULT_TIMEOUT ) ) then
97                 hCloseDialog( SetDefaultLanguage, "ok" )
98             else
99                 warnlog( "Set Default Language dialog is missing" )
100             endif
101         else
102             warnlog( "Unable to open Manage UI Languages dialog" )
103         endif
105         kontext "ManageUILanguages"
106         if ( ManageUILanguages.exists( DEFAULT_TIMEOUT ) ) then
108             printlog( "Click <Add>" )
109             hClickButton( Add )
111             kontext "AddUserInterface"
112             if ( AddUserInterface.exists( DEFAULT_TIMEOUT ) ) then
113                 for iCurrentLanguage = 1 to LANGUAGES_TO_COPY
114                     AddNewControl.select( iCurrentLanguage )
115                     AddNewControl.check()
116                 next iCurrentLanguage
117                 hCloseDialog( AddUserInterface, "ok" )
118             else
119                 warnlog( "Add User Interface Language dialog is missing" )
120             endif
121         else
122             warnlog( "Unable to open Manage UI Languages dialog" )
123         endif
125         kontext "ManageUILanguages"
126         for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
127             PresentLanguages.select( iCurrentLanguage + 1 )
128             cLanguageList( iCurrentLanguage ) = PresentLanguages.getSelText()
129             printlog( iCurrentLanguage & ": " & cLanguageList( iCurrentLanguage ) )
130         next iCurrentLanguage
132         kontext "ManageUILanguages"
133         hCloseDialog( ManageUILanguages, "close" )
135         printlog( "Localizing control" )
136         for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
137             kontext "TranslationBar"
138             CurrentLanguage.select( iCurrentLanguage + 1 )
139             kontext "BasicIde"
140             hSelectControl( COMMAND_BUTTON )
141             hOpenPropertyBrowser()
142             printlog( "Setting string: " & cIDStrings( iCurrentLanguage ) )
143             kontext "TabGeneralControl"
144             NameText.typeKeys( cIDStrings( iCurrentLanguage ) & "<RETURN>" )
145             hClosePropertyBrowser()
146         next iCurrentLanguage
148         printlog( "Copy control" )
149         hUseAsyncSlot( "EditCopy" )
151         printlog( "New dialog" )
152         hNewDialog()
154         printlog( "Paste control" )
155         hUseAsyncSlot( "EditPaste" )
157         hOpenPropertyBrowser()
158         kontext "TabGeneralControl"
159         printlog( "Set coordinates to be identical with those from the source control" )
160         PosX.typeKeys  (  )
161         PosX.typeKeys  ( "<HOME><SHIFT END>" & iOriginalCoordinates( 3 ) & "<RETURN>" )
162         PosY.typeKeys  ( "<HOME><SHIFT END>" & iOriginalCoordinates( 4 ) & "<RETURN>" )
163         Height.typeKeys( "<HOME><SHIFT END>" & iOriginalCoordinates( 1 ) & "<RETURN>" )
164         Width.typeKeys ( "<HOME><SHIFT END>" & iOriginalCoordinates( 2 ) & "<RETURN>" )
165         hClosePropertyBrowser
168         hOpenPropertyBrowser()
169         kontext "TabGeneralControl"
170         printlog( "Get internal coordinates for the control" )
171         iOriginalCoordinates( 1 ) = height.getText()
172         iOriginalCoordinates( 2 ) = width.getText()
173         iOriginalCoordinates( 3 ) = PosX.getText()
174         iOriginalCoordinates( 4 ) = PosY.getText()
175         printlog( "Height: " & iOriginalCoordinates( 1 ) )
176         printlog( "Width.: " & iOriginalCoordinates( 2 ) )
177         printlog( "Pos X.: " & iOriginalCoordinates( 3 ) )
178         printlog( "Pos Y.: " & iOriginalCoordinates( 4 ) )
179         hClosePropertyBrowser()
182         kontext "TranslationBar"
183         for iCurrentLanguage = 0 to LANGUAGES_TO_COPY
184             CurrentLanguage.select( iCurrentLanguage + 1 )
185             cTempString = CurrentLanguage.getSelText()
186             if ( cTempString = cLanguageList( iCurrentLanguage ) ) then
187                 printlog( "Language <" & cTempString & "> was successfully copied" )
188             else
189                 warnlog( "Either a language was lost or the sort order changed" )
190                 printlog( "Expected: " & cLanguageList( iCurrentLanguage ) )
191                 printlog( "Found...: " & cTempString )
192             endif
193         next iCurrentLanguage
195         hCloseBasicIDE()
196     else
197         warnlog( "Failed to initialize dialog" )
198     endif
199     hDestroyDocument()
200     
201 endcase