line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
128678
|
use Renard::Incunabula::Common::Setup; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
14
|
|
2
|
|
|
|
|
|
|
package Renard::Incunabula::Devel::TestHelper; |
3
|
|
|
|
|
|
|
# ABSTRACT: A test helper with functions useful for various Renard distributions |
4
|
|
|
|
|
|
|
$Renard::Incunabula::Devel::TestHelper::VERSION = '0.003'; |
5
|
1
|
|
|
1
|
|
1081
|
use Renard::Incunabula::Common::Types qw(CodeRef InstanceOf Maybe PositiveInt DocumentModel Dir Tuple); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
0
|
|
|
|
|
|
classmethod test_data_directory() :ReturnType(Dir) { |
|
0
|
|
|
|
|
|
|
8
|
0
|
|
|
|
|
|
require Path::Tiny; |
9
|
0
|
|
|
|
|
|
Path::Tiny->import(); |
10
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
if( not defined $ENV{RENARD_TEST_DATA_PATH} ) { |
12
|
0
|
|
|
|
|
|
die "Must set environment variable RENARD_TEST_DATA_PATH to the path for the test-data repository"; |
13
|
|
|
|
|
|
|
} |
14
|
0
|
|
|
|
|
|
return path( $ENV{RENARD_TEST_DATA_PATH} ); |
15
|
1
|
|
|
1
|
|
3210
|
} |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
15
|
|
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
0
|
1
|
|
classmethod create_cairo_document( :$repeat = 1, :$width = 5000, :$height = 5000 ) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
require Renard::Incunabula::Format::Cairo::ImageSurface::Document; |
19
|
0
|
|
|
|
|
|
require Cairo; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $colors = [ |
22
|
|
|
|
|
|
|
( |
23
|
|
|
|
|
|
|
[ 1, 0, 0 ], |
24
|
|
|
|
|
|
|
[ 0, 1, 0 ], |
25
|
|
|
|
|
|
|
[ 0, 0, 1 ], |
26
|
|
|
|
|
|
|
[ 0, 0, 0 ], |
27
|
|
|
|
|
|
|
) x ( $repeat ) |
28
|
|
|
|
|
|
|
]; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my @surfaces = map { |
31
|
0
|
|
|
|
|
|
my $surface = Cairo::ImageSurface->create( |
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
'rgb24', $width, $height |
33
|
|
|
|
|
|
|
); |
34
|
0
|
|
|
|
|
|
my $cr = Cairo::Context->create( $surface ); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $rgb = $_; |
37
|
0
|
|
|
|
|
|
$cr->set_source_rgb( @$rgb ); |
38
|
0
|
|
|
|
|
|
$cr->rectangle(0, 0, $width, $height); |
39
|
0
|
|
|
|
|
|
$cr->fill; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$surface; |
42
|
|
|
|
|
|
|
} @$colors; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $cairo_doc = Renard::Incunabula::Format::Cairo::ImageSurface::Document->new( |
45
|
|
|
|
|
|
|
image_surfaces => \@surfaces, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Renard::Incunabula::Devel::TestHelper - A test helper with functions useful for various Renard distributions |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.003 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 FUNCTIONS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 test_data_directory |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Renard::Incunabula::Devel::TestHelper->test_data_directory |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns a L<Path::Class> object that points to the path defined by |
72
|
|
|
|
|
|
|
the environment variable C<RENARD_TEST_DATA_PATH>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
If the environment variable is not defined, throws an error. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 create_cairo_document |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Renard::Incunabula::Devel::TestHelper->create_cairo_document |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns a L<Renard::Incunabula::Format::Cairo::ImageSurface::Document> which can be |
81
|
|
|
|
|
|
|
used for testing. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The pages have the colors: |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
* red |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
* green |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
* blue |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
* black |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Project Renard |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Project Renard. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |