summaryrefslogtreecommitdiff
path: root/testautomation/writer/optional/includes/autotext/w_autotext.inc
blob: 19e2955f27ab892282aff4f3d64ed36013364f4f (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
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
'**************************************************************************
' 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 : helge.delfs@oracle.com
'*
'* short description : Test of autotext in writer
'*
'\***********************************************************************

sub w_autotext

    Call tEditAutotext_1
    Call tEditAutotext_2
    Call tEditAutotext_3
    Call tEditAutotext_4
    Call tEditAutotext_5

end sub

testcase tEditAutotext_1
    Dim j as integer
    Dim sAll as integer
    Dim i as integer
    Dim Vergleich1$
    Dim Vergleich2$
    Dim Vergleich3$
    Dim Vergleich4$
    
    Printlog "- Create a new autotext with content!"
    printlog " New Writerdocument"
    Call hNewDocument
    printlog " Create a new autotext category"
    if wCreateAutotextCategory( "AANewCategory" ) = false then
        Warnlog "Unable to create new Autotext category"
        Kontext "Autotext"
        if Autotext.Exists then Autotext.Close
        Call hCloseDocument
        goto endsub
    end if       
    wait 500
    Kontext "Autotext"
    Autotext.Close
    
    printlog " Insert some text and format text"
    Call wTypeKeys("This becomes an autotext!")
    ' Format word 'This'
    Call wTypeKeys("<Home><Right>")
    FormatCharacter
    Kontext
    Active.SetPage TabFont
    kontext "TabFont"
    if gAsianSup = True then
        FontWest.Select 5
        if StyleWest.GetItemCount >= 3 then
            StyleWest.Select 3
        else
            For i = 6 to FontWest.GetItemCount
                FontWest.Select i
                try
                    StyleWest.Select 3
                    exit for
                catch
                endcatch
            next i
        end if
        Vergleich1$ = FontWest.GetSelText                
        Vergleich2$ = StyleWest.GetSelText
        SizeWest.Select 5
        Vergleich3$ = SizeWest.GetSelText
    else
        Font.Select 5
        if Style.GetItemCount >= 3 then
            Style.Select 3
        else
            For i = 6 to Font.GetItemCount
                Font.Select i
                try
                    Style.Select 3
                    exit for
                catch
                endcatch
            next i
        end if
        Vergleich1$ = Font.GetSelText
        Vergleich2$ = Style.GetSelText
        Size.Select 5
        Vergleich3$ = Size.GetSelText
    end if
    wait 100
    Kontext
    Active.Setpage TabHyperlinkZeichen
    Kontext "TabHyperlinkZeichen"
    UrlName.Settext "http://www.irgendwas.de"
    TargetFrame.Select 2
    Vergleich4$ = TargetFrame.GetSelText
    TabHyperlinkZeichen.Ok

    Call wTypeKeys("<End>")
    Call wTypeKeys("<Shift Home>")

    printlog " Call Edit / Autotext"
    EditAutotext
    Kontext "Active"
    if Active.Exists then
        warnlog Active.Gettext
        Active.Ok
    end if
    Kontext "Autotext"
    printlog " Uncheck 'Preview and Select first group in List"
    Vorschau_anzeigen.Uncheck
    Kontext "Autotext"
    if wSelectAutotextCategory( "AANewCategory" ) = false then
        Warnlog "Unable to select Autotext category"
        Kontext "Autotext"
        if Autotext.Exists then Autotext.Close
        Call hCloseDocument
        goto endsub
    end if  
    wait 500

    printlog " Insert a name for the Autotext and a Shortcut"
    NameText.Settext "HDEAutotext"
    Kuerzel.Settext "HDE"
    printlog " Select 'New' in Menubutton 'Autotext'"
    wait 500   
    if Menue.IsEnabled then 
        Menue.Click
    else
        Warnlog "Unable to create autotext->Button 'Autotext' is disabled"
        Autotext.Close
        Call hCloseDocument
        goto endsub
    end if
    
    wait 500
    try
        Call hMenuSelectNr ( 1 )
    catch
        Warnlog "Menu Autotext->'New' disabled ! Test failed !"
        Call hMenuClose
        Kontext "Autotext"
        Autotext.Cancel
        Call hCloseDocument
        goto endsub
    endcatch
    printlog " Check if Autotext has been added to list"
    Kontext "Active"
    if Active.Exists then
        if Active.GetRT = 304 then
            Warnlog "Unable to add autotext: " + Active.Gettext
            Active.Ok
            Kontext "Autotext"
            Autotext.Cancel
            Call hCloseDocument
            goto endsub
        end if
    end if

    if wSelectAutotextCategory("AANewCategory") = false then
        Warnlog "Created autotext category not found!"    
    else
        Liste.TypeKeys "+"

        sAll = Liste.GetItemCount
        For j = 1 to sAll
            Liste.TypeKeys "<Down>"
            if Liste.Gettext = "HDEAutotext" then
                printlog "Autotext has been found!"
                Autotext.Ok
                j = sAll + 2
            end if
        next j
        printlog " Check if content has been added to named autotext"
        Kontext "Autotext"
        if Autotext.Exists then
            Warnlog "New autotext has not been found!"
            Autotext.Close
        else
            hSetDocumentContext()
            Call wTypeKeys("<Shift Home>")
            EditCopy
            if GetClipboardtext <> "This becomes an autotext!" then
                Warnlog "Autotext has no content!"
            else
                Call wTypeKeys ("<Home><Right>")
                FormatCharacter
                Kontext
                Active.SetPage TabFont
                Kontext "TabFont"
                if gAsianSup = True then
                    if Vergleich1$ <> FontWest.GetSelText then Warnlog "Wrong Font in Autotext!"
                    if Vergleich2$ <> StyleWest.GetSelText then Warnlog "Wrong Fontstyle in Autotext!"
                    if Vergleich3$ <> SizeWest.GetSelText then Warnlog "Wrong Fontsize in Autotext!"
                else
                    if Vergleich1$ <> Font.GetSelText then Warnlog "Wrong Font in Autotext!"
                    if Vergleich2$ <> Style.GetSelText then Warnlog "Wrong Fontstyle in Autotext!"
                    if Vergleich3$ <> Size.GetSelText then Warnlog "Wrong Fontsize in Autotext!"
                end if
                wait 100
                Kontext
                Active.Setpage TabHyperlinkZeichen
                Kontext "TabHyperlinkZeichen"
                if UrlName.Gettext <> "http://www.irgendwas.de/" then Warnlog "Wrong hyperlink has been added to text!"
                if Vergleich4$ <> TargetFrame.GetSelText then warnlog "Wrong targetFrame has been added to text!"
                TabHyperlinkZeichen.Cancel
            end if
        end if
    end if

    printlog " Delete whole category with created autotext"
    Call wDeleteAutotextCategory( "AANewCategory" )
    Kontext "Autotext"
    if Autotext.Exists then Autotext.Close
    Call hCloseDocument

endcase

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

testcase tEditAutotext_2
    Dim j as integer
    Dim sAll as integer
    Dim i as integer
    Dim Vergleich1$
    Dim Vergleich2$
    Dim Vergleich3$
    Dim Vergleich4$

    Printlog "- Create a new autotext with content! (Text only)"
    printlog " New Writerdocument"
    Call hNewDocument
    printlog " Create a new autotext category"
    if wCreateAutotextCategory( "AANewCategory" ) = false then
        Warnlog "Unable to create new Autotext category"
        Kontext "Autotext"
        if Autotext.Exists then Autotext.Close
        Call hCloseDocument
        goto endsub
    end if       
    wait 500
    Kontext "Autotext"
    Autotext.Close
    hSetDocumentContext()
    printlog " Insert some text and format text"
    Call wTypeKeys("This becomes an autotext!")
    ' Format word 'This'
    Call wTypeKeys("<Home><Right>")
    FormatCharacter
    Kontext
    Active.SetPage TabFont
    kontext "TabFont"
    if gAsianSup = true then
        FontWest.Select 5
        if StyleWest.GetItemCount >= 3 then
            StyleWest.Select 3
        else
            For i = 6 to FontWest.GetItemCount
                FontWest.Select i
                try
                    StyleWest.Select 3
                    exit for
                catch
                endcatch
            next i
        end if
        Vergleich1$ = FontWest.GetSelText
        Vergleich2$ = StyleWest.GetSelText
        SizeWest.Select 5
        Vergleich3$ = SizeWest.GetSelText
    else
        Font.Select 5
        if Style.GetItemCount >= 3 then
            Style.Select 3
        else
            For i = 6 to Font.GetItemCount
                Font.Select i
                try
                    Style.Select 3
                    exit for
                catch
                endcatch
            next i
        end if
        Vergleich1$ = Font.GetSelText
        Vergleich2$ = Style.GetSelText
        Size.Select 5
        Vergleich3$ = Size.GetSelText
    end if
    wait 100
    Kontext
    Active.Setpage TabHyperlinkZeichen
    Kontext "TabHyperlinkZeichen"
    UrlName.Settext "http://www.irgendwas.de"
    TargetFrame.Select 2
    Vergleich4$ = TargetFrame.GetSelText
    TabHyperlinkZeichen.Ok

    Call wTypeKeys("<End>")
    Call wTypeKeys("<Shift Home>")

    printlog " Call Edit / Autotext"
    EditAutotext
    Kontext "Active"
    if Active.Exists then
        warnlog Active.Gettext
        Active.Ok
    end if
    Kontext "Autotext"

    printlog " Uncheck 'Preview and Select first group in List"
    Vorschau_anzeigen.Uncheck
    Kontext "Autotext"
    if wSelectAutotextCategory( "AANewCategory" ) = false then
        Warnlog "Unable to select Autotext category"
        Kontext "Autotext"
        if Autotext.Exists then Autotext.Close
        Call hCloseDocument
        goto endsub
    end if  
    wait 500

    printlog " Insert a name for the Autotext and a Shortcut"
    NameText.Settext "HDEAutotext"
    Kuerzel.Settext "HDE"
    printlog " Select 'New' in Menubutton 'Autotext'"
    wait 500
    Menue.Click
    wait 500
    try
        Call hMenuSelectNr ( 2 )
    catch
        Warnlog "Menu Autotext->'New' disabled ! Test failed !"
        Call hMenuClose
        Kontext "Autotext"
        Autotext.Cancel
        Call hCloseDocument
        goto endsub
    endcatch
    printlog " Check if Autotext has been added to list"
    Kontext "Active"
    if Active.Exists then
        if Active.GetRT = 304 then
            Warnlog "Unable to add autotext: " + Active.Gettext
            Active.Ok
            Kontext "Autotext"
            Autotext.Cancel
            Call hCloseDocument
            goto endsub
        end if
    end if

    if wSelectAutotextCategory("AANewCategory") = false then
        Warnlog "Created autotext category not found!"
    else
        Liste.TypeKeys "+"
    
        sAll = Liste.GetItemCount
        For j = 1 to sAll
            Liste.TypeKeys "<Down>"
            if Liste.Gettext = "HDEAutotext" then
                printlog "Autotext has been found!"
                Autotext.Ok
                j = sAll + 2
            end if
        next j
        printlog " Check if content has been added to named autotext"
        Kontext "Autotext"
        if Autotext.Exists then
            Warnlog "New autotext has not been found!"
            Autotext.Close
        else
            hSetDocumentContext()
            Call wTypeKeys("<Home><Up>" , 4)
            Call wTypeKeys("<Shift End>")
            EditCopy
            if GetClipboardtext <> "This becomes an autotext!" then
                Warnlog "Autotext has no content!"
            else
                Call wTypeKeys ("<Home><Right>")
                FormatCharacter
                Kontext
                Active.SetPage TabFont
                Kontext "TabFont"
                if gAsianSup = true then
                    if Vergleich1$ = FontWest.GetSelText then Warnlog "Wrong Font in Autotext!"
                    if Vergleich2$ = StyleWest.GetSelText then Warnlog "Wrong Fontstyle in Autotext!"
                    if Vergleich3$ = SizeWest.GetSelText then Warnlog "Wrong Fontsize in Autotext!"
                else
                    if Vergleich1$ = Font.GetSelText then Warnlog "Wrong Font in Autotext!"
                    if Vergleich2$ = Style.GetSelText then Warnlog "Wrong Fontstyle in Autotext!"
                    if Vergleich3$ = Size.GetSelText then Warnlog "Wrong Fontsize in Autotext!"
                end if
                wait 100
                Kontext
                Active.Setpage TabHyperlinkZeichen
                Kontext "TabHyperlinkZeichen"
                if UrlName.Gettext = "http://www.irgendwas.de/" then Warnlog "Wrong hyperlink has been added to text!"
                if Vergleich4$ = TargetFrame.GetSelText then Warnlog "Wrong targetFrame has been added to text!"
                TabHyperlinkZeichen.Cancel
            end if
        end if
    end if

    printlog " Delete whole category with created autotext"
    Call wDeleteAutotextCategory( "AANewCategory" )
    Kontext "Autotext"
    if Autotext.Exists then Autotext.Close
    Call hCloseDocument

endcase

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

testcase tEditAutotext_3

    Dim i as Integer
    Dim j as Integer
    Dim AlterWert as String
    Dim hauMatsch as integer

    printlog " Edit / Autotext"
    PrintLog "- Edit / Autotext"
    printlog " New document"
    Call  hNewDocument
    printlog " Select Edit / Autotext"
    EditAutotext
    Kontext "Active"
    if Active.Exists then
        warnlog Active.Gettext
        Active.Ok
    end if

    printlog "  - Select and Insert all Autotexts "
    printlog " Select and Insert all autotexts"
    Sleep 1
    Kontext "AutoText"
    Vorschau_anzeigen.Uncheck
    Liste.Select 1
    for j=1 to 10
        Liste.TypeKeys "-"
        Liste.TypeKeys "<Down>"
        wait 500
    next j

    hauMatsch = Liste.GetItemCount

    for i = 1 to hauMatsch
        Liste.Select 1
        for j=1 to Liste.GetItemCount
            Liste.TypeKeys "-"
            Liste.TypeKeys "<Down>"
            wait 500
        next j
        Vorschau_anzeigen.Check

        Liste.Select i
        Liste.TypeKeys "+"

        Call tCheckAutotextInGroup(Liste.GetItemCount-hauMatsch,i)

    next i

    Kontext "Autotext"
    if Autotext.Exists then Autotext.Close
    
    Call hCloseDocument
endcase

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

testcase tEditAutotext_4

    Call hNewDocument

    printlog " Create a new categorie"
    printlog "  - Create new categorie"
    if wCreateAutotextCategory("AAAAAA") = false then
        Warnlog "Unable to create category"
        Kontext "Autotext"
        if Autotext.Exists then Autotext.Close
        Call hCloseDocument
        goto endsub
    end if

    printlog " Close dialog and check if categorie has been created"
    Kontext "Autotext"
    if Autotext.Exists then Autotext.Close
    if wSelectAutotextCategory("AAAAAA") = false then
        Warnlog "New categorie has been deleted ( after closing and reopening dialog )"
        Kontext "Autotext"
        if Autotext.Exists then Autotext.Close
        Call hCloseDocument
        goto endsub
    end if

    Bereiche.Click
    Kontext "BereicheBearbeitenAutotext"
    printlog " Rename the new categorie"
    printlog "  -  Rename new categorie!"
    Bereich.Settext "AAAAAArrghh"
    Wait 500
    printlog " In dialog click 'rename'"
    if Umbenennen.IsEnabled then
        Umbenennen.Click
        BereicheBearbeitenAutoText.OK
        Kontext "Active"
        if Active.Exists then
            if Active.GetRT = 304 then
                warnlog Active.Gettext
                Active.Ok
            end if
        end if
    else
        Warnlog "Categorie couldn't be renamed (Button is disabled), no further test!"
        Kontext "BereicheBearbeitenAutotext"
        BereicheBearbeitenAutoText.Close
        if wDeleteAutotextCategory("AAAAAA") = false then Warnlog "Unable to delete category"
        Kontext "Autotext"
        AutoText.Close
        Call hCloseDocument
        goto endsub
    end if

    Kontext "BereicheBearbeitenAutotext"
    if BereicheBearbeitenAutotext.Exists then BereicheBearbeitenAutotext.Ok 
    printlog " Close dialog and check if Categorie has been renamed"
    Kontext "Autotext"
    if Autotext.Exists then Autotext.Close
    Sleep 1
    if wSelectAutotextCategory("AAAAAArrghh") = false then
        Warnlog "Categorie hasn't been correctly renamed"
        AlterWert=Liste.Gettext
    end if

    printlog " Delete new categorie"
    printlog "  - Delete new categorie"
    printlog " Select 'Categories'"
    Bereiche.Click
    Kontext "Active"
    if Active.Exists then
        if Active.GetRT = 304 then
            warnlog Active.Gettext
            Active.Ok
        end if
    end if
    Kontext "BereicheBearbeitenAutoText"
    Bereich.SetText "AAAAAArrghh"
    printlog " Select 'Delete', close document and check if categorie has been deleted"
    if Loeschen.IsEnabled then
        Loeschen.Click
    else
        Warnlog "Categorie couldn't be deleted (Button is disabled)!"
    end if

    BereicheBearbeitenAutoText.OK
    Kontext "MessageBox"
    if Not MessageBox.Exists(2) then
        Warnlog "No messsage after deleting Categorie and closing the Dialog !"
    else
        MessageBox.No
        Kontext "Active"
        if Active.Exists then
            if Active.GetRT = 304 then
                warnlog Active.Gettext
                Active.Ok
            end if
        end if
        if wSelectAutotextCategory("AAAAAArrghh") = false then
            Warnlog "After denying the 'Deletemessage' the categorie has been deleted!"
        else
            Kontext "Autotext"
            Bereiche.Click
            Kontext "Active"
            if Active.Exists then
                if Active.GetRT = 304 then
                    warnlog Active.Gettext
                    Active.Ok
                end if
            end if
            Kontext "BereicheBearbeitenAutoText"
            Bereich.SetText "AAAAAArrghh"
            if Loeschen.IsEnabled then
                Loeschen.Click
                BereicheBearbeitenAutotext.Ok
                Kontext "MessageBox"
                if MessageBox.Exists(2) then MessageBox.Yes
                Kontext "Active"
                if Active.Exists then
                    if Active.GetRT = 304 then
                        QAErrorlog Active.Gettext
                        Active.Ok
                    end if
                end if
                Sleep 2
                if wSelectAutotextCategory("AAAAAArrghh") = true then
                    Warnlog "Though the categorie has been deleted it is always there!"
                end if
            else
                Warnlog "Area couldn't be deleted (Button is disabled)!"
            end if
        end if
    end if

    Kontext "Autotext"
    if Autotext.Exists then Autotext.Close
    
    printlog " Close document"
    Call hCloseDocument
endcase

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

testcase tEditAutotext_5
    printlog "  - Insert Autotext with ShortCuts"
    Call hNewDocument
    printlog " try to insert  autotexts with Shotcut"

    Call wTypeKeys "<Return>", 3
    Call wBlindtextEinfuegen

    Kontext "Active"
    if Active.Exists then
        warnlog Active.GetText
        Active.OK
    end if
    Sleep 1
    Call wTypeKeys "<Mod1 A>"
    Sleep 1
    EditCopy
    printlog " Check if autotext has been inserted"
    if GetClipboardText = "" then Warnlog "Autotext couldn't be inserted with Short-Cut!"

    printlog " Close document"
    Call hCloseDocument
endcase