diff options
Diffstat (limited to 'testautomation/graphics/optional/includes/global/export_graphic.inc')
-rw-r--r-- | testautomation/graphics/optional/includes/global/export_graphic.inc | 764 |
1 files changed, 357 insertions, 407 deletions
diff --git a/testautomation/graphics/optional/includes/global/export_graphic.inc b/testautomation/graphics/optional/includes/global/export_graphic.inc index 7c16129e41ae..e1d1479f5ee1 100644 --- a/testautomation/graphics/optional/includes/global/export_graphic.inc +++ b/testautomation/graphics/optional/includes/global/export_graphic.inc @@ -27,106 +27,81 @@ '* '* Owner : wolfram.garten@sun.com '* -'* short description : Graphics Export A-tests. (More durable ones) -'* -'******************************************************************************* -'* -' #1 tEPS -' #1 tGIF -' #1 tJPEG -' #1 tPBM -' #1 tPCT -' #1 tPGM -' #1 tPPM -' #1 tRAS -' #1 tTIFF -' #1 tXPM +'* short description : Graphics Export A-tests '* '\****************************************************************************** + testcase tEPS dim x as integer dim i as integer - dim sFilter as string - dim sExt as string - sFilter = "EPS - Encapsulated PostScript (.eps)" - sExt = ".eps" + const sFilter = "EPS - Encapsulated PostScript (.eps)" + const sExt = ".eps" printlog "open the document" - hFileOpen ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then + if ( hCallExport ( OutputGrafikTBO , sFilter ) ) then Kontext "EPSOptionen" - if EPSOptionen.Exists (2) then + if ( EPSOptionen.Exists( 2 ) ) then printlog "check if all properties have the right count, and depend on each other" ' they do not affect annything, i can check (TBO) ' VorschauTIF.Check ' InterchangeEPSI.Check Level1.Check if Farbe.IsEnabled then warnlog " :-(" - if Graustufen.IsEnabled then warnlog " :-(" - if LZWKodierung.IsEnabled then warnlog " :-(" - if Keine.IsEnabled then warnlog " :-(" - ' if (TextEinstellungen.IsEnabled <> TRUE) then warnlog " :-(" - Level2.Check - if (Farbe.IsEnabled <> TRUE) then warnlog " :-(" - if (Graustufen.IsEnabled <> TRUE) then warnlog " :-(" - if (LZWKodierung.IsEnabled <> TRUE) then warnlog " :-(" - if (Keine.IsEnabled <> TRUE) then warnlog " :-(" - ' if (TextEinstellungen.IsEnabled <> TRUE) then warnlog " :-(" - printlog "'Color Resolution' listbox contains eight items" - ' x = TextEinstellungen.GetItemCount - ' if x <> 2 then warnlog "'TextEinstellungen' Count is wrong; should:2, is:" + x - ' for i = 1 to x - ' TextEinstellungen.Select i - ' sleep 1 - ' Printlog " - " + i + ": '" +TextEinstellungen.GetSelText + "'" - ' next i - printlog "leave dialog with cancel -> there has to be no file created!" - EPSOptionen.Cancel - sleep 5 - if ( dir(OutputGrafikTBO+sExt) = "") then ' inspired by bug #99932 Graphic is exported though cancel is pressed - Printlog "Ok :-)" - else - warnlog "Dialog was canceled, but file got saved, too :-( - i35177" - endif - else - Warnlog "No '" + sFilter + "'-Option-Dialog!" - i=5 - end if - sleep 2 - Kontext "Active" - if Active.Exists(2) then - Warnlog "'" + sFilter + "' has a problem" - Active.OK - end if - end if - printlog " now save it realy and load the file afterwards" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then - Kontext "EPSOptionen" - if EPSOptionen.Exists (2) then - printlog "TextEinstellungen.select 2" - EPSOptionen.OK - sleep 5 - endif - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" - else - warnlog "File didn't get saved :-(" - endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - if ( lcase( gPlatform ) <> "osx" ) then - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) - else - qaErrorLog "#i100253# crash on MacOS X 10.4" + if Graustufen.IsEnabled then warnlog " :-(" + if LZWKodierung.IsEnabled then warnlog " :-(" + if Keine.IsEnabled then warnlog " :-(" + ' if (TextEinstellungen.IsEnabled <> TRUE) then warnlog " :-(" + Level2.Check + if (Farbe.IsEnabled <> TRUE) then warnlog " :-(" + if (Graustufen.IsEnabled <> TRUE) then warnlog " :-(" + if (LZWKodierung.IsEnabled <> TRUE) then warnlog " :-(" + if (Keine.IsEnabled <> TRUE) then warnlog " :-(" + ' if (TextEinstellungen.IsEnabled <> TRUE) then warnlog " :-(" + printlog "'Color Resolution' listbox contains eight items" + ' x = TextEinstellungen.GetItemCount + ' if x <> 2 then warnlog "'TextEinstellungen' Count is wrong; should:2, is:" + x + ' for i = 1 to x + ' TextEinstellungen.Select i + ' sleep 1 + ' Printlog " - " + i + ": '" +TextEinstellungen.GetSelText + "'" + ' next i + printlog "leave dialog with cancel -> there has to be no file created!" + hCloseDialog( EPSOptionen, "cancel" ) + + if ( FileExists( OutputGrafikTBO+sExt ) ) then ' inspired by bug #99932 Graphic is exported though cancel is pressed + warnlog "Dialog was canceled, but file got saved, too :-( - i35177" + endif + else + warnlog( "No export options dialog was displayed" ) + end if + + Kontext "Active" + if Active.Exists(2) then + Warnlog "'" + sFilter + "' has a problem" + Active.OK + end if + end if + + printlog( "Save the file" ) + if ( hCallExport( OutputGrafikTBO, sFilter ) ) then + + Kontext "EPSOptionen" + if ( EPSOptionen.Exists( 2 ) ) then + printlog "TextEinstellungen.select 2" + hCloseDialog( EPSOptionen, "ok" ) + else + warnlog( "No export options dialog was displayed" ) + endif + + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file endif - endif - call hCloseDocument + call hCloseDocument endcase 'tEPS '------------------------------------------------------------------------- @@ -135,8 +110,6 @@ testcase tPCT dim x as integer dim i as integer dim iWaitIndex as integer - dim sFilter as string - dim sExt as string dim bTemp as boolean dim sX as string dim sY as string @@ -144,224 +117,205 @@ testcase tPCT dim sX2 as string dim sY2 as string dim sDocument as string + dim sOutputFile as string + + const FILE_WRITE_TIMEOUT = 200 ' seconds - sFilter = "PCT - Mac Pict (.pct;.pict)" - sExt = ".pct" + const sFilter = "PCT - Mac Pict (.pct;.pict)" + const sExt = ".pct" printlog "open the document" - sDocument = ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString) - hFileOpen sDocument + sDocument = convertpath( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) + hFileOpen( sDocument ) + + if ( hCallExport( OutputGrafikTBO , sFilter ) ) then - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then Kontext "PICTOptionen" - if PICTOptionen.Exists (2) then + printlog( "Export options dialog" ) + if ( PICTOptionen.Exists( 2 ) ) then + printlog "check if all properties have the right count, and depend on each other" Original.Check if Breite.IsEnabled then warnlog " :-(" - if Hoehe.IsEnabled then warnlog " :-(" - Groesse.Check - Breite.More - Hoehe.Less - printlog "leave dialog with cancel -> there has to be no file created!" - PICTOptionen.Cancel - sleep 5 - if ( dir(OutputGrafikTBO+sExt) = "") then - Printlog "Ok :-)" - else - warnlog "Dialog was canceled, but file got saved, too :-( - i35177" - endif - else - Warnlog "No '" + sFilter + "' -Dialog!" - i=5 - end if - sleep 2 - Kontext "Active" - if Active.Exists(2) then - Warnlog " '" + sFilter + "' has a problem" - Active.OK - end if - end if - printlog " now save it realy and load the file afterwards" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then - Kontext "PICTOptionen" - if PICTOptionen.Exists (2) then - Groesse.Check - Breite.Less - Hoehe.More - PICTOptionen.OK - iWaitIndex = 0 - do while PICTOptionen.Exists AND iWaitIndex < 30 - sleep (1) - iWaitIndex = iWaitIndex + 1 - loop - endif - i=0 - while ((NOT fileExists(OutputGrafikTBO+sExt)) AND (i<36)) - inc(i) - sleep(5) - wend - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" - else - warnlog "File didn't get saved :-(" - endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) - endif - hCloseDocument () - printlog " now save a SELECTION in ORIGINAL SIZE and load the file afterwards" - hFileOpen (sDocument) - sleep (10) - - printlog "check if the document is writable" - if fIsDocumentWritable = false then - printlog "make the document writable and check if it's succesfull" - if fMakeDocumentWritable = false then - warnlog "The document can't be make writeable. Test stopped." - goto endsub - endif + if Hoehe.IsEnabled then warnlog " :-(" + Groesse.Check + Breite.More + Hoehe.Less + + printlog "leave dialog with cancel -> there has to be no file created!" + hCloseDialog( PICTOptionen, "cancel" ) + + if ( FileExists( OutputGrafikTBO + sExt ) ) then + warnlog( "#i35177# - dialog <PictOptions> canceled, still the file was saved" ) endif + else + warnlog( "No export options dialog was displayed" ) + end if + + Kontext "Active" + if Active.Exists(2) then + Warnlog " '" + sFilter + "' has a problem" + Active.OK + end if - hTypeKeys ("<escape><tab>") - fGetSizeXY sx1, sY, TRUE - if hCallExport (OutputGrafikTBO + "1" , sFilter, TRUE ) = TRUE then - Kontext "PICTOptionen" - if PICTOptionen.Exists (2) then - Original.Check - PICTOptionen.OK - iWaitIndex = 0 - do while PICTOptionen.Exists AND iWaitIndex < 30 - sleep (1) - iWaitIndex = iWaitIndex + 1 - loop - endif - i=0 - while ((NOT fileExists(OutputGrafikTBO+ "1"+sExt)) AND (i<36)) - inc(i) - sleep(5) - wend - if ( dir(OutputGrafikTBO + "1"+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO + "1"+sExt + "'" + end if + + printlog " now save it realy and load the file afterwards" + if ( hCallExport( OutputGrafikTBO, sFilter ) ) then + + Kontext "PICTOptionen" + printlog( "Export options dialog" ) + if ( PICTOptionen.Exists( 2 ) ) then + Groesse.Check + Breite.Less + Hoehe.More + hCloseDialog( PICTOptionen, "ok" ) + else + warnlog( "No export options dialog was displayed" ) + endif + + sOutputFile = OutputGrafikTBO+sExt + + if ( hWaitForOutputFile( sOutputFile ) ) then + + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( sOutputFile ) ' local helper function, see bottom of this file + else + warnlog( "File was not saved: " & sOutputFile ) + endif + + endif + + hFileReOpen( sDocument ) + + printlog "check if the document is writable" + if ( not fIsDocumentWritable ) then + printlog( "Document is write protected, changing state" ) + if ( not fMakeDocumentWritable ) then + warnlog "The document can't be make writeable. Test stopped." + goto endsub + endif + endif + + hTypeKeys ("<escape><tab>") + fGetSizeXY sx1, sY, TRUE + + if ( hCallExport( OutputGrafikTBO + "1", sFilter, TRUE ) ) then + + Kontext "PICTOptionen" + printlog( "Export options dialog" ) + if ( PICTOptionen.Exists( 2 ) ) then + Original.Check + hCloseDialog( PICTOptionen, "ok" ) + else + warnlog( "No export options dialog was displayed" ) + endif + + sOutputFile = OutputGrafikTBO + "1" + sExt + if ( hWaitForOutputFile( sOutputFile ) ) then + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( sOutputFile ) ' local helper function, see bottom of this file + else + warnlog( "File was not saved: " & sOutputFile ) + endif + + bTemp = fGetSizeXY( sx1, sY, bTemp ) + if (bTemp = FALSE) then + warnlog "Selected original size NOT OK :-(" + endif + endif + + hFileReOpen( "" ) + hRechteckErstellen ( 10, 10, 30, 40 ) + + if ( hCallExport( OutputGrafikTBO + "2" , sFilter, TRUE ) ) then + + Kontext "PICTOptionen" + printlog( "Export options dialog" ) + if ( PICTOptionen.Exists( 2 ) ) then + Groesse.Check + Breite.SetText "9" + Hoehe.SetText "9" + Groesse.Check + + printlog "Check 'Size' one more time to make the change go through" + sx1 = Breite.GetText + sY = Hoehe.GetText + hCloseDialog( PICTOptionen, "ok" ) + else + warnlog( "No export options dialog was displayed" ) + endif + + sOutputFile = OutputGrafikTBO + "2" + sExt + + if ( not hWaitForOutputFile( sOutputFile ) ) then + warnlog( "File was not saved: " & sOutputFile ) + endif + + printlog( "Reload file if it exists. Warn if not" ) + hFileReOpen( sOutputFile ) + + kontext "DocumentDraw" + DocumentDraw.TypeKeys ("<escape><tab>") + ContextOriginalSize + bTemp = fGetSizeXY( sx1, sY, bTemp ) + if ( not bTemp ) then warnlog "Selected original size NOT OK :-(" + endif + + if ( hCallExport( OutputGrafikTBO + "3", sFilter, TRUE ) ) then + + Kontext "PICTOptionen" + printlog( "Export options dialog" ) + if ( PICTOptionen.Exists( 2 ) ) then + Groesse.Check + sX2 = Breite.GetText + if (LiberalMeasurement(sx1, sX2)) <> TRUE then + if (val(str(StrToDouble(sx1)+5)) >= StrToDouble(sX2) ) AND (val(str(StrToDouble ( sx1 )-5)) <= StrToDouble ( sX2 )) then + Printlog "Width was ok. Expected: " + sx1 + "' was: '" + sX2 + "'" else - warnlog "File didn't get saved :-(" - endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO + "1"+sExt ) - bTemp = FALSE - fGetSizeXY sx1, sY, bTemp - if (bTemp = FALSE) then - warnlog "Selected original size NOT OK :-(" + warnLog "Width is different expected: '" + sx1 + "' is: '" + sX2 + "'" endif endif - hCloseDocument () - printlog " now CREATE a rectangle, select it, save it in SIZE and load the file afterwards" - hNewDocument() - hRechteckErstellen ( 10, 10, 30, 40 ) - if hCallExport (OutputGrafikTBO + "2" , sFilter, TRUE ) = TRUE then - Kontext "PICTOptionen" - if PICTOptionen.Exists (2) then - Groesse.Check - Breite.SetText "9" - Hoehe.SetText "9" - Groesse.Check - printlog "Check 'Size' one more time to make the change go through" - sx1 = Breite.GetText - sY = Hoehe.GetText - PICTOptionen.OK - iWaitIndex = 0 - do while PICTOptionen.Exists AND iWaitIndex < 30 - sleep (1) - iWaitIndex = iWaitIndex + 1 - loop - endif - i=0 - while ((NOT fileExists(OutputGrafikTBO+ "2"+sExt)) AND (i<36)) - inc(i) - sleep(5) - wend - if ( dir(OutputGrafikTBO + "2"+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO + "2"+sExt + "'" + sY2 = Hoehe.GetText + if (LiberalMeasurement(sY, sY2)) <> TRUE then + if ( val(str(StrToDouble(sY)+5)) >= StrToDouble(sY2) ) AND (val(str(StrToDouble ( sY )-5)) <= StrToDouble ( sY2 )) then + Printlog "Height was ok. Expected: " + sY + "' was: '" + sY2 + "'" else - warnlog "File didn't get saved :-(" - endif - hCloseDocument () - sleep 5 - hFileOpen (OutputGrafikTBO + "2"+sExt) - kontext "DocumentDraw" - DocumentDraw.TypeKeys ("<escape><tab>") - ContextOriginalSize - bTemp = FALSE - fGetSizeXY sx1, sY, bTemp - if (bTemp = FALSE) then - warnlog "Selected original size NOT OK :-(" - endif - endif - if hCallExport (OutputGrafikTBO + "3" , sFilter, TRUE ) = TRUE then - Kontext "PICTOptionen" - if PICTOptionen.Exists (2) then - Groesse.Check - sX2 = Breite.GetText - if (LiberalMeasurement(sx1, sX2)) <> TRUE then - if (val(str(StrToDouble(sx1)+5)) >= StrToDouble(sX2) ) AND (val(str(StrToDouble ( sx1 )-5)) <= StrToDouble ( sX2 )) then - Printlog "Width was ok. Expected: " + sx1 + "' was: '" + sX2 + "'" - else - warnLog "Width is different expected: '" + sx1 + "' is: '" + sX2 + "'" - endif - endif - sY2 = Hoehe.GetText - if (LiberalMeasurement(sY, sY2)) <> TRUE then - if ( val(str(StrToDouble(sY)+5)) >= StrToDouble(sY2) ) AND (val(str(StrToDouble ( sY )-5)) <= StrToDouble ( sY2 )) then - Printlog "Height was ok. Expected: " + sY + "' was: '" + sY2 + "'" - else - warnLog "Height is different expected: '" + sY + "' is: '" + sY2 + "'" - endif - endif - PICTOptionen.Cancel - sleep 5 + warnLog "Height is different expected: '" + sY + "' is: '" + sY2 + "'" endif endif + hCloseDialog( PICTOptionen, "cancel" ) + else + warnlog( "No export options dialog was displayed" ) + endif + endif - call hCloseDocument + call hCloseDocument endcase 'tPCT '------------------------------------------------------------------------------- testcase tPBM - dim x as integer - dim i as integer - dim sFilter as string - dim sExt as string - - sFilter = "PBM - Portable Bitmap (.pbm)" - sExt = ".pbm" + const sFilter = "PBM - Portable Bitmap (.pbm)" + const sExt = ".pbm" printlog "Open the document" - hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString )) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString ) printlog "Save it" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then + if ( hCallExport (OutputGrafikTBO , sFilter ) ) then + Kontext "PBMOptionen" - if PBMOptionen.Exists (2) then + if ( PBMOptionen.Exists( 2 ) ) then Ascii.Check - PBMOptionen.OK - sleep 5 - endif - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" + hCloseDialog( PBMOptionen, "ok" ) else - warnlog "File didn't get saved :-(" + warnlog( "No export options dialog was displayed" ) endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) + + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + endif call hCloseDocument @@ -370,35 +324,26 @@ endcase 'tPBM '------------------------------------------------------------------------------- testcase tPGM - dim x as integer - dim i as integer - dim sFilter as string - dim sExt as string - - sFilter = "PGM - Portable Graymap (.pgm)" - sExt = ".pgm" + const sFilter = "PGM - Portable Graymap (.pgm)" + const sExt = ".pgm" printlog "Open the document" - hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString )) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) printlog "Save it" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then + if ( hCallExport (OutputGrafikTBO , sFilter ) ) then + Kontext "PGMOptionen" - if PGMOptionen.Exists (2) then + if ( PGMOptionen.Exists( 2 ) ) then Ascii.Check - PGMOptionen.OK - sleep 5 - endif - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" + hCloseDialog( PGMOptionen, "ok" ) else - warnlog "File didn't get saved :-(" + warnlog( "No export options dialog was displayed" ) endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) + + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + endif call hCloseDocument @@ -407,35 +352,26 @@ endcase 'tPGM '------------------------------------------------------------------------------- testcase tPPM - dim x as integer - dim i as integer - dim sFilter as string - dim sExt as string - - sFilter = "PPM - Portable Pixelmap (.ppm)" - sExt = ".ppm" + const sFilter = "PPM - Portable Pixelmap (.ppm)" + const sExt = ".ppm" printlog "Open the document" - hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString )) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) printlog "Save it" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then + if ( hCallExport (OutputGrafikTBO , sFilter ) ) then + Kontext "PPMOptionen" - if PPMOptionen.Exists (2) then + if ( PPMOptionen.Exists( 2 ) ) then Ascii.Check - PPMOptionen.OK - sleep 5 - endif - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" + hCloseDialog( PPMOptionen, "ok" ) else - warnlog "File didn't get saved :-(" + warnlog( "No export options dialog was displayed" ) endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) + + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + endif call hCloseDocument @@ -444,29 +380,18 @@ endcase 'tPPM '------------------------------------------------------------------------------ testcase tRAS - dim x as integer - dim i as integer - dim sFilter as string - dim sExt as string - - sFilter = "RAS - Sun Raster Image (.ras)" - sExt = ".ras" + const sFilter = "RAS - Sun Raster Image (.ras)" + const sExt = ".ras" printlog "Open the document" - hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString )) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) printlog "Save it" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) - else - warnlog "File didn't get saved :-(" - endif + if ( hCallExport( OutputGrafikTBO, sFilter ) ) then + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + else + warnlog( "No export options dialog was displayed" ) endif call hCloseDocument @@ -477,27 +402,19 @@ testcase tTIFF dim x as integer dim i as integer - dim sFilter as string - dim sExt as string - sFilter = "TIFF - Tagged Image File Format (.tif;.tiff)" - sExt = ".tif" + const sFilter = "TIFF - Tagged Image File Format (.tif;.tiff)" + const sExt = ".tif" printlog "Open the document" hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString )) printlog "Save it" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) - else - warnlog "File didn't get saved :-(" - endif + if ( hCallExport (OutputGrafikTBO , sFilter ) ) then + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + else + warnlog( "No export options dialog was displayed" ) endif call hCloseDocument @@ -506,29 +423,18 @@ endcase 'tTIFF '------------------------------------------------------------------------------ testcase tXPM - dim x as integer - dim i as integer - dim sFilter as string - dim sExt as string - - sFilter = "XPM - X PixMap (.xpm)" - sExt = ".xpm" + const sFilter = "XPM - X PixMap (.xpm)" + const sExt = ".xpm" printlog "Open the document" - hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString )) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) printlog "save it" if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) - else - warnlog "File didn't get saved :-(" - endif + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + else + warnlog( "No export options dialog was displayed" ) endif call hCloseDocument @@ -537,36 +443,27 @@ endcase 'tXPM '------------------------------------------------------------------------------- testcase tGIF - dim x as integer - dim i as integer - dim sFilter as string - dim sExt as string - - sFilter = "GIF - Graphics Interchange Format (.gif)" - sExt = ".gif" + const sFilter = "GIF - Graphics Interchange Format (.gif)" + const sExt = ".gif" printlog "open the document" - hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) printlog "save it" - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then + if ( hCallExport( OutputGrafikTBO, sFilter ) ) then + Kontext "GIFOptionen" if GIFOptionen.Exists (2) then Interlace.Uncheck TransparentSpeichern.UnCheck - GIFOptionen.OK - sleep 5 - endif - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" + hCloseDialog( GIFOptionen, "ok" ) else - warnlog "File didn't get saved :-(" + warnlog( "No export options dialog was displayed" ) endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) + + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + endif call hCloseDocument @@ -575,39 +472,92 @@ endcase 'tGIF '------------------------------------------------------------------------------- testcase tJPEG - dim x as integer - dim i as integer - dim sFilter as string - dim sExt as string - - sFilter = "JPEG - Joint Photographic Experts Group (.jpg;.jpeg;.jfif;.jif;.jpe)" - sExt = ".jpg" + const sFilter = "JPEG - Joint Photographic Experts Group (.jpg;.jpeg;.jfif;.jif;.jpe)" + const sExt = ".jpg" printlog "Open the document" - hFileOpen (ConvertPath ( gTesttoolPath + "graphics\required\input\graphicexport."+ExtensionString) + hFileOpen( gTesttoolPath + "graphics\required\input\graphicexport." + ExtensionString ) printlog " save it " - if hCallExport (OutputGrafikTBO , sFilter ) = TRUE then + if ( hCallExport( OutputGrafikTBO , sFilter ) ) then + Kontext "JpegOptionen" - if JpegOptionen.Exists (2) then + if ( JpegOptionen.Exists( 2 ) ) then Echtfarben.Check Qualitaet.ToMin - JpegOptionen.OK - sleep 5 - endif - if ( dir(OutputGrafikTBO+sExt) <> "") then - Printlog "Ok :-) Saved as: '" + OutputGrafikTBO+sExt + "'" + hCloseDialog( JpegOptionen, "ok" ) else - warnlog "File didn't get saved :-(" + warnlog( "No export options dialog was displayed" ) endif - hCloseDocument () - sleep 5 - hNewDocument() - sleep 5 - Call hGrafikEinfuegen ( OutputGrafikTBO+sExt ) + + printlog( "Close file and re-insert graphics into new document" ) + hInsertGraphicsToNewFile( OutputGrafikTBO + sExt ) ' local helper function, see bottom of this file + endif call hCloseDocument endcase 'tJPEG -'------------------------------------------------------------------------- + +'******************************************************************************* + +function hInsertGraphicsToNewFile( sOutputFile as string ) + + if ( FileExists( sOutputFile ) ) then + hFileReOpen( "" ) + Call hGrafikEinfuegen( sOutputFile ) + else + warnlog( "File not saved: " & sOutputFile ) + endif + +end function + +'******************************************************************************* + +function hFileReOpen( cFile as string ) as boolean + + dim iDocumentCount as integer : iDocumentCount = getDocumentCount + hFileReopen() = false + + hCloseDocument() + + if ( cFile = "" ) then + hNewDocument() + else + if ( FileExists( cFile ) ) then + hFileOpen( cFile ) + else + warnlog( "hFileReOpen(): File does not exist: " & cFile ) + endif + endif + + if ( getDocumentCount = iDocumentCount ) then hFileReOpen() = true + +end function + +'******************************************************************************* + +function hWaitForOutputFile( sOutputFile as string ) as boolean + + const FILE_WRITE_TIMEOUT = 30 + dim iWait as integer : iWait = 0 + + for iWait = 1 to FILE_WRITE_TIMEOUT + + ' File found + if ( FileExists( sOutputFile ) ) then + hWaitForOutputFile() = true + exit function + endif + + ' Timeout + if ( iWait = FILE_WRITE_TIMEOUT ) then + hWaitForOutputFile() = false + exit function + endif + + wait( 1000 ) + + next iWait + +end function |