App-MaMGal

 view release on metacpan or  search on metacpan

t/080_unit_picture.t  view on Meta::CPAN

#!/usr/bin/perl
# mamgal - a program for creating static image galleries
# Copyright 2007-2009 Marcin Owsiany <marcin@owsiany.pl>
# See the README file for license information
package App::MaMGal::Unit::Entry::Picture;
use strict;
use warnings;
use Carp qw(verbose confess);
use Test::More;
use Test::Exception;
use Test::Files;
use Test::HTML::Content;
use lib 'testlib';
use File::stat;
use Image::EXIF::DateTime::Parser;
use App::MaMGal::ImageInfoFactory;
use App::MaMGal::TestHelper;
BEGIN { our @ISA = 'App::MaMGal::Unit::Entry' }
BEGIN { do 't/050_unit_entry.t' }

sub pre_class_setting : Test(startup) {
	my $self = shift;
	$self->{tools} = {
		mplayer_wrapper => App::MaMGal::TestHelper->get_mock_mplayer_wrapper,
		formatter => App::MaMGal::TestHelper->get_mock_formatter('format_slide'),
		image_info_factory => App::MaMGal::ImageInfoFactory->new(Image::EXIF::DateTime::Parser->new, get_mock_logger),
	};
}

sub entry_tools_setup : Test(setup => 0) {
	my $self = shift;
	$self->{entry}->add_tools($self->{tools});
	$self->{entry_no_stat}->add_tools($self->{tools});
}

sub _touch
{
	my ($self, $infix, $time, $suffix) = @_;
	my $dir = $self->{test_file_name}->[0].'/'.$infix;
	my $name = $self->{test_file_name}->[1];
	$name .= $suffix || '';
	mkdir $dir or confess "Cannot mkdir [$dir]: $!";
	open(T, '>'.$dir.'/'.$name) or die "Cannot open: $!";
	print T 'whatever';
	close(T) or die "Cannot close: $!";
	utime $time, $time, $dir.'/'.$name or die "Cannot touch: $!";
}

sub miniature_path
{
	my $self = shift;
	my $component = shift;
	return $self->{test_file_name}->[0].'/'.$self->relative_miniature_path($component);
}

sub relative_miniature_path
{
	my $self = shift;
	my $component = shift;
	return $component.'/'.$self->{test_file_name}->[1];
}

sub slide_path
{
	my $self = shift;
	my $component = shift;
	return $self->{test_file_name}->[0].'/'.$self->relative_slide_path($component);
}

sub relative_slide_path
{
	my $self = shift;
	my $component = shift;
	return $component.'/'.$self->{test_file_name}->[1].'.html';
}

sub call_refresh_miniatures
{
	my $self = shift;
	my $infix = shift;
	my $suffix = shift;
	my $e = $self->{entry};
	$e->refresh_miniatures([$infix, 60, 60, $suffix]);
}

sub call_refresh_slide



( run in 2.196 seconds using v1.01-cache-2.11-cpan-5735350b133 )