summaryrefslogtreecommitdiff
path: root/testautomation/framework/optional/includes/basic_macros.inc
blob: 8f1d8905392bd93ba5bcdcd1ff39a90a7f938a9b (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
'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 : joerg.skottke@sun.com
' **
' ** short description : check macro-dialogs / BASIC-IDE ( 1. part )
' **
'\******************************************************************************


testcase tMakro_In_All_Apps


    dim brc as boolean
    dim cApp as string
    dim iApp as Integer
    dim bBug as Boolean
    dim cMsg as string
    bBug = FALSE
    
    const CMACRO = "AppMakro"
    

    for iApp = 1 to 7

        cApp = hNumericDoctype( iApp )
        printlog( cApp )

        printlog( "Open a new document" )
        brc = hCreateDocument()
        
        brc = hInitBasicIde( CMACRO )
        if ( not brc ) then
            warnlog( "Could not open the BASIC Macro Organizer, aborting" )
            call hDestroyDocument()
            goto endsub
        endif
        
        printlog "Close the BASIC-IDE"
        brc = hCloseBasicIde()
        
        printlog( "Close the navigator (Master-doc)" )
        brc = hCloseNavigator()
        
        printlog( "Close the document" )
        FileClose

        printlog( "Close the messagebox (document changed)" )
        kontext "messagebox"
        if ( MessageBox.Exists( 1 ) ) then
            cMsg = MessageBox.getText()
            cMsg = hRemoveLineBreaks( cMsg )
            printlog( "MessageBox: " & cMsg )
            MessageBox.No()
        else
            warnlog( "No warning for changed document" )
        end if

    next iApp
    
endcase

'*******************************************************************************

testcase tMakro_Dialog

    if ( gBuild < 9305 ) then
        warnlog( "#i87457# - Application macros assigned to userlayer" )
        goto endsub
    endif

    
    dim brc as boolean
    dim cMsg as string
    
    dim iPos as integer
    dim iLibraryItemCount as integer
    
    dim iCurrentLibrary as Integer
    dim XLBFILE as String
        XLBFILE = gTesttoolPath & "framework\optional\input\AppLibrary1\script.xlb"
    const CFN = "tMakro_Dialog::"
    const CMACRO = "MacroDlg"
    
    
    gApplication = "WRITER"
    printlog( "Open a new document" )
    brc = hCreateDocument()
    
    printlog( "Create a new library, a new module, open Basic-Ide" )
    brc = hInitBasicIde( CMACRO )
    if ( not brc ) then
        warnlog( CFN & "Could not open BASIC-IDE, aborting" )
        goto endsub
    endif
    
    printlog( "Close the Basic-Ide" )
    kontext "BasicIDE"
    hCloseBasicIde()
    
    printlog( "Open the Basic Macro Organizer" )
    brc = hOpenBasicOrganizerFromDoc()

    printlog( "Select the last Module for the current document" )
    iPos = hSelectTheLastNode( MakroAus )
    
    printlog( "Click Organize..." )
    Verwalten.Click()
    
    printlog( "Select Modules-tab" )
    brc = hSelectBasicObjectOrganizerTab( 1 )

    
    printlog( "Press 'new module'" )
    kontext "tabmodule"
    NeuesModul.Click()

    kontext "neuesmodul"
    printlog( "Cancel the dialog" )
    NeuesModul.Cancel()

    brc = hSelectBasicObjectOrganizerTab( 2 )

    kontext "tabdialogs"
    printlog( "Press 'new dialog'" )
    NewDialog.Click()
       
    printlog( "Cancel the dialog" )
    kontext "neuerdialog"
    NeuerDialog.Cancel()

    kontext
    printlog( "Select the libraries Tab" )
    brc = hSelectBasicObjectOrganizerTab( 3 )

    
    printlog( "Press 'New' on the libraries tab" )
    kontext "tabbibliotheken"
    Neu.Click()

    kontext "neuebibliothek"
    printlog( "Close the dialog with 'OK'" )
    Call DialogTest( NeueBibliothek )
    NeueBibliothek.OK()
    
    printlog( "Delete 'Library1'" )
    kontext "tabbibliotheken"
    Loeschen.Click()
    
    printlog( "Close the warning" )
    kontext "active"
    if ( Active.Exists() ) then
        cMsg = active.getText()
        cMsg = hRemoveLineBreaks( cMsg )
        printlog( "MessageBox: " & cMsg )
        Active.Yes()
    else
        warnlog( "Deletion warning is missing" )
    endif
  
    printlog( "Check the number of libraries in list" )
    kontext "tabbibliotheken"
    iLibraryItemCount = Bibliotheksliste.getItemCount()
    if ( iLibraryItemCount <> 1 ) then
        if ( iLibraryItemCount = 11 ) then
            warnlog( "#i87457# Macros moved from 'OpenOffice.org Macros' to 'My Macros'" )
        else
            warnlog( "Incorrect item count. Should be 1, is: " & iLibraryItemCount )
        endif
    endif

    printlog( "Append a xlb-file" )
    kontext "tabbibliotheken"
    Hinzufuegen.Click()

    printlog( "Select 'AppLibrary1/script.xlb' from the files list" 
    kontext "oeffnendlg"
    Dateiname.SetText( ConvertPath ( XLBFILE ) )
    Oeffnen.Click()
    
    ' If the .xlb file cannot be found the test cannot continue. Warn and cleanup.
    kontext "Active"
    if ( Active.exists( 1 ) ) then
    
        try
            Active.getButtonCount()
            
            warnlog( "Script does not exist warning displayed. Aborting test" )
            printlog( Active.getText() )
            active.ok()
            
            kontext "OeffnenDlg"
            if ( OeffnenDlg.exists( 1 ) ) then
                printlog( "Closing File Open dialog" )
                OeffnenDlg.cancel()
            endif
            
            kontext "tabbibliotheken"
            if ( TabBibliotheken.exists( 1 ) ) then
                printlog( "Closing Libaries tab" )
                TabBibliotheken.close()
            endif
            
            kontext "Makro"
            if ( Makro.exists( 1 ) ) then
                printlog( "Closing Macro organizer" )
                Makro.close()
            endif
            
            printlog( "Exiting test" )
            goto endsub
        catch
            printlog( "Script found and loaded. Good." )
        endcatch
        
    endif

    printlog( "Ensure 'Insert as Reference' is unchecked" )
    kontext "appendlibraries"
    InsertAsReference.UnCheck()

    printlog( "Check 'Replace existing library'" )
    ReplaceExistingLibraries.Check()

    printlog( "Press 'OK' to append the library" )
    kontext "appendlibraries"
    try
        AppendLibraries.OK()
    catch
        warnlog( "#i85254# Appending libraries leads to crash" )
    endcatch

    printlog( "Check the number of libraries in list (should be two)" )
    kontext "tabbibliotheken"
    iLibraryItemCount = Bibliotheksliste.getItemCount()
    if ( iLibraryItemCount <> 2 ) then
        qaerrorlog( "#i87457# Two entries in list expected, found " & iLibraryItemCount )
    endif

    printlog( "Select the first item" )
    Bibliotheksliste.TypeKeys( "<HOME>" )
    for iCurrentLibrary = 1 to iLibraryItemCount 
        if ( Bibliotheksliste.getSelText() = "AppLibrary1" ) then
            printlog( "Found AppLibrary1" )
            exit for
        endif
        printlog( "This was not AppLibrary1, trying again" )
        Bibliotheksliste.Typekeys( "<DOWN>" )
    next iCurrentLibrary
    
    printlog( "Set a password for AppLibrary1" )
    kontext "tabbibliotheken"
    if ( Passwort.IsEnabled() ) then
        Passwort.Click()
        kontext "passwddlg"
        PasswdDLG.Cancel()
    else
        warnlog( "Password is disabled for 'AppLibrary1'" )
    endif

    printlog( "Delete 'AppLibrary1'" )
    kontext "tabbibliotheken"
    Loeschen.Click()
    
    printlog( "Close the warning with YES" )
    kontext "active"
    if ( Active.Exists() ) then
        cMsg = active.getText()
        cMsg = hRemoveLineBreaks( cMsg )
        printlog( "MessageBox: " & cMsg )
        Active.Yes()
    else
        warnlog( "Expected confirmation dialog for delete" )
    endif
    
    kontext "tabbibliotheken"
    printlog( "Press 'edit' on 'Libraries'-tab" )
    Bearbeiten.Click()

    kontext "BasicIDE"
    if ( BasicIDE.Exists( 5 ) ) then
    
        hInsertMacro( 3 )
    
        printlog( "Close the basic-document" )
        brc = hCloseBasicIde()

        kontext "active"
        if ( Active.Exists ( 2 ) ) then
            cMsg = active.getText()
            cMsg = hRemoveLineBreaks( cMsg )
            warnlog( "Unexpected MessageBox: " & cMsg )
            Active.NO()
        endif

    else
        warnlog("#i38978# The Macro-Document is not open, aborting test")
        call hDestroyDocument()
        goto endsub
    endif

    printlog( "Open the BASIC Macro Organizer" )
    brc = hOpenBasicOrganizerFromDoc()
    
    printlog( "Select the last macro from the list" )
    kontext "makro"
    iPos = hSelectTheLastNode( MakroAus )
    
    try
        printlog( "Assign the macro, Tools/customize dialog should open" )
        Zuordnen.Click ()
    catch
        warnlog( "#i106853# Assign-Button is disabled or macro is missing" )
    endcatch

    printlog( "Activate all tapages and cancel the Tools/Customize dialog" )
    
    brc = hToolsCustomizeSelectTab( "menu" )
    brc = hToolsCustomizeSelectTab( "keyboard" 
    if ( not brc ) then
        qaerrorlog( "#i61765# Keyboard tab missing when called via Tools/Macros->Assign" )
    endif
    brc = hToolsCustomizeSelectTab( "events" )
    brc = hToolsCustomizeSelectTab( "toolbars" )

    printlog( "Cancel Tools/Customize dialog -> Macro Organizer should be open" )    
    brc = hToolsCustomizeClose( 2 )
    
    
    printlog "Click to run macro"
    kontext "makro"
    try
        Ausfuehren.Click()
    catch
        warnlog( "Unable to run macro" )
        kontext "Makro"
        Makro.close()
    endcatch
    
    kontext "active"
    if ( active.exists() ) then
        cMsg = active.getText()
        cMsg = hRemoveLineBreaks( cMsg )
        if ( cMsg = "TTMacro3" ) then
            printlog( "The correct macro has been executed" )
        else
            warnlog( "Unknown Messagebox: " & cMsg ) 
        endif
        Active.OK()
    endif
    
    printlog( "Open macro organizer from the current document" )
    brc = hOpenBasicOrganizerFromDoc()
    
    printlog( "Select the last item in the treelist" )
    brc = hSelectTheLastNode( MakroAus )

    printlog( "Delete the new module" )
    Loeschen.Click()
    
    printlog( "Close the deletion warning" )
    kontext "active"
    if ( active.exists() ) then
        cMsg = active.getText()
        cMsg = hRemoveLineBreaks( cMsg )
        printlog( "MessageBox: " & cMsg )
        Active.Yes()
    else
        warnlog( "No confirmation dialog for delete" )
    endif
    
    printlog( "Close the macro organizer" )
    kontext "makro"
    Makro.Close()
    
    printlog( "Close the document" )
    Call hDestroyDocument()
    
    
endcase