line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Images::Test; |
2
|
8
|
|
|
8
|
|
2583343
|
use Mojo::Base -base; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
50
|
|
3
|
8
|
|
|
8
|
|
1083
|
use 5.20.0; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
279
|
|
4
|
8
|
|
|
8
|
|
3860
|
use experimental 'signatures'; |
|
8
|
|
|
|
|
5405
|
|
|
8
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
900
|
use Exporter 'import'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
231
|
|
7
|
8
|
|
|
8
|
|
6682
|
use Imager; |
|
8
|
|
|
|
|
222258
|
|
|
8
|
|
|
|
|
53
|
|
8
|
8
|
|
|
8
|
|
992
|
use Mojo::Asset::Memory; |
|
8
|
|
|
|
|
50979
|
|
|
8
|
|
|
|
|
81
|
|
9
|
8
|
|
|
8
|
|
666
|
use Mojo::Upload; |
|
8
|
|
|
|
|
3341
|
|
|
8
|
|
|
|
|
54
|
|
10
|
8
|
|
|
8
|
|
181
|
use Mojo::Util 'steady_time'; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
382
|
|
11
|
8
|
|
|
8
|
|
527
|
use Mojo::UserAgent; |
|
8
|
|
|
|
|
174446
|
|
|
8
|
|
|
|
|
77
|
|
12
|
8
|
|
|
8
|
|
996
|
use Mojolicious::Controller; |
|
8
|
|
|
|
|
97739
|
|
|
8
|
|
|
|
|
54
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = (qw(test_upload test_image test_controller uniq_id)); |
16
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@EXPORT_OK); |
17
|
|
|
|
|
|
|
|
18
|
19
|
50
|
|
19
|
1
|
4541
|
sub test_image($x = 1024, $y = 800) { |
|
19
|
100
|
|
|
|
57
|
|
|
19
|
100
|
|
|
|
50
|
|
|
19
|
|
|
|
|
16
|
|
19
|
19
|
|
|
|
|
115
|
my $blue = Imager::Color->new(0, 0, 255); |
20
|
19
|
|
|
|
|
567
|
my $gray = Imager::Color->new(125, 125, 125); |
21
|
|
|
|
|
|
|
|
22
|
19
|
|
|
|
|
246
|
Imager::->new(xsize => $x, ysize => $y)->box(filled => 1, color => $gray) |
23
|
|
|
|
|
|
|
->box( |
24
|
|
|
|
|
|
|
filled => 1, |
25
|
|
|
|
|
|
|
color => $blue, |
26
|
|
|
|
|
|
|
box => [int($x / 4), int($x / 4), int($x / 2), int($y / 2)] |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
11
|
50
|
|
11
|
1
|
14079
|
sub test_upload($x = 1024, $y = 800) { |
|
11
|
100
|
|
|
|
47
|
|
|
11
|
100
|
|
|
|
37
|
|
|
11
|
|
|
|
|
14
|
|
31
|
11
|
|
|
|
|
47
|
test_image($x, $y)->write(data => \my $data, type => 'jpeg'); |
32
|
11
|
|
|
|
|
59418
|
my $asset = Mojo::Asset::Memory->new->add_chunk($data); |
33
|
11
|
|
|
|
|
1367
|
my $upload = Mojo::Upload->new(asset => $asset); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
0
|
1
|
0
|
sub test_controller($x = 1024, $y = 800, $name = 'image') { |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
37
|
0
|
|
|
|
|
0
|
test_image($x, $y)->write(data => \my $data, type => 'jpeg'); |
38
|
0
|
|
|
|
|
0
|
my $tx = Mojo::UserAgent->new->build_tx( |
39
|
|
|
|
|
|
|
POST => '/' => form => {$name => {content => $data}}); |
40
|
0
|
|
|
|
|
0
|
Mojolicious::Controller->new->tx($tx); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub uniq_id { |
44
|
5
|
|
|
5
|
1
|
17038
|
my $id = steady_time . rand; |
45
|
5
|
|
|
|
|
156
|
$id =~ s/\./-/g; |
46
|
5
|
|
|
|
|
15
|
$id; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |