summaryrefslogtreecommitdiff
path: root/testautomation/framework/required/includes/graphics_import.inc
blob: a2a92f961274c8f1eda3d094a87e3b74109ea876 (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
'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 : Graphic import (2nd file for the first.bas)
'*
'\******************************************************************************


testcase tQuickInsertGraphNotAsLink

    printlog( "Load files of all known graphics formats" )
    
    dim iCurrentFile as integer
    dim GraphicFile as String
    dim Filtername as String

    printlog( "Insert a sample of commonly used file formats into a writer document (not linked)" )
    
    if ( gUseSysDlg ) then
        warnlog( "This test needs the OpenOffice.org filepicker to be set as default" )
        goto endsub
    endif
    
    gApplication = "WRITER"    
    Call hNewDocument
    
    for iCurrentFile = 1 to 25

        ' MODIFY and ENABLE this SAMPLE snippet to exclude one fileformat from testing
        '         if ( iCurrentFile = 7 ) AND (gtPlatform="x86") then
        '             qaErrorLog("#<issue-id># crash on <platform> on loading <image-file>")
        '             goto skipformat
        '         endif
        ' Note: Can be locale dependent!
        if (iCurrentFile = 4) AND (gPlatform="osx") then
            qaerrorlog("#i100253# crash on MacOS X on loading ball.eps")
            goto skipformat
        endif

        Kontext "GrafikEinfuegenDlg"
        if ( not GrafikEinfuegenDlg.exists() ) then
            InsertGraphicsFromFile
            Kontext "GrafikEinfuegenDlg"
        endif
        
        if ( GrafikEinfuegenDlg.Exists( 2 ) ) then
            ' the list of files expected to be found in the samples directory
            select case iCurrentFile
                case 1  :  GraphicFile = "desp.bmp"
                case 2  :  GraphicFile = "columbia.dxf"
                case 3  :  GraphicFile = "extrud.emf"
                case 4  :  GraphicFile = "ball.eps"
                case 5  :  GraphicFile = "airshw.met"
                case 6  :  GraphicFile = "eface.gif"
                case 7  :  GraphicFile = "purzel.gif"         ' Animated Gif
                case 8  :  GraphicFile = "borabora.jpg"
                case 9  :  GraphicFile = "grafix1.pbm"
                case 10 :  GraphicFile = "circle.pcx"
                case 11 :  GraphicFile = "papagei1.pcd"
                case 12 :  GraphicFile = "newtonme.pct"
                case 13 :  GraphicFile = "grafix2.pgm"
                case 14 :  GraphicFile = "obst.png"
                case 15 :  GraphicFile = "london.ppm"
                case 16 :  GraphicFile = "tiger.psd"
                case 17 :  GraphicFile = "grafix3.ras"
                case 18 :  GraphicFile = "mickym.sgf"
                case 19 :  GraphicFile = "faxpfeil.sgv"
                case 20 :  GraphicFile = "picture.svm"
                case 21 :  GraphicFile = "pilz.tga"
                case 22 :  GraphicFile = "stabler.tif"
                case 23 :  GraphicFile = "krokodil.wmf"
                case 24 :  GraphicFile = "grafix4.xbm"
                case 25 :  GraphicFile = "papagei2.xpm"
            end select
            
            GraphicFile = ConvertPath (gTesttoolPath & "global\input\graf_inp\" & GraphicFile)
            printlog( "Current file " + iCurrentFile + ": " & GraphicFile )
            printlog( " * Set filter to <All formats>" )
            DateiName.SetText( GraphicFile )
            DateiTyp.Select( 1 )
            WaitSlot()
            
            printlog( " * Uncheck Preview- and Link-checkbox, load the file" )
            Vorschau.unCheck
            Verknuepfen.unCheck()
            Oeffnen.click()
            WaitSlot( 2000 )
            
            Kontext "Active"
            if ( Active.Exists() ) then
                Warnlog( "Unexpected messagebox: " & Active.GetText() )
                Warnlog( "Affected file: " & GraphicFile )
                Active.OK
            else
                try
                    EditCopy
                    WaitSlot( 2000 )
                    EditDeleteContents
                    WaitSlot( 2000 )
                catch
                    Warnlog( "Graphic file not selected/Copy or Delete is disabled: " & GraphicFile )
                    gMouseClick (90, 90)
                endcatch
            endif
        else 
            warnlog( "Insert Graphics Dialog is not open, aborting" )
            goto endsub
        endif
        
    skipformat:
    next iCurrentFile
    
    printlog( "" )
    printlog( "Test the PCD-Filters directly (3 samples)" )
    
    for iCurrentFile = 1 to 3
    
        printlog( "" )
        
        Kontext "GrafikEinfuegenDlg"
        if ( not GrafikEinfuegenDlg.exists() ) then
            InsertGraphicsFromFile
            Kontext "GrafikEinfuegenDlg"
        endif

        if ( GrafikEinfuegenDlg.exists( 2 ) ) then
            
            select case iCurrentFile
            case 1 : Filtername = "PCD - Kodak Photo CD (768x512) (*.pcd)"
            case 2 : Filtername = "PCD - Kodak Photo CD (384x256) (*.pcd)"
            case 3 : Filtername = "PCD - Kodak Photo CD (192x128) (*.pcd)"
            end select
            
            GraphicFile = ConvertPath( gTesttoolPath & "global\input\graf_inp\papagei1.pcd" )
            
            printlog( "Current filter: " & Filtername )
            printlog( "Current file..: " & GraphicFile )
            DateiName.SetText ( GraphicFile )
            DateiTyp.Select( Filtername )
            
            printlog( " * Uncheck Preview- and Link-checkbox, load the file" )
            Vorschau.Uncheck()
            Verknuepfen.unCheck()
            Oeffnen.click()
            WaitSlot( 2000 )
            
            Kontext "Active"
            if ( Active.Exists() )then
                Warnlog( "Unexpected messagebox: " & Active.GetText() )
                Warnlog( "Affected file..: " & GraphicFile )
                Warnlog( "Affected filter: " & Filtername )
                Active.OK()
            else
                try
                    EditCopy
                    WaitSlot( 2000 )
                    EditDeleteContents
                    WaitSlot( 2000 )
                catch
                    Warnlog( "Problems with filtertype : " & Filtername )
                    gMouseClick (90, 90)
                endcatch
            endif
        else
            warnlog( "Insert Graphics Dialog is not open. Aborting" )
            goto endsub
        endif
        
    next iCurrentFile
    
    Kontext "GrafikEinfuegenDlg"
    if GrafikEinfuegenDlg.Exists then
        GrafikEinfuegenDlg.Cancel
    endif
    
    Call hCloseDocument

endcase

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

testcase tInFilterCountCompare()

    printlog( "Check filterlist (filterstring) for graphics files" )
    
    if ( gUseSysDlg ) then
        warnlog( "This test needs the OpenOffice.org filepicker to be set as default" )
        goto endsub
    endif
    
    const FILE_NAME = "graphic_filters.txt"
    const SUFFIX_STRING_LENGTH = 178
    
'   List of filter suffixes for verification in case of error
'   *.bmp;*.dxf;*.emf;*.eps;*.gif;*.jpg;*.jpeg;*.jfif;*.jif;*.met;*.pbm;*.pcd;
'   *.pct;*.pcx;*.pgm;*.png;*.ppm;*.psd;*.ras;*.sgf;*.sgv;*.svm;*.tga;*.tif;
'   *.tiff;*.wmf;*.xbm;*.xpm;*.pict
        
    dim caUIFilters( 30 ) as string

    dim cReferencePath as string
        cReferencePath = gTesttoolPath & "global/input/filters/"
        cReferencePath = convertpath ( cReferencePath & FILE_NAME )
        
    dim cUIFiltersPath as string 
        cUIFiltersPath = hGetWorkPath() & FILE_NAME
        
    dim iCurrentFilter as integer
    dim iFilterCount as integer
    
    dim cAllFormats as string
    
    dim irc as integer
    dim iBegin as integer
    dim iEnd as integer

    printlog( "" )
    printlog( "Verify filternames listed on the Insert Graphics dialog" )

    hCreateDocument()
    hChangeDoc()
    
    InsertGraphicsFromFile
    
    kontext "GrafikEinfuegenDlg"
    if ( GrafikEinfuegenDlg.exists( 1 ) ) then
        iFilterCount = DateiTyp.getItemCount()
        
        'Make list compatible with listfunctions
        caUIFilters( 0 ) = iFilterCount - 1
        
        for iCurrentFilter = 2 to iFilterCount
        
            caUIFilters( iCurrentFilter - 1 ) = DateiTyp.getItemText( iCurrentFilter )
            
        next iCurrentFilter
        
        irc = hManageComparisionList( cReferencePath, cUIFiltersPath, caUIFilters() )
        if ( irc <> 0 ) then
            warnlog( "The list of graphic format filters has changed" )
        endif
        
        printlog( "" )
        printlog( "Verify <All formats>-string" )
        cAllFormats = DateiTyp.getItemText( 1 )
        
        iBegin = instr( cAllFormats, "<" )
        if ( iBegin <> 1 ) then
            warnlog( "The opening bracket < is missing in <All formats> string" )
        endif
        
        iEnd = instr( cAllFormats, ">" )
        if ( iEnd = 0 ) then
            warnlog( "The closing bracket > is missing in <All formats> string" )
        endif
        
        if ( ( iEnd - iBegin ) < 2 ) then
            warnlog( "<All formats> string is shorter than expected, please check" )
            printlog( "String is: " & cAllFormats & ", length (" & len( cAllFormats ) & ")" )
        endif
        
        iBegin = instr( cAllFormats, "(" )
        if ( iBegin <> iEnd + 2 ) then
            warnlog( "The opening bracket ( is missing in <All formats> string" )
        endif
        
        iEnd = instr( cAllFormats, ")" )
        if ( iEnd < 10 ) then
            warnlog( "The closing bracket ) is missing in <All formats> string" )
        endif   
        
        irc = iEnd - iBegin
        if ( irc <> SUFFIX_STRING_LENGTH ) then
            warnlog( "The list of file suffixes has changed, please verify" )
            printlog( "Found: " & irc & " chars, expected " & SUFFIX_STRING_LENGTH )
        endif
        
        kontext "GrafikEinfuegenDlg"
        GrafikEinfuegenDlg.cancel()
    else
        warnlog( "<Insert Graphics> dialog did not open" )
    endif

    hDestroyDocument()
    


endcase