jl165 merging heads
[LibreOffice.git] / testautomation / framework / optional / includes / basic_eventbinding.inc
blob4d5ee502df6621893b0d597308a97d06985734ca
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 : thorsten.bosbach@oracle.com
30 '* short description : Function test of Basic IDE Assign Componenet
32 '\************************************************************************
35 testcase tAssignComponent
36     dim j,b,i,a,x,y as integer
37     dim sTemp as string
38     dim sTemp2 as string
39     dim sDialogName as string
40   
41     ' make sure we start from backingwindow
42     b = getDocumentCount
43     for j = 1 to b
44         printlog "closing: " + j
45         hCloseDocument()
46     next j
47     ' make sure we only have one document window
48     hNewDocument()
49     sleep (5)
50     
51     ToolsMacrosOrganizeDialogs
52     Kontext "TabDialogs"
53     if TabDialogs.exists(5) then
54         ModuleList.typeKeys("<home>")
55         sTemp = ModuleList.getSelText
56         sTemp2 = ""
57         while (NOT newDialog.isEnabled) AND (sTemp <> sTemp2)
58             ModuleList.typeKeys("<down>")
59             sTemp2 = sTemp
60             sTemp = ModuleList.getSelText
61         wend
62         if sTemp = sTemp2 then
63             warnlog "Couldn't find a way to enable the 'New...' button - aborting"
64             goto endsub
65         endif
66         printlog ModuleList.getSelText
67         newDialog.click
68         kontext "NeuerDialog"
69         if NeuerDialog.exists(5) then
70             ' save dialog name, for deleting it later
71             sDialogName = Dialogname.getText
72             printlog sDialogName
73             NeuerDialog.OK
74             Kontext "TabDialogs"
75             if TabDialogs.exists(5) then
76                 printlog ModuleList.getSelText
77                 edit.click
78                 Kontext "BasicIDE"
79                 if DialogWindow.exists(5) then ' you can't use exists on BasicIDE; check for a control
80                     DialogWindow.TypeKeys("tab")
81                     DialogWindow.TypeKeys("tab",true)
82                     try
83                         ContextProperties
84                     catch
85                         qaErrorLog "#i70901# .typeKeys doesn't work in DialogWindow"
86                         ' works better, but also not always
87                         DialogWindow.mouseDown( 10 , 10 )
88                         DialogWindow.mouseMove( 90 , 90 )
89                         DialogWindow.mouseUp( 90 , 90 )
90                         try
91                             ContextProperties
92                         catch
93                             qaErrorLog "Even Workaround doesn't work! - exiting"
94                             goto endsub
95                         endcatch
96                     endcatch
97                     kontext "ControlPropertiesDialog"
98                     'printlog TabEventsControl.exists(5)
99                     if NOT ControlPropertiesDialog.exists(5) then
100                         qaErrorLog "#i70901# can't use exists on tabpage parent"
101                     endif
102                     'printlog TabGeneralControl.exists(5)
103                     ' doesn't work...
104 '                    if ControlPropertiesDialog.exists(5) then
105                     kontext "TabGeneralControl"
106                     if TabGeneralControl.exists(5) then
107                         kontext "ControlPropertiesTabControl"
108                         ControlPropertiesTabcontrol.setPage (TabEventsControl)
109                         Kontext "TabEventsControl"
110                         if TabEventsControl.exists(5) then
111                             PBKeyTyped.click
112                             Kontext "AssignMacro"
113                             if AssignMacro.exists(5) then
114                                 Component.click
115                                 Kontext "AssingComponent"
116                                 if AssingComponent.exists(5) then
117                                     DialogTest(AssingComponent)
118                                     ComponentMethodName.setText ("vnd.sun.star.script:Library1.Module1.TestDialogComponent?language=Basic&location=document")
119                                     AssingComponent.OK
120                                     Kontext "AssignMacro"
121                                     if AssignMacro.exists(5) then
122                                         ' doesn't work, because featureset is not implemted on component EditListBox... expected for xmas 2006
123                                         'printlog eventListBox.getItemText
124                                         AssignMacro.OK
125                                         Kontext "TabEventsControl"
126                                         printlog evtKeyTyped.getText
127                                         Kontext "ControlPropertiesDialog"
128                                         ContextProperties
129                                     endif
130                                 else
131                                     warnlog "couldn't open dialog 'Assign Component'"
132                                 endif
133                             else
134                                 warnlog "couldn't open dialog 'Assign Macro'"
135                             endif
136                         else
137                             warnlog "couldn't switch to tab page 'Events''"
138                         endif
139                     else
140                         warnlog "couldn't open flyer 'Properties: Dialog'"
141                     endif
142                 else
143                     warnlog "couldn't open Basic IDE Dialog editor"
144                 endif
145             else
146                 warnlog "couldn't open dialog 'New Dialog'"
147             endif
148         else
149             warnlog "couldn't open dialog 'New Dialog'"
150         endif
151     else
152         warnlog "couldn't open dialog 'OOo Basic Macro Organizer'"
153     endif
154     
155     'delete dialog!
156     ToolsMacrosOrganizeDialogs
157     Kontext "TabDialogs"
158     if TabDialogs.exists(5) then
159         ModuleList.typeKeys("<home>")
160         sTemp = ModuleList.getSelText
161         sTemp2 = ""
162         while (sTemp <> sDialogName) AND (sTemp <> sTemp2)
163             ModuleList.typeKeys("<down>")
164             sTemp2 = sTemp
165             sTemp = ModuleList.getSelText
166         wend
167         if sTemp = sTemp2 then
168             warnlog "Couldn't find the created dialog - aborting"
169             goto endsub
170         endif
171         printlog ModuleList.getSelText
172         delete.click
173         kontext
174         if active.exists(5) then
175             printlog active.getText
176             active.yes
177         else
178             warnlog "couldn't delete dialog '"+sDialogName+"'"
179         endif
180         Kontext "TabDialogs"
181         TabDialogs.cancel
182     else
183         warnlog "couldn't open dialog 'OOo Basic Macro Organizer'"
184     endif
185         
186 'Sub Main
187 '       oSimpleComponent = CreateUnoService( "my_module.MyService1" )
188 '       oActiveFrame = StarDesktop.getActiveFrame()
189 '       oSimpleComponent.createDialog("vnd.sun.star.script:Standard.Dialog1?location=application", oActiveFrame )
190 'End Sub
191     hCloseDocument()
192     hCloseDocument()
193 endcase
195 testcase tAssignComponentFunction
196     dim x,i,a as integer
197     dim sTemp as string
198     dim sPath as string
199         sPath = gTesttoolPath & "framework\optional\input/eventbinding/"
200     dim sExtension as string
201         sExtension = "DialogComponent.oxt"
202     
203     sExtensionCLI("list","")
204     'sExtensionCLI("add","DialogComponent.oxt",convertPath(gTestToolPath + "framework\optional\input/eventbinding/") )
205     hExtensionAddGUI( sPath & sExtension, "" )
206     hFileOpen(convertPath(gTestToolPath + "framework\optional\input/eventbinding/DialogComponent.odt"))
207     kontext "SecurityWarning"
208     if SecurityWarning.exists(5) then
209         SecurityWarning.ok
210     endif
211     ToolsMacrosRunMacro
212     Kontext "ScriptSelector"
213     if ScriptSelector.exists(10) then
214         x = LibraryTreeList.getItemCount
215         'There have to show up 3 libraries, else the document isn't loaded
216         if x <> 3 then
217             printlog "Try again..."
218             ScriptSelector.cancel
219             sleep 10
220             ToolsMacrosRunMacro
221             Kontext "ScriptSelector"
222             x = LibraryTreeList.getItemCount
223         endif
224         'Look for library 'DialogComponent' and 'DIALOGCOMPONENT'
225         for i = 1 to x
226             sTemp = LibraryTreeList.getItemText(i)
227             'printlog "("+i+"/"+x+"): '" + sTemp + "'"
228             if (instr(stemp,"DialogComponent.odt") OR instr(stemp,"DIALOGCOMPONENT.ODT")) then
229                 a = i
230                 printlog "Found library ("+i+"/"+x+"): '" + sTemp + "'"
231             endif
232         next i
233         if 0 <> a then
234             'Select the library and unfold it
235             LibraryTreeList.select(a)
236             LibraryTreeList.typeKeys("+")
237             'Go to 'Standard' and unfold
238             LibraryTreeList.typeKeys("<down>")
239             LibraryTreeList.typeKeys("+")
240             'Go to 'Global'
241             LibraryTreeList.typeKeys("<down>")
243             'Select macro name 'TestDialogComponent'
244             x = ScriptList.getItemCount
245             for i = 1 to x
246                 sTemp = ScriptList.getItemText(i)
247                 'printlog "("+i+"/"+x+"): '" + sTemp + "'"
248                 if "TestDialogComponent" = sTemp then
249                     a = i
250                     printlog "Found macro ("+i+"/"+x+"): '" + sTemp + "'"
251                 endif
252             next i
253             if (0 <> a) then
254                 'Select the macro
255                 ScriptList.select(a)
256                 'Start the macro by pressing the button 'run'
257                 qaErrorLog ("#i68892# The test can't go on, because no help ids are useable in BASIC right now.")
258                 ScriptSelector.cancel
259                 'ScriptSelector.ok
260         '       sleep... at least 60 seconds
261                 call sleep(10)
262             else
263                 warnlog "Macro not found: 'TestDialogComponent'"
264             endif
265         else
266             warnlog "Library not found: 'DialogComponent' or 'DIALOGCOMPONENT'"
267         endif
268     else
269         warnlog "'Run macro dialog' didn't came up"
270     endif
271     'printlog resetapplication
272     
273    ' vnd.sun.star.UNO:doit1
274    ' vnd.sun.star.UNO:doit2
275    ' vnd.sun.star.UNO:doit3
276    ' vnd.sun.star.UNO:handleEventWithArguments
277    ' vnd.sun.star.UNO:handleEvent
278    ' vnd.sun.star.UNO:copyText
279     
280     sExtensionCLI("remove","DialogComponent.oxt" )
281     'hExtension RemoveGUI( sExtension )
282     hCloseDocument()
283 endcase