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_eventbinding.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 : thorsten.bosbach@sun.com
36 '* short description : Function test of Basic IDE Assign Componenet
38 '\************************************************************************
41 testcase tAssignComponent
42 dim j,b,i,a,x,y as integer
45 dim sDialogName as string
47 ' make sure we start from backingwindow
50 printlog "closing: " + j
53 ' make sure we only have one document window
57 '/// Call Tools - Macros - Organize Dialogs... ///'
58 ToolsMacrosOrganizeDialogs
60 '/// Dialog 'OOo Basic Macro Organizer' is open ///'
61 if TabDialogs.exists(5) then
62 '/// go to top in list 'Dialog' ///'
63 ModuleList.typeKeys("<home>")
64 sTemp = ModuleList.getSelText
66 '/// go down in list with <cursor down>, until the button 'New...' is enabled ///'
67 while (NOT newDialog.isEnabled) AND (sTemp <> sTemp2)
68 ModuleList.typeKeys("<down>")
70 sTemp = ModuleList.getSelText
72 if sTemp = sTemp2 then
73 warnlog "Couldn't find a way to enable the 'New...' button - aborting"
76 printlog ModuleList.getSelText
77 '/// click the button 'New...' ///'
80 '/// dialog 'New Dialog' is open ///'
81 if NeuerDialog.exists(5) then
82 ' save dialog name, for deleting it later
83 sDialogName = Dialogname.getText
85 '/// remember suggested dialog name, for deleting it later ///'
86 '/// accept the name and close dialog by pressing button 'OK' ///'
88 '/// dialog 'New Dialog' is up again ///'
90 if TabDialogs.exists(5) then
91 '/// New created dialog name is highlited in list 'Dialog' ///'
92 printlog ModuleList.getSelText
93 '/// click button 'Edit' ///'
96 '/// Basic IDE Dialog editor is up 'My Macros & Dialogs.Standard - OpenOffice.org Basic' ///'
97 if DialogWindow.exists(5) then ' you can't use exists on BasicIDE; check for a control
98 '/// type key <Tab> to select the dialog in the editor ///'
99 DialogWindow.TypeKeys("tab")
100 DialogWindow.TypeKeys("tab",true)
101 '/// open context menu and select entry 'Properties...' ///'
105 qaErrorLog "#i70901# .typeKeys doesn't work in DialogWindow"
106 ' works better, but also not always
107 DialogWindow.mouseDown( 10 , 10 )
108 DialogWindow.mouseMove( 90 , 90 )
109 DialogWindow.mouseUp( 90 , 90 )
113 qaErrorLog "Even Workaround doesn't work! - exiting"
117 kontext "ControlPropertiesDialog"
118 '/// flyer is open 'Properties: Dialog' ///'
119 'printlog TabEventsControl.exists(5)
120 if NOT ControlPropertiesDialog.exists(5) then
121 qaErrorLog "#i70901# can't use exists on tabpage parent"
123 'printlog TabGeneralControl.exists(5)
125 ' if ControlPropertiesDialog.exists(5) then
126 kontext "TabGeneralControl"
127 if TabGeneralControl.exists(5) then
128 kontext "ControlPropertiesTabControl"
129 ControlPropertiesTabcontrol.setPage (TabEventsControl)
130 '/// switch to tabpage 'Events' ///'
131 Kontext "TabEventsControl"
132 if TabEventsControl.exists(5) then
133 '/// press button '...' beside 'Key pressed'///'
135 Kontext "AssignMacro"
136 '/// dialog comes up 'Assing Macro' ///'
137 if AssignMacro.exists(5) then
138 '/// click button 'Component' ///'
140 Kontext "AssingComponent"
141 '/// dialog is open 'Assign component' ///'
142 if AssingComponent.exists(5) then
143 DialogTest(AssingComponent)
144 '/// set Component Method Name to 'compost' ///'
145 ComponentMethodName.setText ("vnd.sun.star.script:Library1.Module1.TestDialogComponent?language=Basic&location=document")
146 '/// press button 'OK' to close dialog///'
148 Kontext "AssignMacro"
149 if AssignMacro.exists(5) then
150 ' doesn't work, because featureset is not implemted on component EditListBox... expected for xmas 2006
151 'printlog eventListBox.getItemText
152 '/// close dialog 'Assign Macro' with button 'OK' ///'
154 Kontext "TabEventsControl"
155 printlog evtKeyTyped.getText
156 Kontext "ControlPropertiesDialog"
157 '/// close flyer 'Properties: Dialog' by openening context menu and selecting 'Properties'///'
161 warnlog "couldn't open dialog 'Assign Component'"
164 warnlog "couldn't open dialog 'Assign Macro'"
167 warnlog "couldn't switch to tab page 'Events''"
170 warnlog "couldn't open flyer 'Properties: Dialog'"
173 warnlog "couldn't open Basic IDE Dialog editor"
176 warnlog "couldn't open dialog 'New Dialog'"
179 warnlog "couldn't open dialog 'New Dialog'"
182 warnlog "couldn't open dialog 'OOo Basic Macro Organizer'"
186 '/// Call Tools - Macros - Organize Dialogs... ///'
187 ToolsMacrosOrganizeDialogs
189 '/// Dialog 'OOo Basic Macro Organizer' is open ///'
190 if TabDialogs.exists(5) then
191 '/// go to top in list 'Dialog' ///'
192 ModuleList.typeKeys("<home>")
193 sTemp = ModuleList.getSelText
195 '/// go down in list with <cursor down>, until the created dialog name is found ///'
196 while (sTemp <> sDialogName) AND (sTemp <> sTemp2)
197 ModuleList.typeKeys("<down>")
199 sTemp = ModuleList.getSelText
201 if sTemp = sTemp2 then
202 warnlog "Couldn't find the created dialog - aborting"
205 printlog ModuleList.getSelText
206 '/// click the button 'Delete...' ///'
209 '/// active 'Do you want to delete...' is open ///'
210 if active.exists(5) then
211 printlog active.getText
212 '/// delete dialog by pressing button 'YES' ///'
215 warnlog "couldn't delete dialog '"+sDialogName+"'"
220 warnlog "couldn't open dialog 'OOo Basic Macro Organizer'"
224 ' oSimpleComponent = CreateUnoService( "my_module.MyService1" )
225 ' oActiveFrame = StarDesktop.getActiveFrame()
226 ' oSimpleComponent.createDialog("vnd.sun.star.script:Standard.Dialog1?location=application", oActiveFrame )
228 '/// close Basic IDE by calling File->Close///'
230 '/// close opened document///'
234 testcase tAssignComponentFunction
238 sPath = gTesttoolPath & "framework\optional\input/eventbinding/"
239 dim sExtension as string
240 sExtension = "DialogComponent.oxt"
242 sExtensionCLI("list","")
243 'sExtensionCLI("add","DialogComponent.oxt",convertPath(gTestToolPath + "framework\optional\input/eventbinding/") )
244 hExtensionAddGUI( sPath & sExtension, "" )
245 hFileOpen(convertPath(gTestToolPath + "framework\optional\input/eventbinding/DialogComponent.odt"))
246 kontext "SecurityWarning"
247 if SecurityWarning.exists(5) then
251 Kontext "ScriptSelector"
252 if ScriptSelector.exists(10) then
253 x = LibraryTreeList.getItemCount
254 'There have to show up 3 libraries, else the document isn't loaded
256 printlog "Try again..."
257 ScriptSelector.cancel
260 Kontext "ScriptSelector"
261 x = LibraryTreeList.getItemCount
263 'Look for library 'DialogComponent' and 'DIALOGCOMPONENT'
265 sTemp = LibraryTreeList.getItemText(i)
266 'printlog "("+i+"/"+x+"): '" + sTemp + "'"
267 if (("DialogComponent.odt"=sTemp) OR ("DIALOGCOMPONENT.ODT"=sTemp)) then
269 printlog "Found library ("+i+"/"+x+"): '" + sTemp + "'"
273 'Select the library and unfold it
274 LibraryTreeList.select(a)
275 LibraryTreeList.typeKeys("+")
276 'Go to 'Standard' and unfold
277 LibraryTreeList.typeKeys("<down>")
278 LibraryTreeList.typeKeys("+")
280 LibraryTreeList.typeKeys("<down>")
282 'Select macro name 'TestDialogComponent'
283 x = ScriptList.getItemCount
285 sTemp = ScriptList.getItemText(i)
286 'printlog "("+i+"/"+x+"): '" + sTemp + "'"
287 if "TestDialogComponent" = sTemp then
289 printlog "Found macro ("+i+"/"+x+"): '" + sTemp + "'"
295 'Start the macro by pressing the button 'run'
296 qaErrorLog ("#i68892# The test can't go on, because no help ids are useable in BASIC right now.")
297 ScriptSelector.cancel
299 ' sleep... at least 60 seconds
302 warnlog "Macro not found: 'TestDialogComponent'"
305 warnlog "Library not found: 'DialogComponent' or 'DIALOGCOMPONENT'"
308 warnlog "'Run macro dialog' didn't came up"
310 'printlog resetapplication
312 ' vnd.sun.star.UNO:doit1
313 ' vnd.sun.star.UNO:doit2
314 ' vnd.sun.star.UNO:doit3
315 ' vnd.sun.star.UNO:handleEventWithArguments
316 ' vnd.sun.star.UNO:handleEvent
317 ' vnd.sun.star.UNO:copyText
319 sExtensionCLI("remove","DialogComponent.oxt" )
320 'hExtension RemoveGUI( sExtension )