Experimental Image::BoxFind module:    Image/t/18-save_image_using_suffix.t


     # Test file created outside of h2xs framework.
# Run this like so: `perl Image-BoxFind.t'
#   doom@kzsu.stanford.edu     2007/10/22 04:50:12

use warnings;
use strict;
$|=1;
my $DEBUG = 0;
use Data::Dumper;

use Test::More;
BEGIN { plan tests => 3 };
use Test::Number::Delta;

use File::Basename qw( basename fileparse);
use File::Path     qw(mkpath);

use FindBin qw( $Bin );
use lib "$Bin/../..";
use lib "$Bin/lib";

my $image_dir = "$Bin/dat/images";
my $modified_dir = "$image_dir/output";

BEGIN { #1
  use_ok( 'Image::BoxFind' );
}
use Image::BoxFind::Testing::Eyeballs ':all';

#2
ok(1, "Traditional: If we made it this far, we're ok.");


my @image_files =
  (
   "$Bin/dat/images/simple_test_3.png",
#   "$Bin/dat/images/firefox_save_as.png",
#   "$Bin/dat/images/rhythmbox_prefs.png",
#   "$Bin/dat/images/gimp_open_dialog.png",
  );

# test cases are an array of three elements:
# 0: the test name
# 1: href of object attributes (not including image_file).

{
  my $test_name = "save_image_using_suffix";
  foreach my $image_file ( @image_files ) {
    my $basename = (  fileparse($image_file, qr{\.png} ) )[0];

    my $bf = Image::BoxFind->new( { image_file => $image_file,
                                    DEBUG       => $DEBUG,
                                  } );

    my $expected_file = "$basename-testorama.png";
    mkpath("$expected_file");
    my $expected_full = "$modified_dir/$expected_file";
    unlink( $expected_full ) if -e $expected_full;

    $bf->save_image_using_suffix('testorama');

    my $status = (-f "$expected_full");
    is( $status, 1, "Testing $test_name creation of output file: $expected_file");
  }
}

     

Joseph Brenner, Tue Nov 27 17:40:02 2007