summaryrefslogtreecommitdiff
path: root/testautomation/writer/optional/includes/regression/issuezilla/w_issuezilla_regression.inc
blob: 34ea891602392d4e9dcad873a9fb7738dd9ee5df (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
'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 : helge.delfs@sun.com
'*
'* short description : Avoid regression (issuezilla tasks)
'*
'\***********************************************************************

sub w_issuezilla_regression

    Call i64991
    Call i65094
    Call i69045
    Call i69521
    Call i75027
    Call i76637
    Call i88656
	Call i103265

end sub

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

testcase i64991
    Dim PrevMacroSetting as integer
    Dim sDocName as string, i as integer, j as integer

    sDocName = ConvertPath(gtesttoolpath & "writer\optional\input\regression\issuezilla\i64991.odt")
    '/// New writer document
    Call hNewDocument
    '/// Set macro security to 'Medium' to activate Macros
    PrevMacroSetting = hSetMacroSecurity(1)
    '/// Open file \\writer\\optional\\input\\regression\\issuezilla\\i64991.odt
    printlog "- Open file: " & sDocName 
    call hFileOpen (sDocName,false)
    Kontext "SecurityWarning"
    if SecurityWarning.Exists(2) then
        SecurityWarning.OK
    else
        Warnlog "Security Warning not up. Test interrupted!"
        Call hCloseDocument
        goto endsub
    end if
    
	printlog "Save document to be able to find macro module later"    
    Call hFileSaveAsKill (gOfficepath + "user\work\i64991.odt")
	
	printlog "- execute macro"
    ToolsMacrosRunMacro
    ' Sometimes it lasts long until dialog is shown
    For i = 1 to 15
        Sleep(i)
        Kontext "ScriptSelector"
        if ScriptSelector.Exists then exit for
    next i
    printlog " - select 'i64991' in Library list"
    Kontext "ScriptSelector"
    For i = 1 to LibraryTreeList.GetItemCount
        LibraryTreeList.Select i
        if InStr(LibraryTreeList.GetSelText,"i64991") then
            printlog " - open node 'i64991' in Library list"
            i = LibraryTreeList.GetItemCount + 1
            LibraryTreeList.TypeKeys "+"
            wait 500
            printlog " - select 'Standard' in Library list"
            LibraryTreeList.TypeKeys "<Down>"            
            wait 500
            printlog " - open node 'Standard' in Library list"
            LibraryTreeList.TypeKeys "+"
            wait 500
            LibraryTreeList.TypeKeys "<Down>"
            printlog " - select 'check_page_style' in Library list"
            if LibraryTreeList.GetSelText <> "check_page_style" then
                Warnlog "Unable to find macro. Test interrupted!"
                ScriptSelector.Cancel
                Call hCloseDocument
                goto endsub
            end if
            printlog "- Now select script 'Main'"
            for j = 1 to ScriptList.GetItemCount
                ScriptList.Select j
                if ScriptList.GetSelText = "Main" then
                    printlog " - execute Script 'Main'"
                    ScriptSelector.Ok
                    exit for
                end if
            next j
        end if
    next i
    Kontext "ScriptSelector"
    if ScriptSelector.Exists then
        Warnlog "Something failed executing macro. Test interrupted"
        ScriptSelector.Cancel
    else
        '/// check if page layout on first page is landscape
        printlog "Check layout on first page"
        FormatPageWriter
        Kontext
        Active.Setpage TabSeite
        Kontext "TabSeite"
        if Not Quer.IsChecked then Warnlog "#i64991#Setting a printer make the page styles to be lost"
        TabSeite.Cancel

        Call wTypeKeys ("<Down>")

        '/// check if page layout on second page is still portrait
        printlog "Check layout on second page"
        FormatPageWriter
        Kontext
        Active.Setpage TabSeite
        Kontext "TabSeite"
        if Not Hoch.IsChecked then Warnlog "#i64991#Setting a printer make the page styles to be lost"
        TabSeite.Cancel
    end if

    '/// Set macro setting to previous value
    Call hSetMacroSecurity(PrevMacroSetting)

    '/// Close document
    Call hCloseDocument

endcase
'--------------------------------------------------------------------------

testcase i65094

    '/// New writer document
    Call hNewDocument
    '/// Open file \\writer\\optional\\input\\regression\\issuezilla\\i65094a.odt
    printlog "- Open file: i65094a.odt" 
    Call hFileOpen ( gTesttoolPath + "writer\optional\input\regression\issuezilla\i65094a.odt" )
    Call sMakeReadOnlyDocumentEditable
    '/// Compare document with other version \\writer\\optional\\input\\regression\\issuezilla\\i65094b.odt
'    UseBindings
    printlog "- Compare document with other version"
    EditCompareDocument
    Kontext "OeffnenDlg"
    '/// Open document ( i65094b.odt )
    Dateiname.SetText ConvertPath( gTesttoolPath + "writer\optional\input\regression\issuezilla\i65094b.odt" )
'    Sleep 2
    Oeffnen.Click
    Sleep 5
    Call sMakeReadOnlyDocumentEditable
    printlog "- Accept all"
    '/// In Redlining dialog select 'Accept all'
    Kontext "Redlining"
    if Redlining.exists then
        try
            AlleAkzeptieren.Click
            Sleep 1
        catch
            warnlog "accept button is disabled"
        endcatch
        '/// Close Redlining dialog
        Redlining.Close
        '/// Save document as "..\user\work\i65094compare.odt
        Call hFileSaveAsKill (gOfficepath + "user\work\i65094compare.odt")
        '/// Save document as "..\user\work\i65094compare.odt" 
        Wait 500
        printlog "- Compare done and document saved"
    else
        warnlog "Redlining dialog does not exist"
    end if
    Call hCloseDocument
    
endcase
'--------------------------------------------------------------------------

testcase i69045

    '/// New writer document
    Call hNewDocument
    printlog "- Open new dokument, enable redlining and make some changes"
    '/// Enable redlining
    EditChangesRecord
    '/// Change document
    Call wTypeKeys "Here are some changes"
    '/// Save document as "..\user\work\i65094compare.odt and close it
    Call hFileSaveAsKill (gOfficepath & "user\work\i69045.odt")
    Call hCloseDocument
    printlog "- Save, close and load document"
    '/// Open saved document
    Call hFileOpen ( gOfficepath & "user\work\i69045.odt" )
    '/// Check 
    try
        EditChangesAcceptOrReject
    catch
        warnlog "Redlining has not been saved or does not work"
    endcatch
    Kontext "Redlining"
    if Redlining.exists then
        try
            AlleAkzeptieren.Click
            Sleep 1
            printlog "- Edit changes has been saved and accepted"
        catch
            warnlog "AcceptAll is not enabled"
        endcatch    
        '/// Close Redlining dialog
        Redlining.Close
    end if
    Call hCloseDocument

endcase
'--------------------------------------------------------------------------

testcase i69521

    Dim iItems as integer

    '/// New writer document
    Call hNewDocument
    '/// Load document: \\writer\\optional\\input\\regression\\issuezilla\\i69521.odt
    Call hFileOpen (gTesttoolpath & "writer\optional\input\regression\issuezilla\i69521.odt")
    Call sMakeReadOnlyDocumentEditable
    '/// Loaded document should have 5 EPS Graphics
    iItems = CountItemsInNavigatorGroup(4)
    if iItems <> 5 then
        Warnlog "Initially there are not 5 Grahics in document but: " & iItems
        Call hCloseDocument
        goto endsub
    end if

    '/// save document as OfficePath\\user\work\\i96521-1.odt"
    Call hFileSaveAsKill (gOfficePath & "user\work\i96521-1.odt")
    '/// close document
    Call hCloseDocument
    '/// reload previous saved document
    Call hFileOpen (gOfficePath & "user\work\i96521-1.odt")
    '/// Check if all 5 Graphics are still in document
    iItems = CountItemsInNavigatorGroup(4)
    if iItems <> 5 then
        Warnlog "After save and reload there are not 5 Grahics in document but: " & iItems
    end if

    Call hCloseDocument

endcase
'--------------------------------------------------------------------------

testcase i75027

    Dim i as integer
    Dim j as integer
    Dim sClipBrd() as string
    Dim bNumberingError as boolean

    gApplication   = "HTML"
    '/// New HTML Document
    Call hNewDocument
    '/// type 'This<BR>is<BR>a numbering<BR>test'
    Call wTypeKeys ("This<Return>is<Return>a numbering<Return>test")
    '/// Select all paragraphs
    Call wTypeKeys ("<Mod1 A>")     
    '/// Format with simple numbering
    Kontext "TextObjectbar"
    if Not TextObjectbar.Exists then Call hToolbarSelect ( "FORMATTING", true )
    '/// Select 'Numbering' in object bar ///
    Numerierung.Click        
    '/// move "is" to numbering level 2
    '/// move "a numbering" to numbering level 3
    '/// move "test" to numbering level 4  
    printlog "- create numbering"
    Call wTypeKeys ("<Mod1 Home>"    
    for i = 1 to 3    
        Call wTypeKeys ("<Down>")
        Kontext "NumObjectbar"
        if Not NumObjectbar.Exists then Call hToolbarSelect("BULLETSANDNUMBERING", true)
        for j = 1 to 1 + i
            Hinunterstufen.Click
        next j
    next i
    '/// should look like:
    '/// 1. this
    '///    1. is 
    '///        1. a numbering
    '///            1. test
    printlog "- check numbering"
    Call wTypeKeys ( "<MOD1 A>" )
    EditCopy
    Select Case gPlatGroup
        Case "unx"
            sClipBrd() = Split (GetClipboardText, CHR$(10))
        Case else
            sClipBrd() = Split (GetClipboardText, CHR$(13) & CHR$(10))
    end select
    if Ubound(sClipBrd()) = 3 then
        if Left$(sClipBrd(0), 2) <> "1." then bNumberingError = true
        if Left$(sClipBrd(1), 2) <> "1." then bNumberingError = true
        if Left$(sClipBrd(2), 2) <> "1." then bNumberingError = true
        if Left$(sClipBrd(3), 2) <> "1." then bNumberingError = true
    else
        Warnlog "Error in clipboard content! " & Ubound(sClipBrd())
    end if
    if bNumberingError = true then
        Warnlog "Seems numbering I. has not been correctly created"
    end if
    bNumberingError = false
    '/// save as HTML-file i75027.html
    Call hFileSaveAsKill (gOfficepath & "user\work\i75027.html")    
    '/// Reload previous saved document
    Call hCloseDocument
    Call hFileOpen (gOfficepath & "user\work\i75027.html")
    '/// Check that the numbering is still the same.
    printlog "- check numbering (previous saved)"
    Call wTypeKeys ( "<MOD1 A>" )
    EditCopy
    Select Case gPlatGroup
        Case "unx"
            sClipBrd() = Split (GetClipboardText, CHR$(10))
        Case else
            sClipBrd() = Split (GetClipboardText, CHR$(13) & CHR$(10))
    end select
    if Ubound(sClipBrd()) = 3 then
        if Left$(sClipBrd(0), 2) <> "1." then bNumberingError = true
        if Left$(sClipBrd(1), 2) <> "1." then bNumberingError = true
        if Left$(sClipBrd(2), 2) <> "1." then bNumberingError = true
        if Left$(sClipBrd(3), 2) <> "1." then bNumberingError = true
    else
        Warnlog "Error in clipboard content! " & Ubound(sClipBrd())
    end if
    if bNumberingError = true then
        Warnlog "Seems numbering I. has not been correctly created"
    end if    
    '/// Close Document
    Call hCloseDocument
    gApplication   = "WRITER"

endcase
'--------------------------------------------------------------------------

testcase i76637

    'Variables:
    DIM sDocument           AS String 'variable for saving the doc

    gApplication   = "WRITER"
    
    '/// open a swriter
    Call hNewDocument 'NewDocument
    Kontext "DocumentWriter"
    printlog "New writer doc"
    
    '/// [Insert]-[Envelope]
    InsertEnvelope
    printlog "inserting envelope.."
    
    '/// click "New Doc" button in Envelope_Dlg
    Kontext
    active.SetPage TabEnvelope 'setting correct Tabpage
    Kontext "TabEnvelope"
    TabEnvelope.OK 'clicking on NewDoc button, which is OK button with another name
    
    '/// Save document
    sDocument = ConvertPath ( gOfficePath + "user\work\test1.odt")
    'deleting old Docs in the directory
    if Dir (sDocument) <> "" then kill sDocument 'deleting old docs
    Call hFileSaveAsKill (sDocument)
    printlog "Document saved"
    
    '/// click [File]-[Reload]
    Kontext "DocumentWriter"
    FileReload
    printlog "reloading ..here the crash happened in i76637."
    '///crash occured here

    Call hCloseDocument
    Call hCloseDocument
endcase

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

testcase i88656
    printlog "Test Format - AutoFormat - Apply And Edit Changes."

    printlog " Open a new writerdocument."
    Call hNewDocument
    printlog "Write the forrlowing text into the document: This is a test-text to be autoformatted."
    wTypeKeys ("This is a test-text to be autoformatted.")

    'Without text selected.
    printlog "Use the menu: Format - Autoformat - Apply and Edit Changes."
    FormatAutoformatApplyAndEditChanges

    kontext "active"
    if active.exists(2) then
       printlog " In the dialog: choose 'Accept."
       active.Ok
    end if

    printlog "Press SHIFT + HOME. To select the text we just wrote."
    wTypeKeys ("<SHIFT HOME>")

    'with text selected
    printlog "Again, but with the text selected; use the menu: Format - Autoformat - Apply and Edit Changes."
    FormatAutoformatApplyAndEditChanges

    kontext "active"
    if active.exists(3) then
       printlog " In the dialog: choose 'no'."
       active.Cancel
    end if

    kontext "active"
    if active.exists(3) then
       printlog " In the dialog: choose 'no'."
       active.No
    end if

    Call hCloseDocument
endcase

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

testcase i103265

	Dim i as integer

	printlog "ODF Hyperlinks in TOCs"
	Call hNewDocument
    printlog "- Open test document"
	Call hFileOpen ( gTesttoolPath + "writer\optional\input\regression\issuezilla\i103265.odt" )
    Call sMakeReadOnlyDocumentEditable
    printlog "- Update TOC"
	ToolsUpdateAllIndexes
	
	printlog "Check that every hyperlink jumps correctly to its target"
	For i = 1 to 3
		' point cursor to beginning of document
		Call wTypeKeys "<MOD1 HOME>"
		' point cursor to index entry
		Call wTypeKeys "<DOWN>", 4 + i
		'execute Hyperlink
		ContextOpenHyperlink
		' check if it jumps to correct target
		Call wTypeKeys "<SHIFT END>"
		EditCopy
		Select Case i
			Case 1:
				if GetClipboardText <> "# 1 Test" then
					Warnlog "First hyperlink not correctly jumped to. Not '# 1 Test' but " & GetClipboardtext
				end if
			Case 2:
				if GetClipboardText <> "1. Test" then
					Warnlog "First hyperlink not correctly jumped to. Not '# 1. Test' but " & GetClipboardtext
				end if
			Case 3:
				if GetClipboardText <> "Test " then
					Warnlog "First hyperlink not correctly jumped to. Not 'Test' but " & GetClipboardtext
				end if
		end select
	next i

	printlog "- Save as HTML"
	gApplication = "HTML"	
	Call hFileSaveAsWithFilterKill ( gOfficePath + "user\work\ODFHyperlinksInTOCs.html", "HTML (StarWriter)" )
    Call hCloseDocument
	
    printlog "- Reload"
	Call hFileOpen ( gOfficePath + "user\work\ODFHyperlinksInTOCs.html" )		
	printlog "Check that every hyperlink jumps correctly to its target"
	For i = 1 to 3
		' point cursor to beginning of document
		Call wTypeKeys "<MOD1 HOME>"
		' point cursor to index entry
		Call wTypeKeys "<DOWN>", 5 + i
		'execute Hyperlink
		ContextOpenHyperlink
		' check if it jumps to correct target
		Call wTypeKeys "<SHIFT END>"
		EditCopy
		Select Case i
			Case 1:
				if GetClipboardText <> "# 1 Test" then
					Warnlog "First hyperlink not correctly jumped to. Not '# 1 Test' but " & GetClipboardtext
				end if
			Case 2:
				if GetClipboardText <> "1. Test" then
					Warnlog "First hyperlink not correctly jumped to. Not '# 1. Test' but " & GetClipboardtext
				end if
			Case 3:
				if GetClipboardText <> "1Test " then
					Warnlog "First hyperlink not correctly jumped to. Not 'Test ' but " & GetClipboardtext
				end if
		end select
	next i
	
	Call hCloseDocument

endcase