summaryrefslogtreecommitdiff
path: root/testautomation/dbaccess/optional/includes/ctrl_Spreadsheet.inc
blob: 8cfeea2ec6ca27beaa6341ecae507f6be81918fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
'* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'* 
'* Copyright 2008 by Sun Microsystems, Inc.
'*
'* OpenOffice.org - a multi-platform office productivity suite
'*
'* $RCSfile: ctrl_Spreadsheet.inc,v $
'*
'* $Revision: 1.1 $
'*
'* last change: $Author: jsi $ $Date: 2008-06-16 07:43:41 $
'*
'* This file is part of OpenOffice.org.
'*
'* OpenOffice.org is free software: you can redistribute it and/or modify
'* it under the terms of the GNU Lesser General Public License version 3
'* only, as published by the Free Software Foundation.
'*
'* OpenOffice.org is distributed in the hope that it will be useful,
'* but WITHOUT ANY WARRANTY; without even the implied warranty of
'* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'* GNU Lesser General Public License version 3 for more details
'* (a copy is included in the LICENSE file that accompanied this code).
'*
'* You should have received a copy of the GNU Lesser General Public License
'* version 3 along with OpenOffice.org.  If not, see
'* <http://www.openoffice.org/license.html>
'* for a copy of the LGPLv3 License.
'*
'/************************************************************************
'*
'* owner : marc.neumann@sun.com
'*
'* short description : Controls linked to spreadsheet cells
'*
'\***********************************************************************

'* preconditions : no FormDesignToolbar should be open
'* testpurpose : test if controls linked to cells work correct

sub ctrl_Spreadsheet

    call preCon_CloseFormDesignToolbar
    call tTextBox
    call tListBox
    call tCheckBox
    
end sub
'--------------------------------------------------------------------------------------
testcase tListBox
    
    Dim j as integer
    Dim k as integer
    dim i as integer
    printlog "- Formular toolbox: List box element (" & gApplication & ")"
    '/// open a spreadsheet, insert a listbox (the wizard appears)
    gApplication = "CALC"
    call hNewDocument
    Kontext "DocumentCalc"
    DocumentCalc.TypeKeys("Value1")
    DocumentCalc.TypeKeys("<RETURN>")
    DocumentCalc.TypeKeys("Value2")
    DocumentCalc.TypeKeys("<RETURN>")
    DocumentCalc.TypeKeys("Value3")
    DocumentCalc.TypeKeys("<RETURN>")
    DocumentCalc.TypeKeys("Value4")
    DocumentCalc.TypeKeys("<RETURN>")
    DocumentCalc.TypeKeys("Value5")
    DocumentCalc.TypeKeys("<RETURN>")
    sleep(1)

    call hToolbarSelect("FormControls",true)
    
    Kontext "FormControls"
    Listbox.Click
    sleep(3)
    call hDrawingWithSelection ( 60, 40, 70, 55 )
    sleep(3)
    Kontext "AutoPilotListComboBox"
    AutoPilotListComboBox.MouseDown(10,10)
    AutoPilotListComboBox.MouseUp(10,10)
    '/// close the autopilot
    if AutoPilotListComboBox.Exists(1) then        
        AutopilotListComboBox.Cancel                
    end if
	sleep(1)

    call hToolbarSelect("FormControls",true)   
	
    Kontext "FormControls"    
	ControlProperties.Click
	sleep(1)
    call fsetControlProperty("ListBox","CellRange","A1:A5")
	call fsetControlProperty("ListBox","CellBound","B1")
	sleep(1)    
    '/// close control property browser
    Kontext "ControlPropertiesDialog"
        ControlPropertiesDialog.Close
    '/// save the document
    printlog "save the document"
    hFileSaveAsKill ( gOfficePath + ConvertPath("user/work/TT_ListBox.ods"))
	hCloseDocument
    sleep(1)
    '/// reload the document
    printlog "reload the document"
	hFileOpen ( gOfficePath + ConvertPath("user/work/TT_ListBox.ods"))	
    sleep 1
    KOntext "DocumentCalc"
    DocumentCalc.TypeKeys "<MOD1 F5>" , true
    sleep(1)
    DocumentCalc.TypeKeys "<DOWN>" , true
    sleep(1)
    DocumentCalc.TypeKeys "<DOWN>" , true
    sleep(1)
    DocumentCalc.TypeKeys "<MOD1 F6>" , true
    sleep(1)
    DocumentCalc.TypeKeys "<MOD1 HOME>" , true
    sleep(1)
    DocumentCalc.TypeKeys "<RIGHT>" , true
    sleep(1)
    DocumentCalc.TypeKeys "<MOD1 C>" , true
    sleep(1)
    Dim str1 as String
    str1 = getClipboardText()    
    if str1 <> "Value2" then
        warnlog "the value is not right. Is should be Value2 but it is " + str1
    endif
	hCloseDocument

endcase
'--------------------------------------------------------------------------------------
testcase tTextBox     
    
    '/// Open a new document,
    gApplication = "CALC"
    printlog "Open a new document,"
	call hNewDocument
    Kontext "DocumentCalc"       
	'DocumentWriter.TypeKeys "tt_doc" , true

	sleep(1)	

    call hToolbarSelect("FormControls",true)
	
    Kontext "FormControls"
  	   	
   	Edit.Click
   	sleep(1)      

    '/// insert a text box
    printlog "insert a text box"
    sleep(3)
    call hDrawingWithSelection ( 30, 30, 40, 40 )
	sleep(2)
	Kontext "FormControls"
	ControlProperties.Click
	sleep(2)
    '/// set multiline and alignment to right            	
	call fsetControlProperty("TextBox","CellBound","A1")    
    
    Kontext "ControlPropertiesDialog"
        ControlPropertiesDialog.Close
    
    '/// save the document
    printlog "save the document"
	hFileSaveAsKill ( gOfficePath + ConvertPath("user/work/TT_TextBox.ods"))
	hCloseDocument
    sleep(1)
    '/// reload the document
    printlog "reload the document"
	hFileOpen ( gOfficePath + ConvertPath("user/work/TT_TextBox.ods"))    

    call hToolbarSelect("FormControls",true)    

    sleep(1)
  	Kontext "FormControls"
    SwitchControlDesignMode.Click
    sleep(1)
    Kontext "DocumentCalc"
     DocumentCalc.typeKeys "Hello world" , true ' this is important to get the focus into the document
     sleep(1)
     DocumentCalc.typeKeys "<F6>" , 6 , true ' it's important that you don't do this in 6 lines
     sleep(1)

    call hToolbarSelect("FormDesignTools",true)     

    Kontext "DocumentCalc"
        DocumentCalc.MouseDown(50,50)
        DocumentCalc.MouseUp(50,50)
    
    Kontext "FormDesignTools"
        ShowFmExplorer.Click

    Kontext "FormularNavigator" 
   	 Liste.TypeKeys "<HOME>"
     sleep(1)
     Liste.TypeKeys "<DOWN>"
     sleep(1)
     Liste.TypeKeys "<DOWN>"
     sleep(1)
     
     Liste.OpenContextmenu
     sleep(1)
     call hMenuSelectNr(5)
     sleep(1)
    
    'Kontext "FormControls"    
    ' try
    '    ControlProperties.Click
    '    sleep(1)
    ' catch 
    '    warnlog "error while open the control properties browser"
    '    call hCloseDocument
    '    goto endsub
    ' endcatch
    '/// check if the values are saved
    printlog "check if the values are saved"
	sleep(2)
    Kontext "ControlPropertiesTabControl"
        ControlPropertiesTabControl.SetPage TabDataControl
        sleep(1)
    if fgetControlProperty("TextBox","CellBound") <> "A1" then
        warnlog "the bound cell is not saved"
        call hCloseDocument
        goto endsub
    endif            
    sleep(1)    	
    
    call hToolbarSelect("FormControls",true)
    
    Kontext "FormControls"
        SwitchControlDesignMode.Click
        sleep(1)

    Kontext "DocumentCalc"
        Documentcalc.TypeKeys "<MOD1 F5>", true
        sleep(1)
        Documentcalc.TypeKeys "<MOD1 HOME>", true
        sleep(1)
        Documentcalc.TypeKeys "<MOD1 SHIFT END>", true
        sleep(1)
        Documentcalc.TypeKeys "<MOD1 C>", true
        sleep(1)
        printlog getClipboard
        if getClipboard <> "Hello world" then
            warnlog "the cell bound doesn't work"
        endif
    hCloseDocument
    gApplication = "WRITER"

endcase
'--------------------------------------------------------------------------------------
testcase tCheckBox     
    
    '/// Open a new document,
    gApplication = "CALC"
    printlog "Open a new document,"
	call hNewDocument
    Kontext "DocumentCalc"	
	
    call hToolbarSelect("FormControls",true)

  	Kontext "FormControls"   	
   	CheckBox.Click
   	sleep(3)      
    '/// insert a checkbox box
    printlog "insert a checkbox box"                        
    call hDrawingWithSelection ( 50, 50, 70, 70 )
	sleep(2)

    call hToolbarSelect("FormControls",true)
	
  	Kontext "FormControls"
	ControlProperties.Click
	sleep(2)
    '/// set multiline and alignment to right            	
	call fsetControlProperty("CheckBox","CellBound","A1")
    call fsetControlProperty("CheckBox","ReferenceValueOff","unchecked")
    call fsetControlProperty("CheckBox","ReferenceValue","checked")
    '/// close control property browser
    Kontext "ControlPropertiesDialog"
        ControlPropertiesDialog.Close
    '/// save the document
    printlog "save the document"
	hFileSaveAsKill ( gOfficePath + ConvertPath("user/work/TT_CheckBox.ods"))
	hCloseDocument    
    '/// reload the document
    printlog "reload the document"
	hFileOpen ( gOfficePath + ConvertPath("user/work/TT_CheckBox.ods"))    
    
    call hToolbarSelect("FormControls",true)    

  	Kontext "FormControls"
    SwitchControlDesignMode.Click
    sleep(1)
    'Kontext "DocumentCalc"
    ' DocumentCalc.typeKeys "hello world" , true ' this is important to get the focus into the document

    call hToolbarSelect("FormDesignTools",true)
    
    Kontext "FormDesignTools"
        ShowFmExplorer.Click    
    
    Kontext "FormularNavigator" 
   	 Liste.TypeKeys "<HOME>"
     sleep(1)
     Liste.TypeKeys "<DOWN>"
     sleep(1)
     Liste.TypeKeys "<DOWN>"
     sleep(1)
     Liste.OpenContextmenu
     sleep(1)
     call hMenuSelectNr(5)
     sleep(1)
     
    'Kontext "FormControls"    
    ' try
    '    ControlProperties.Click
    ' catch 
    '    warnlog "error while open the control properties browser"
    '    call hCloseDocument
    '    goto endsub
    ' endcatch
    
    '/// check if the values are saved
    printlog "check if the values are saved"
	sleep(2)
    Kontext "ControlPropertiesTabControl"
        ControlPropertiesTabControl.SetPage TabGeneralControl
    Kontext "TabGeneralControl"    
	TabGeneralControl.TypeKeys "<TAB>" , true ' this tab is importent, I don't not why but it is.
    if fgetControlProperty("CheckBox","CellBound") <> "A1" then
        warnlog "the bound cell is not saved"
        call hCloseDocument
        goto endsub
    endif            
    sleep(1)    	
    
    call hToolbarSelect("FormControls",true)
    Kontext "FormControls"
        SwitchControlDesignMode.Click        
        sleep(1)
    
    Kontext "DocumentCalc"
        DocumentCalc.MouseDown(20,20)
        DocumentCalc.MouseUp(20,20)
        
        sleep(1)
        
    Kontext "DocumentCalc"
        Documentcalc.TypeKeys "<MOD1 F5>", true
        sleep(1)
        Documentcalc.TypeKeys "<SPACE>", true
        sleep(2)
        
        ' need to activate the document again        
        Documentcalc.MouseDown(10,10)
        Documentcalc.MouseUp(10,10)
        
        sleep(2)
        
        DocumentCalc.TypeKeys "<MOD1 HOME>" , true

        sleep(1)
        
        Documentcalc.TypeKeys "<MOD1 C>", true

        sleep(1)
        
        Dim str2 as String
        str2 = getClipboardText()
        printlog str2
        ' use STRCOMP to compare the strings thats works.
        if StrComp(str2,"checked") <> 0 then
            printlog StrComp(str2,"checked")
            warnlog "the cell bound doesn't work"
        endif
    hCloseDocument
    gApplication = "WRITER"

endcase
'-------------------------------------------------------------------------
function preCon_CloseFormDesignToolbar
    
    printlog "preCondition close FormDesignToolbar"
    call hNewDocument
    call hToolbarSelect("FormDesignTools",false)
    call hCloseDocument
    call ExitRestartTheOffice

end function