summaryrefslogtreecommitdiff
path: root/testautomation/graphics/optional/includes/global/g_clipboard.inc
blob: e2ee473df88fbfe4f38dfcdcc72d1491a028657c (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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' 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 : wolfram.garten@oracle.com
'*
'* short description :
'*
'**************************************************************************************
' #1 tiEditUndo
' #1 tiEditRedo
' #1 tiEditClipboard
' #1 tiEditPasteSpecial_HTML
' #1 tdEditPasteSpecial_Text
' #1 tdEditPasteSpecial_Graphic
' #1 tdEditPasteSpecial_Circle
' #1 tiEditPasteSpecial
'\*************************************************************************************

testcase tiEditUndo

    Dim Ueber_Text_1 as string
    dim sTestfile as string
    dim sLocaltestfile as string
    
    if ( gApplication = "IMPRESS" ) then
        ExtensionString = "odp"
    else
        ExtensionString = "odg"
    end if
    
    sTestfile = gTesttoolPath + "graphics\required\input\leer."+ExtensionString
    printlog "Loading test file.."
    hFileOpenLocally( sTestfile )
    sleep 3
    printlog "Selecting grey rectangle.."
    hTypeKeys "<TAB><TAB>"
    sleep 3
    printlog "Opening Position and size dialog."
    ContextPositionAndSize
    Kontext
    if Messagebox.exists (5) then
        Messagebox.SetPage TabPositionAndSize
    else
        printlog "Not the expected Dialog came up. Please check."
    endif
    Kontext "TabPositionAndSize"
    printlog "defining variable for original position of object"
    Ueber_Text_1=PositionX.GetText
    printlog "Canceling dialog."
    TabPositionAndSize.Cancel
    sleep 2
    Kontext "Toolbar"
    Auswahl.Click
    sleep 1
    printlog "Sending Rectangle backwards."
    ContextArrangeBringBackward	
    sleep 1
    printlog "Deselect."
    gMouseClick 60,60
    sleep 1
    Kontext "Toolbar"
    Auswahl.Click
    sleep 1
    printlog "trying to select blue rectangle in front"
    hTypeKeys "<TAB><TAB>"
    Kontext "Toolbar"
    Auswahl.Click
    sleep 1
    printlog "Open Position and Size dialog, checking position"
    ContextPositionAndSize
    Kontext
    Messagebox.SetPage TabPositionAndSize
    Kontext "TabPositionAndSize"
    if PositionX=0 Then Warnlog "Command was not completely executed, and it could not be undone."
    TabPositionAndSize.Cancel
    sleep 2
    gMouseClick 60,60
    sleep 1
    printlog "Edit Undo for BringBackward"
    EditUndo
    Sleep 2
    gMouseClick 60,60
    sleep 1
    Kontext "Toolbar"
    Auswahl.Click
    printlog "Trying to select grey rectangle again."
    hTypeKeys "<TAB><TAB>"
    sleep 1
    Kontext "Toolbar"
    Auswahl.Click
    printlog "Again checking position using Position and Size dialog"
    ContextPositionAndSize
    kontext
    Messagebox.SetPage TabPositionAndSize
    kontext "TabPositionAndSize"
    printlog "Checking if x Position is like ata the start again."
    if PositionX.GetText = Ueber_Text_1 then
      printlog "OK, last order could be redone"
    else
      warnlog "Last order could not be redone"
    end if
    TabPositionAndSize.Cancel
    printlog "Close document"
    sLocaltestfile = hFileGetLocalPath( gTesttoolPath + "leer."+ExtensionString )
    printlog sLocaltestfile
    if (FileExists (sLocaltestfile)) then
        app.kill (sLocaltestfile)
        printlog "Deleting used file."
    else
        warnlog "File is missing."
    endif
    Call hCloseDocument	

endcase

'-------------------------------------------------------------------------------
testcase tiEditRedo
    
    Dim Datei$
    Dim Ueber_Text_1
    
    if (gApplication = "IMPRESS") then 
        ExtensionString = "odp"
    else
        ExtensionString = "odg"
    end if
    
    Datei$ = gTesttoolPath + "graphics\required\input\leer."+ExtensionString
    
    hFileOpen ConvertPath (Datei$)			'/// Open test document (leer.od?) ///'
    sleep 3
    ' check if the document is writable
    if fIsDocumentWritable = false then
        ' make the document writable and check if it's succesfull
        if fMakeDocumentWritable = false then
            warnlog "The document can't be make writeable. Test stopped."
            goto endsub
        endif
    endif
    sleep 1
    gMouseClick 30,10
    sleep 1
    hTypeKeys "<TAB>"
    sleep 2
    ContextPositionAndSize
    sleep 1
    Kontext
    Messagebox.SetPage TabPositionAndSize
    Kontext "TabPositionAndSize"
    Ueber_Text_1=PositionX.GetText
    TabPositionAndSize.Cancel
    sleep 1
    hTypeKeys "<TAB>"
    sleep 1
    ContextArrangeBringBackward					'/// move object behind other object ///'
    sleep 1
    gMouseClick 60,60
    sleep 1
    hTypeKeys "<TAB>"
    sleep 1
    ContextPositionAndSize
    sleep 1
    Kontext
    Messagebox.SetPage TabPositionAndSize					'/// checking new position values ///'
    Kontext "TabPositionAndSize"
     if PositionX.GetText = Ueber_Text_1 Then Warnlog "  Nothing changed, so nothing can be undone"
    TabPositionAndSize.Cancel
    sleep 1
    gMouseClick 60,60
    EditUndo							'/// Edit Undo///'
    sleep 1
    hTypeKeys "<TAB>"
    sleep 1
    ContextPositionAndSize
    sleep 1
    kontext
    Messagebox.SetPage TabPositionAndSize					'/// checking again position ///'
    kontext "TabPositionAndSize"
    if PositionX.GetText <> Ueber_Text_1 Then Warnlog "  Undo didn't worked, so repeat last action wont work either"
    TabPositionAndSize.Cancel
    sleep 2
    EditRedo							'/// Edit Redo ///'
    sleep 2
    gMouseClick 60,60
    sleep 2
    hTypeKeys "<TAB>"
    sleep 2
    ContextPositionAndSize
    sleep 1
    kontext
    Messagebox.SetPage TabPositionAndSize
    kontext "TabPositionAndSize"
    if PositionX.GetText <> Ueber_Text_1 then			'/// checking position ///'
      printlog "Action Undo repeated"
    else
      warnlog "Action Undo not repeated"
    end if
    TabPositionAndSize.OK
    sleep 1
    call hCloseDocument						'/// close document ///'
    sleep 1
endcase

'-------------------------------------------------------------------------------
testcase tiEditClipboard

    Dim Ueber_Text_4 as string
    dim sTemp as string
    
    '/// open application ///'
    Call hNewDocument
    Call sSelectEmptyLayout
    sleep 1
    SetClipboard ""
    '/// Create rectangle ///'
    Call hRechteckErstellen ( 65, 65, 80, 80 )
    sleep 1
    '///+ RightClick onto rectangle///'
    gMouseClick 70,70
    sleep 1
    Ueber_Text_4 = fGetPositionX()				'/// Get values for position variables ///'
    Sleep 1
    '/// <b> Edit->Copy </b> ///'
    EditCopy
    '///+ Type Key [Deletee] ///'
    hTypeKeys "<DELETE>"
    '///+ <i> Edit->Paste </i> ///'
    EditPaste
    sleep 1
    '///+   Edit->Select All ///'
    EditSelectAll
    sTemp = fGetPositionX()
    if LiberalMeasurement(sTemp, Ueber_Text_4) then			'/// TabPositionAndSize: comparing position with original position ///'
      printlog "OK   EditCopy and EditPaste"
    else
      warnlog "- Edit paste did not work; is: '" + sTemp + "' ; should: '" + Ueber_Text_4 + "'"
    end if
    sleep 1
    '/// Type Keys [escape], + EditSelectAll (to deselect object and to select again) ///'
    hTypeKeys "<escape>"
    EditSelectAll
    sleep 2
    '/// <b> Edit->Cut </b>///'
    EditCut
    sleep 1
    hTypeKeys "<TAB>"
    try
      '///+ - Format->Position And Size -> HAS TO FAIL / IS NOT AVAILABLE !!! '///'
      ContextPositionAndSize
         kontext
         '///+ - select TabPage 'Position And Size' ///'
         Messagebox.SetPage TabPositionAndSize
         Kontext "TabPositionAndSize"
         if TabPositionAndSize.NOTexists then
            warnlog "TabPositionAndSize isn't up ?!!"
         endif
      '///+ - Ok dialog 'Position And Size' ///'
      TabPositionAndSize.Ok
      warnlog "TabPositionAndSize IS up :-( Doesn't have to be, because object should be deleted !!!"
    catch
      Printlog " - There is no object in the document anymore :-)"
    endcatch
    sleep 1
    '///+ <i> Edit->Paste </i> ///'
    EditPaste
    sleep 2
    sTemp = fGetPositionX()
    if LiberalMeasurement(sTemp, Ueber_Text_4) then
        printlog "OK   Edit paste"
    else
      warnlog "- Edit paste did not work; is: '" + sTemp + "' ; should: '" + Ueber_Text_4 + "'"
    end if
    sleep 3
    '/// close application ///'
    Call hCloseDocument
endcase

'-------------------------------------------------------------------------------
testcase tiEditPasteSpecial_HTML
    
    dim Zaehler as integer
    Kontext "Standardbar"
    sleep 1
    Call hFileOpen ConvertPath (gTesttoolPath + "graphics\required\input\frame1.htm")	'/// Load html document ///'
    sleep 5
    autoexecute=false
    Kontext "DocumentWriter"
    DocumentWriter.MouseDown 10,10
    DocumentWriter.MouseUp 10,10
    autoexecute=true
    EditSelectAll
    sleep 3
    EditCopy									'/// Copy selection ///'
    Sleep 2
    FileClose									'/// Close document ///'
    sleep 3
    Call hNewDocument								'/// Create new Impress document ///'
    sleep 1
    EditPasteSpecial								'/// Edit paste special ///'
    sleep 1
    Kontext "InhaltEinfuegen"
    For Zaehler = 1 to Auswahl.GetItemCount
       Auswahl.select Zaehler
       printlog Zaehler, ". Selection = ", Auswahl.GetSelText
    next Zaehler
    
    if Auswahl.GetItemCount <> 4 then						'/// Controlling number of possible formats ///'
      warnlog "formats for inserting Html <> 4"
    else
      printlog "OK   4 formats for HTML-Document"
    end if
    
    sleep 3
    InhaltEinfuegen.OK								'/// Paste clipboard content ///'
    sleep 3
    try
     EditCopy									'/// Copy object back into clipboard ///'
    catch
     Warnlog "-  Nothing inserted into document"
    endcatch
    sleep 3
    Call hCloseDocument  								'/// Close document ///'
    sleep 3
endcase

'-------------------------------------------------------------------------------
testcase tdEditPasteSpecial_Text
    
    printlog "Insert Text"
    call hNewDocument                 '/// new document  ///'
    SetClipboard "I am a cool test-text in the Clipboard"  '/// put text into clipboard ///'
    EditPasteSpecial                  '/// edit paste special ///'
    sleep 1
    Kontext "InhaltEinfuegen"
    Auswahl.Select 1                  '/// select list entree 1 ///'
    printlog "Selection = ", Auswahl.GetSelText
    sleep 1
    if Auswahl.GetItemCount <> 1 then
      warnlog "Selectionformat <> 1"
    else
      printlog "Format Text OK"
    end if
    InhaltEinfuegen.OK                '/// close dialog ///'
    sleep 1
    
    Call hCloseDocument                   '/// close document ///'
endcase

'-------------------------------------------------------------------------------
testcase tdEditPasteSpecial_Graphic
    
    dim Zaehler as integer
    
    call hNewDocument                  '/// ^new document  ///'
    printlog "Insert graphic file"
    InsertGraphicsFromFile               '/// insert graphic (sample.bmp)///'
    
    Kontext "GrafikEinfuegenDlg"
      Dateiname.SetText ConvertPath (gTesttoolPath + "global\input\graf_inp\enter.bmp")
      Oeffnen.Click
    sleep 1
    EditSelectAll                     '/// select graphic ///'
    EditCut                     '/// cut graphic ///'
    EditPasteSpecial                  '/// edit paste special ///'
    sleep 1
    Kontext "InhaltEinfuegen"
    For Zaehler = 1 to Auswahl.GetItemCount         '/// get item count for Auswahl ///'
    Auswahl.select Zaehler
    printlog Zaehler, ". Selection = ", Auswahl.GetSelText
    next Zaehler
    
    if Auswahl.GetItemCount <> 4 then            '/// check if item count = 4 ///'
      warnlog "Format for insert graphic files should be 4, but is: " + Auswahl.GetItemCount
    else
      printlog "There are " + Auswahl.GetItemCount + " formats for graphic files"
    end if
    InhaltEinfuegen.OK                '/// insert graphic from clipboard ///'
    gMouseClick 90,90
    sleep 1
    Call hCloseDocument                   '/// close document  ///'
endcase

'-------------------------------------------------------------------------------
testcase tdEditPasteSpecial_Circle

   dim Zaehler as integer
 call hNewDocument                  '/// new document  ///'
  sleep 5
  printlog "Insert circle"                '/// create circle ///'
  Kontext "Toolbar"
  Ellipsen.Click
  sleep 3
  gMouseMove (20,20,80,80)
  sleep 1
  hTypeKeys "<escape>"
  sleep 2
  EditSelectAll               '/// select circle ///'
  sleep 5
  EditCut                     '/// cut circle ///'
  sleep 1
  EditPasteSpecial                  '/// edit paste special ///'
  sleep 1
  Kontext "InhaltEinfuegen"
  if EinfuegenAls.IsVisible Then EinfuegenAls.Check      '/// check "EinfuegenAls" ///'
   For Zaehler = 1 to Auswahl.GetItemCount         '/// get item count for Auswahl ///'
       Auswahl.select Zaehler
       printlog Zaehler, ". Selection = ", Auswahl.GetSelText
   next Zaehler
   if Auswahl.GetItemCount <> 4 then            '/// check if item count = 4 ///'
     warnlog "Number of possible formats <> 4"
   else
     printlog "There are 4 formats for circle"
   end if
  sleep 1
  InhaltEinfuegen.OK                '/// paste circle ///'
  sleep 1
 Call hCloseDocument                   '/// close document  ///'
endcase

'-------------------------------------------------------------------------------
testcase tiEditPasteSpecial

  dim i as integer
  dim x as integer
'   warnlog "TODOTBO: from draw, impress, math..."
   '/// go into writer, type a text, select all, Edit->Cut, close writer ///'
   '/// go into application to test, insert every format you can get from Edit->Paste->Special :-) ///'
   gApplication   = "WRITER"
   call hNewDocument
   kontext "DocumentWriter"
   DocumentWriter.TypeKeys "abc<shift home>"
   editcut
   call hCloseDocument
   gApplication   = "IMPRESS"
   call hNewDocument
   sleep 1

 Printlog " get count of possibilities: "
   EditPasteSpecial
   sleep 1
   Kontext "InhaltEinfuegen"
   x = Auswahl.GetItemCount
   for i = 1 to x
      printlog " - " + i + " - " + Auswahl.GetItemText (i)
   next i
   InhaltEinfuegen.Cancel

 Printlog " insert every possibility"
   for i = 1 to x
   Printlog " - processing number: "+i
      EditPasteSpecial
      sleep 1
      Kontext "InhaltEinfuegen"
      Auswahl.Select i
      sleep 1
      InhaltEinfuegen.OK
      sleep 1
   next i
   Call hCloseDocument  '/// close document ///'
endcase

'-------------------------------------------------------------------------------