line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Images::Test; |
2
|
8
|
|
|
8
|
|
2509846
|
use Mojo::Base -base; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
59
|
|
3
|
8
|
|
|
8
|
|
1358
|
use 5.20.0; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
390
|
|
4
|
8
|
|
|
8
|
|
4154
|
use experimental 'signatures'; |
|
8
|
|
|
|
|
5893
|
|
|
8
|
|
|
|
|
43
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
1043
|
use Exporter 'import'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
246
|
|
7
|
8
|
|
|
8
|
|
7551
|
use Imager; |
|
8
|
|
|
|
|
255538
|
|
|
8
|
|
|
|
|
61
|
|
8
|
8
|
|
|
8
|
|
1420
|
use Mojo::Asset::Memory; |
|
8
|
|
|
|
|
83032
|
|
|
8
|
|
|
|
|
97
|
|
9
|
8
|
|
|
8
|
|
1086
|
use Mojo::Upload; |
|
8
|
|
|
|
|
5664
|
|
|
8
|
|
|
|
|
67
|
|
10
|
8
|
|
|
8
|
|
208
|
use Mojo::Util 'steady_time'; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
449
|
|
11
|
8
|
|
|
8
|
|
1156
|
use Mojo::UserAgent; |
|
8
|
|
|
|
|
202214
|
|
|
8
|
|
|
|
|
71
|
|
12
|
8
|
|
|
8
|
|
898
|
use Mojolicious::Controller; |
|
8
|
|
|
|
|
107101
|
|
|
8
|
|
|
|
|
51
|
|
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
|
6397
|
sub test_image($x = 1024, $y = 800) { |
|
19
|
100
|
|
|
|
62
|
|
|
19
|
100
|
|
|
|
54
|
|
|
19
|
|
|
|
|
30
|
|
19
|
19
|
|
|
|
|
151
|
my $blue = Imager::Color->new(0, 0, 255); |
20
|
19
|
|
|
|
|
643
|
my $gray = Imager::Color->new(125, 125, 125); |
21
|
|
|
|
|
|
|
|
22
|
19
|
|
|
|
|
284
|
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
|
14831
|
sub test_upload($x = 1024, $y = 800) { |
|
11
|
100
|
|
|
|
46
|
|
|
11
|
100
|
|
|
|
36
|
|
|
11
|
|
|
|
|
13
|
|
31
|
11
|
|
|
|
|
41
|
test_image($x, $y)->write(data => \my $data, type => 'jpeg'); |
32
|
11
|
|
|
|
|
60292
|
my $asset = Mojo::Asset::Memory->new->add_chunk($data); |
33
|
11
|
|
|
|
|
1546
|
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
|
16201
|
my $id = steady_time . rand; |
45
|
5
|
|
|
|
|
159
|
$id =~ s/\./-/g; |
46
|
5
|
|
|
|
|
15
|
$id; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |