line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Images::Test; |
2
|
8
|
|
|
8
|
|
2500667
|
use Mojo::Base -base; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
52
|
|
3
|
8
|
|
|
8
|
|
1160
|
use 5.20.0; |
|
8
|
|
|
|
|
26
|
|
|
8
|
|
|
|
|
302
|
|
4
|
8
|
|
|
8
|
|
3881
|
use experimental 'signatures'; |
|
8
|
|
|
|
|
5481
|
|
|
8
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
825
|
use Exporter 'import'; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
310
|
|
7
|
8
|
|
|
8
|
|
6416
|
use Imager; |
|
8
|
|
|
|
|
210584
|
|
|
8
|
|
|
|
|
58
|
|
8
|
8
|
|
|
8
|
|
1244
|
use Mojo::Asset::Memory; |
|
8
|
|
|
|
|
52105
|
|
|
8
|
|
|
|
|
87
|
|
9
|
8
|
|
|
8
|
|
600
|
use Mojo::Upload; |
|
8
|
|
|
|
|
3355
|
|
|
8
|
|
|
|
|
54
|
|
10
|
8
|
|
|
8
|
|
164
|
use Mojo::Util 'steady_time'; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
357
|
|
11
|
8
|
|
|
8
|
|
514
|
use Mojo::UserAgent; |
|
8
|
|
|
|
|
160511
|
|
|
8
|
|
|
|
|
69
|
|
12
|
8
|
|
|
8
|
|
822
|
use Mojolicious::Controller; |
|
8
|
|
|
|
|
88156
|
|
|
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
|
4283
|
sub test_image($x = 1024, $y = 800) { |
|
19
|
100
|
|
|
|
67
|
|
|
19
|
100
|
|
|
|
52
|
|
|
19
|
|
|
|
|
24
|
|
19
|
19
|
|
|
|
|
130
|
my $blue = Imager::Color->new(0, 0, 255); |
20
|
19
|
|
|
|
|
573
|
my $gray = Imager::Color->new(125, 125, 125); |
21
|
|
|
|
|
|
|
|
22
|
19
|
|
|
|
|
263
|
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
|
13503
|
sub test_upload($x = 1024, $y = 800) { |
|
11
|
100
|
|
|
|
46
|
|
|
11
|
100
|
|
|
|
38
|
|
|
11
|
|
|
|
|
19
|
|
31
|
11
|
|
|
|
|
40
|
test_image($x, $y)->write(data => \my $data, type => 'jpeg'); |
32
|
11
|
|
|
|
|
57367
|
my $asset = Mojo::Asset::Memory->new->add_chunk($data); |
33
|
11
|
|
|
|
|
1210
|
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
|
15291
|
my $id = steady_time . rand; |
45
|
5
|
|
|
|
|
147
|
$id =~ s/\./-/g; |
46
|
5
|
|
|
|
|
15
|
$id; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |