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
|
#============================================================= -*-perl-*-
#
# t/image.t
#
# Tests the Image plugin.
#
# Written by Andy Wardley <abw@wardley.org>
#
# Copyright (C) 2002 Andy Wardley. All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id: image.t,v 1.3 2003/03/18 00:06:25 abw Exp $
#
#========================================================================
use strict;
use lib qw( ./lib ../lib );
use Template::Test;
use Cwd;
use File::Spec;
$^W = 1;
eval "use Image::Info";
if ($@) {
eval "use Image::Size";
skip_all('Neither Image::Info nor Image::Size installed') if $@;
}
my $dir = -d 't' ? 'images' : File::Spec->catfile(File::Spec->updir(), 'images');
my $vars = {
dir => $dir,
file => {
logo => File::Spec->catfile($dir, 'ttdotorg.gif'),
power => File::Spec->catfile($dir, 'tt2power.gif'),
},
};
test_expect(\*DATA, undef, $vars);
__DATA__
-- test --
[% USE Image(file.logo) -%]
file: [% Image.file %]
size: [% Image.size.join(', ') %]
width: [% Image.width %]
height: [% Image.height %]
-- expect --
-- process --
file: [% file.logo %]
size: 110, 60
width: 110
height: 60
-- test --
[% USE image( name = file.power) -%]
name: [% image.name %]
file: [% image.file %]
width: [% image.width %]
height: [% image.height %]
size: [% image.size.join(', ') %]
-- expect --
-- process --
name: [% file.power %]
file: [% file.power %]
width: 78
height: 47
size: 78, 47
-- test --
[% USE image file.logo -%]
attr: [% image.attr %]
-- expect --
attr: width="110" height="60"
-- test --
[% USE image file.logo -%]
tag: [% image.tag %]
tag: [% image.tag(class="myimage") %]
-- expect --
-- process --
tag: <img src="[% file.logo %]" width="110" height="60" />
tag: <img src="[% file.logo %]" width="110" height="60" class="myimage" />
|