1 'encoding UTF-8 Do not remove or change this line!
2 '*******************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: graphics_import.inc,v $
13 '* last change: $Author: obo $ $Date: 2008-07-25 08:03:02 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : joerg.skottke@sun.com
36 '* short description : Graphic import (2nd file for the first.bas)
38 '\******************************************************************************
41 testcase tQuickInsertGraphNotAsLink
42 dim iCurrentFile as integer
43 dim GraphicFile as String
44 dim Filtername as String
46 printlog( "Insert a sample of commonly used file formats into a writer document (not linked)" )
48 if ( gUseSysDlg ) then
49 warnlog( "This test needs the OpenOffice.org filepicker to be set as default" )
53 gApplication = "WRITER"
56 for iCurrentFile = 1 to 25
58 ' MODIFY and ENABLE this SAMPLE snippet to exclude one fileformat from testing
59 ' if ( iCurrentFile = 7 ) AND (gtPlatform="x86") then
60 ' qaErrorLog("#<issue-id># crash on <platform> on loading <image-file>")
63 ' Note: Can be locale dependent!
64 if (iCurrentFile = 4) AND (gPlatform="osx") then
65 qaerrorlog("#i100253# crash on MacOS X on loading ball.eps")
69 Kontext "GrafikEinfuegenDlg"
70 if ( not GrafikEinfuegenDlg.exists() ) then
71 InsertGraphicsFromFile
72 Kontext "GrafikEinfuegenDlg"
75 if ( GrafikEinfuegenDlg.Exists( 2 ) ) then
76 ' the list of files expected to be found in the samples directory
77 select case iCurrentFile
78 case 1 : GraphicFile = "desp.bmp"
79 case 2 : GraphicFile = "columbia.dxf"
80 case 3 : GraphicFile = "extrud.emf"
81 case 4 : GraphicFile = "ball.eps"
82 case 5 : GraphicFile = "airshw.met"
83 case 6 : GraphicFile = "eface.gif"
84 case 7 : GraphicFile = "purzel.gif" ' Animated Gif
85 case 8 : GraphicFile = "borabora.jpg"
86 case 9 : GraphicFile = "grafix1.pbm"
87 case 10 : GraphicFile = "circle.pcx"
88 case 11 : GraphicFile = "papagei1.pcd"
89 case 12 : GraphicFile = "newtonme.pct"
90 case 13 : GraphicFile = "grafix2.pgm"
91 case 14 : GraphicFile = "obst.png"
92 case 15 : GraphicFile = "london.ppm"
93 case 16 : GraphicFile = "tiger.psd"
94 case 17 : GraphicFile = "grafix3.ras"
95 case 18 : GraphicFile = "mickym.sgf"
96 case 19 : GraphicFile = "faxpfeil.sgv"
97 case 20 : GraphicFile = "picture.svm"
98 case 21 : GraphicFile = "pilz.tga"
99 case 22 : GraphicFile = "stabler.tif"
100 case 23 : GraphicFile = "krokodil.wmf"
101 case 24 : GraphicFile = "grafix4.xbm"
102 case 25 : GraphicFile = "papagei2.xpm"
105 GraphicFile = ConvertPath (gTesttoolPath & "global\input\graf_inp\" & GraphicFile)
106 printlog( "Current file " + iCurrentFile + ": " & GraphicFile )
107 printlog( " * Set filter to <All formats>" )
108 DateiName.SetText( GraphicFile )
112 printlog( " * Uncheck Preview- and Link-checkbox, load the file" )
114 Verknuepfen.unCheck()
119 if ( Active.Exists() ) then
120 Warnlog( "Unexpected messagebox: " & Active.GetText() )
121 Warnlog( "Affected file: " & GraphicFile )
130 Warnlog( "Graphic file not selected/Copy or Delete is disabled: " & GraphicFile )
135 warnlog( "Insert Graphics Dialog is not open, aborting" )
143 printlog( "Test the PCD-Filters directly (3 samples)" )
145 for iCurrentFile = 1 to 3
149 Kontext "GrafikEinfuegenDlg"
150 if ( not GrafikEinfuegenDlg.exists() ) then
151 InsertGraphicsFromFile
152 Kontext "GrafikEinfuegenDlg"
155 if ( GrafikEinfuegenDlg.exists( 2 ) ) then
157 select case iCurrentFile
158 case 1 : Filtername = "PCD - Kodak Photo CD (768x512) (*.pcd)"
159 case 2 : Filtername = "PCD - Kodak Photo CD (384x256) (*.pcd)"
160 case 3 : Filtername = "PCD - Kodak Photo CD (192x128) (*.pcd)"
163 GraphicFile = ConvertPath( gTesttoolPath & "global\input\graf_inp\papagei1.pcd" )
165 printlog( "Current filter: " & Filtername )
166 printlog( "Current file..: " & GraphicFile )
167 DateiName.SetText ( GraphicFile )
168 DateiTyp.Select( Filtername )
170 printlog( " * Uncheck Preview- and Link-checkbox, load the file" )
172 Verknuepfen.unCheck()
177 if ( Active.Exists() )then
178 Warnlog( "Unexpected messagebox: " & Active.GetText() )
179 Warnlog( "Affected file..: " & GraphicFile )
180 Warnlog( "Affected filter: " & Filtername )
189 Warnlog( "Problems with filtertype : " & Filtername )
194 warnlog( "Insert Graphics Dialog is not open. Aborting" )
200 Kontext "GrafikEinfuegenDlg"
201 if GrafikEinfuegenDlg.Exists then
202 GrafikEinfuegenDlg.Cancel
209 '*******************************************************************************
211 testcase tInFilterCountCompare()
213 '///<h1>Verify presence of all known graphic filters</h1>
214 '///<i>Plain text description</i><br><br>
216 if ( gUseSysDlg ) then
217 warnlog( "This test needs the OpenOffice.org filepicker to be set as default" )
221 const FILE_NAME = "graphic_filters.txt"
222 const SUFFIX_STRING_LENGTH = 178
224 ' List of filter suffixes for verification in case of error
225 ' *.bmp;*.dxf;*.emf;*.eps;*.gif;*.jpg;*.jpeg;*.jfif;*.jif;*.met;*.pbm;*.pcd;
226 ' *.pct;*.pcx;*.pgm;*.png;*.ppm;*.psd;*.ras;*.sgf;*.sgv;*.svm;*.tga;*.tif;
227 ' *.tiff;*.wmf;*.xbm;*.xpm;*.pict
229 dim caUIFilters( 30 ) as string
231 dim cReferencePath as string
232 cReferencePath = gTesttoolPath & "global/input/filters/"
233 cReferencePath = convertpath ( cReferencePath & FILE_NAME )
235 dim cUIFiltersPath as string
236 cUIFiltersPath = hGetWorkPath() & FILE_NAME
238 dim iCurrentFilter as integer
239 dim iFilterCount as integer
241 dim cAllFormats as string
244 dim iBegin as integer
247 '///<u>Description:</u>
249 printlog( "Verify filternames listed on the Insert Graphics dialog" )
252 '///+<li>Open a new document, change it</li>
256 '///+<li>Open the graphics import dialog</li>
257 InsertGraphicsFromFile
259 '///+<li>Get the number of filters from the list</li>
260 kontext "GrafikEinfuegenDlg"
261 iFilterCount = DateiTyp.getItemCount()
263 'Make list compatible with listfunctions
264 caUIFilters( 0 ) = iFilterCount - 1
266 '///+<li>Part 1: Retrieve the names of the filters, ignore the first entry (all formats)</li>
267 for iCurrentFilter = 2 to iFilterCount
269 caUIFilters( iCurrentFilter - 1 ) = DateiTyp.getItemText( iCurrentFilter )
273 '///+<li>Compare the list against the reference</li>
274 irc = hManageComparisionList( cReferencePath, cUIFiltersPath, caUIFilters() )
276 warnlog( "The list of graphic format filters has changed" )
279 '///+<li>Part 2: Verify the <All formats> string</li>
281 printlog( "Verify <All formats>-string" )
282 cAllFormats = DateiTyp.getItemText( 1 )
284 '///+<li>Test opening bracket (<) (this is first character in string)</li>
285 iBegin = instr( cAllFormats, "<" )
286 if ( iBegin <> 1 ) then
287 warnlog( "The opening bracket < is missing in <All formats> string" )
290 '///+<li>Test closing bracket (>)</li>
291 iEnd = instr( cAllFormats, ">" )
293 warnlog( "The closing bracket > is missing in <All formats> string" )
296 '///+<li>Verify that <All formats> string has sane length</li>
297 if ( ( iEnd - iBegin ) < 2 ) then
298 warnlog( "<All formats> string is shorter than expected, please check" )
299 printlog( "String is: " & cAllFormats & ", length (" & len( cAllFormats ) & ")" )
302 '///+<li>Test opening bracket (, it is separated by one blank from ></li>
303 iBegin = instr( cAllFormats, "(" )
304 if ( iBegin <> iEnd + 2 ) then
305 warnlog( "The opening bracket ( is missing in <All formats> string" )
308 '///+<li>Test closing bracket )</li>
309 iEnd = instr( cAllFormats, ")" )
310 if ( iEnd < 10 ) then
311 warnlog( "The closing bracket ) is missing in <All formats> string" )
314 '///+<li>Verify that the list of filter-suffixes has sane length</li>
316 if ( irc <> SUFFIX_STRING_LENGTH ) then
317 warnlog( "The list of file suffixes has changed, please verify" )
318 printlog( "Found: " & irc & " chars, expected " & SUFFIX_STRING_LENGTH )
321 '///+<li>Close the dialog</li>
322 kontext "GrafikEinfuegenDlg"
323 GrafikEinfuegenDlg.cancel()
325 '///+<li>Close the document</li>