summaryrefslogtreecommitdiff
path: root/testautomation/writer/optional/includes/autocorrection/w_autocorrect2.inc
blob: 57e8f5ad073bbb81707719b63f426b21b25e96d5 (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
'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 : Test AutoCorrect/AutoFormat/Word Completion
'*
'\***********************************************************************

sub w_autocorrect2

    printLog Chr(13) + "- Test the AutoCorrect/AutoFormat Word Completion features"    
    Call tToolsAutocorrectWordCompletion_1     'Check the default settings
    Call tToolsAutocorrectWordCompletion_2     'Check entries
    Call tToolsAutocorrectWordCompletion_3     'Check list of suggestions can be "scrolled"
    Call tToolsAutocorrectWordCompletion_4     'Test Max entries
    Call tToolsAutocorrectWordCompletion_5     'Check 'When closing a document, save the list for later use in other documents'
    Call tToolsAutocorrectWordCompletion_6

end sub

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

testcase tToolsAutocorrectWordCompletion_1

    Dim iAcceptWith as String
    Dim iEntriesNumber as Integer
    Dim sMinWordLength as String
    Dim sMaxEntries as String
    Dim sMinMaxEntries as String

    iAcceptWith     = 2
    iEntriesNumber  = 0
    sMinWordLength  = "10"
    sMaxEntries     = "500"
    sMinMaxEntries  = "50"

    printLog "Check the default settings"
    '/// Check the default settings
    '/// - Check box "Enable word completion" (default: checked)
    '/// - Check box "Append Space" (default: unchecked)
    '/// - Check box "Show as tip" (default: unchecked)
    '/// - Check box "Collect Words" (default: checked)
    '/// - Check box "When closing a document, remove the words collected from it from the list" (default: unchecked)
    '/// - List box "Accept with" (Default = "Return")
    '/// - Spin box "minimal number of characters" default = 10
    '/// - Spin box "Max. entries" (default =500, minimum = 50)
    '/// - Box: "List of words collected" -- should be empty after Office restart.

    Call hNewDocument
    'Delete all entries in the list
    Call fDeleteAllEntries()

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"

    if WoerterErgaenzen.IsChecked   = False           then Warnlog "Complete words should be checked ."
    if AppendSpace.IsChecked        =  TRUE           then Warnlog "Append space should be UNchecked ."
    if AlsTipphilfe.IsChecked       =  TRUE           then Warnlog "Show as tip should be UNchecked ."
    if VorschlaegeSammeln.IsChecked <> TRUE           then Warnlog "Collect suggestions should be checked ."
    if KeepList.IsChecked           = TRUE            then Warnlog "When closing a document, remove the words collected from it from the list should be unchecked ."
    if AnnehmenMit.GetSelIndex      <> iAcceptWith    then Warnlog "The Accept with should be 'Enter' ."
    if MinWortlaenge.GetText        <> sMinWordLength then Warnlog "Min word length should be " + sMinWordLength
    if MaxEintraege.GetText         <> sMaxEntries    then Warnlog "Max entries should be " + sMaxEntries
    if GesammelteWorte.GetItemCount <> iEntriesNumber then Warnlog "Entries number  should be " + iEntriesNumber

    MaxEintraege.SetText "49"

    TabWortergaenzung.OK

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if MaxEintraege.GetText <> sMinMaxEntries then Warnlog "Max entries should be " + sMinMaxEntries
    MaxEintraege.SetText sMaxEntries
    TabWortergaenzung.OK

    Call hCloseDocument

endcase

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

testcase tToolsAutocorrectWordCompletion_2

    Dim iDefaultEntriesNumber as Integer
    Dim iEntriesNumber as Integer
    Dim i as Integer
    Dim sMinWordLength as String

    iDefaultEntriesNumber  = 0
    iEntriesNumber         = 3
    sMinWordLength         = "5"

    printLog "Check the default settings"
    '/// Check entries
    '/// delete all entries first
    '/// input some test words
    '/// check if some words should are remembered in the entries
    '/// delete all entries
    '/// close and reopen dialog, check entries again

    Call hFileOpen ( gTesttoolPath + "writer\optional\input\autocorrection\01.odt" )
    Call sMakeReadOnlyDocumentEditable
    'Delete all entries in the list
    Call fDeleteAllEntries()

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount <> 0 then
        Warnlog "Entries number should be " + iDefaultEntriesNumber
        Warnlog "No test for this case"
        TabWortergaenzung.Cancel
        Call hCloseDocument
    end if
    MinWortlaenge.SetText sMinWordLength
    TabWortergaenzung.OK

    Call wTypeKeys "Hello World ! This is a OpenOffice.org Test .<Return>"
    Sleep 3

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount <> 3 then Warnlog "Entries number should be " + iEntriesNumber
    for i = 1 to GesammelteWorte.GetItemCount
        GesammelteWorte.Select 1
        if EintragLoeschen.IsEnabled then
            EintragLoeschen.Click
        else
            i = GesammelteWorte.GetItemCount + 1
        end if
    next i
    TabWortergaenzung.OK
    Sleep 1

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount <> 0 then Warnlog "Entries number should be " + 0
    TabWortergaenzung.Cancel

    Call hCloseDocument

endcase

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

testcase tToolsAutocorrectWordCompletion_3

    Dim aTestWord() as String
    Dim sPartOfTestWord as String
    Dim i as Integer
    Dim j as integer

    aTestWord = Array( "accessibility", "accomplish", "accounting" )
    
    sPartOfTestWord = "acc"

    printLog "Check list of suggestions can be 'scrolled'"
    '/// Check list of suggestions can be 'scrolled'

    '/// input some test words with first 3 letters are same
    '/// forward with <CTRL-Tab>
    '/// backwards with <SHIFT-CTRL-Tab>
    '/// endless loop test

    Call hFileOpen ( gTesttoolPath + "writer\optional\input\autocorrection\01.odt" )
    Call sMakeReadOnlyDocumentEditable
    'Delete all entries in the list
    Call fDeleteAllEntries()

    'forward with <CTRL-Tab>
    For i = 0 to 2
        Call wTypeKeys aTestWord(i)
        Call wTypeKeys "<Return>"
    next i
    Sleep 2

    For i = 0 to 2
        Call wTypeKeys sPartOfTestWord
        if i > 0 then Call wTypeKeys "<MOD1 TAB>", i
        Sleep 2
        Call wTypeKeys "<Return>"
        Call wTypeKeys "<Shift Home>"
        EditCopy
        if GetClipboardText <> aTestWord(i) then Warnlog "#102535# Should be " +aTestWord(i) +" but get " +GetClipboardText
        Call wTypeKeys "<Delete>"
    next i

    'endless loop test
    Call wTypeKeys sPartOfTestWord
    Call wTypeKeys "<MOD1 TAB>", 3
    Call wTypeKeys "<Return>"
    Call wTypeKeys "<Shift Home>"
    EditCopy
    if GetClipboardText <> aTestWord(0) then Warnlog "#102535# Should be " +aTestWord(0) +" but get " +GetClipboardText
    Call wTypeKeys "<Delete>"

    'backwards with <SHIFT-CTRL-Tab>
    j = UBound (aTestWord)

    For i = j to 0 step -1
        Call wTypeKeys sPartOfTestWord
        Call wTypeKeys "<MOD1 TAB>", j
        if i > 0 then Call wTypeKeys "<Shift MOD1 TAB>", i
        Call wTypeKeys "<Return>"
        Call wTypeKeys "<Shift Home>"
        EditCopy
        if GetClipboardText <> aTestWord(j-i) then Warnlog "#102535# Should be " +aTestWord(j-i) +" but get " +GetClipboardText
        Call wTypeKeys "<Delete>"
    next i

    'endless loop test
    Call wTypeKeys sPartOfTestWord
    Call wTypeKeys "<Shift MOD1 TAB>"
    Call wTypeKeys "<Return>"
    Call wTypeKeys "<Shift Home>"
    EditCopy
    if GetClipboardText <> "accounting" then Warnlog "#102535# Should be 'accounting' but get " +GetClipboardText

    Call hCloseDocument

endcase

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

testcase tToolsAutocorrectWordCompletion_4

    Dim sDefaultMaxEntries as String
    Dim sTestMaxEntries as String
    Dim sTestFile as String
    Dim iTestMaxEntries as Integer

    sDefaultMaxEntries  =  "500"
    sTestMaxEntries     =  "50"
    sTestFile           =  "tToolsAutocorrectWordCompletion_4.sxw"
    iTestMaxEntries     =  50

    printLog "Test Max entries"
    '/// Test Max entries

    '/// Delete all entries in the list
    '/// set Max entries to 50
    '/// Open the test file ( The entries number is > 50 when Max entries is 500)
    '/// check the number of entries.

    Call hNewDocument
    'Delete all entries in the list
    Call fDeleteAllEntries()

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    MaxEintraege.SetText sTestMaxEntries
    TabWortergaenzung.OK

    Call hFileOpen ( gTesttoolPath + "writer\optional\input\advanced\" + sTestFile )
    Call sMakeReadOnlyDocumentEditable
    Sleep 4

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount > iTestMaxEntries then Warnlog "Entries number should be less than " + iTestMaxEntries

    'Recover to default
    MaxEintraege.SetText sDefaultMaxEntries
    TabWortergaenzung.OK

    Call hCloseDocument

endcase

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

testcase tToolsAutocorrectWordCompletion_5

    Dim sTestWord1 as String
    Dim sTestWord2 as String
    Dim sTestWord3 as String
    Dim iEntriesNumber_Checked as Integer
    Dim iEntriesNumber_UnChecked as Integer

    sTestWord1               = "kilometer "
    sTestWord2               = "entertainment "
    sTestWord3               = "education "
    iEntriesNumber_Checked   = 3
    iEntriesNumber_UnChecked = 1

    printLog "Check 'When closing a document, remove the words collected from it from the list'"
    '/// Check 'When closing a document, remove the words collected from it from the list'
    '/// delete all entries first.
    '/// 1) check when the checkbox is unchecked
    '///    a) Open a file, type "kilometer"
    '///    b) Open 2nd file, type "entertainment" and "education"
    '///    c) Close 2nd file, the number of entries in first file should be 3
    '/// 2) check when the checkbox is checked
    '///    delete all entries , and Uncheck the testing checkbox
    '///    a) Open a file, type "kilometer"
    '///    b) Open 2nd file, type "entertainment" and "education"
    '///    c) Close 2nd file, the number of entries in first file should be 1

    'Test when checkbox is checkec -- default

    'Open 1st file
    Call hFileOpen ( gTesttoolPath + "writer\optional\input\autocorrection\01.odt" )
    Call sMakeReadOnlyDocumentEditable

    'Delete all entries in the list
    Call fDeleteAllEntries()

    ' check checkbox
    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    MinWortlaenge.SetText "5"
    KeepList.UnCheck
    TabWortergaenzung.Ok

    Call wTypeKeys sTestWord1

    'Open 2nd file
    Call hFileOpen ( gTesttoolPath + "writer\optional\input\autocorrection\01-01.odt" )
    Call sMakeReadOnlyDocumentEditable

    Call wTypeKeys sTestWord2
    Call wTypeKeys sTestWord3

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount <> 3 then
        Warnlog "Checked:Entries number should be equal 3 in 2nd file ,but get " + GesammelteWorte.GetItemCount
    end if
    TabWortergaenzung.Cancel

    'Close 2nd file
    Call hCloseDocument

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount <> 3 then
        Warnlog "Checked:Entries number should be equal 3 in 1st file ,but get " + GesammelteWorte.GetItemCount
    end if
    TabWortergaenzung.Cancel

    Call hCloseDocument

    'Test when checkbox is Checked
    'Open 1st file
    Call hFileOpen ( gTesttoolPath + "writer\optional\input\autocorrection\01.odt" )
    Call sMakeReadOnlyDocumentEditable

    'Delete all entries in the list
    fDeleteAllEntries()

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"

    KeepList.Check
    TabWortergaenzung.OK

    Call wTypeKeys sTestWord1

    'Open 2nd file
    Call hFileOpen ( gTesttoolPath + "writer\optional\input\autocorrection\01-01.odt" )
    Call sMakeReadOnlyDocumentEditable

    Call wTypeKeys sTestWord2
    Call wTypeKeys sTestWord3

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount <> 3 then
        Warnlog "UnChecked:Entries number should be equal 3 in 2nd file ,but get " + GesammelteWorte.GetItemCount
    end if
    TabWortergaenzung.Cancel

    'Close 2nd file
    Call hCloseDocument

    ToolsAutocorrect
    Kontext
    Active.Setpage TabWortergaenzung
    Kontext "TabWortergaenzung"
    if GesammelteWorte.GetItemCount <> 1 then
        Warnlog "UnChecked:Entries number should be equal 1 in 2nd file ,but get " +GesammelteWorte.GetItemCount
    end if
    TabWortergaenzung.Cancel

    'Close 1st file
    Call hCloseDocument

endcase

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

testcase tToolsAutocorrectWordCompletion_6

    Dim sTestWord as String
    Dim sPartOfTestWord as String

    sTestWord       = "OpenOffice.org"
    sPartOfTestWord = "Ope"

    printLog "Check Show as Tip"
    '/// Check Show as Tip

    '/// When uncheck ( default) , the left word will be highlight
    '/// When check  , the left word will NOT be appeared,  <--- can test
    '/// and a help tip will appear       <--- no way to test yet

    'Show as Tip -- uncheck (default)
    Call hFileOpen ( gTesttoolPath + "writer\optional\input\autocorrection\01.odt" )
    Call sMakeReadOnlyDocumentEditable

    Call wTypeKeys sTestWord
    Call wTypeKeys "<Return>"
    Sleep 1
    Call wTypeKeys sPartOfTestWord
    Sleep 4
    Call wTypeKeys "<Return>"
    Call wTypeKeys "<Shift Home>"

    Sleep 1
    Call wTypeKeys "StaS"
    Sleep 4
    Call wTypeKeys "<Return>"

    Call hCloseDocument

endcase