line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Brownie; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
531
|
use 5.008001; |
|
19
|
|
|
|
|
67
|
|
|
19
|
|
|
|
|
715
|
|
4
|
19
|
|
|
19
|
|
106
|
use strict; |
|
19
|
|
|
|
|
49
|
|
|
19
|
|
|
|
|
743
|
|
5
|
19
|
|
|
19
|
|
217
|
use warnings; |
|
19
|
|
|
|
|
38
|
|
|
19
|
|
|
|
|
711
|
|
6
|
19
|
|
|
19
|
|
5561
|
use Brownie::Session; |
|
19
|
|
|
|
|
53
|
|
|
19
|
|
|
|
|
602
|
|
7
|
19
|
|
|
19
|
|
164
|
use Sub::Install; |
|
19
|
|
|
|
|
41
|
|
|
19
|
|
|
|
|
219
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %container; |
12
|
|
|
|
|
|
|
for my $accessor (qw{ |
13
|
|
|
|
|
|
|
driver |
14
|
|
|
|
|
|
|
app_host |
15
|
|
|
|
|
|
|
app |
16
|
|
|
|
|
|
|
}) { |
17
|
|
|
|
|
|
|
Sub::Install::install_sub({ |
18
|
|
|
|
|
|
|
code => sub { |
19
|
24
|
|
|
24
|
|
41
|
my ($class, $args) = @_; |
20
|
24
|
100
|
|
|
|
127
|
return $container{$accessor} unless @_ > 1; |
21
|
3
|
|
|
|
|
11
|
$container{$accessor} = $args; |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
as => $accessor, |
24
|
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %session; |
28
|
|
|
|
|
|
|
sub current_session { |
29
|
7
|
|
|
7
|
0
|
12
|
my $class = shift; |
30
|
|
|
|
|
|
|
# TODO: changable session |
31
|
7
|
|
33
|
|
|
51
|
$session{default} ||= Brownie::Session->new( |
32
|
|
|
|
|
|
|
app => Brownie->app, |
33
|
|
|
|
|
|
|
app_host => Brownie->app_host, |
34
|
|
|
|
|
|
|
driver => Brownie->driver, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub reset_sessions { |
39
|
26
|
|
|
26
|
0
|
83
|
my $class = shift; |
40
|
26
|
|
|
|
|
341
|
undef %session; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
19
|
|
|
19
|
|
81227
|
END { __PACKAGE__->reset_sessions } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Brownie - Browser integration framework inspired by Capybara |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 OO-Style |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use Test::More; |
56
|
|
|
|
|
|
|
use Brownie::Session; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# external server |
59
|
|
|
|
|
|
|
my $session = Brownie::Session->new( |
60
|
|
|
|
|
|
|
driver => 'Mechanize', |
61
|
|
|
|
|
|
|
app_host => 'http://app.example.com:5000', |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# PSGI app |
65
|
|
|
|
|
|
|
my $session = Brownie::Session->new( |
66
|
|
|
|
|
|
|
driver => 'Mechanize', |
67
|
|
|
|
|
|
|
app => sub { ...(PSGI app)... }, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# PSGI file |
71
|
|
|
|
|
|
|
my $session = Brownie::Session->new( |
72
|
|
|
|
|
|
|
driver => 'Mechanize', |
73
|
|
|
|
|
|
|
app => 'app.psgi', |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$session->visit('/'); |
77
|
|
|
|
|
|
|
is $session->title => 'Some Title'; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$session->fill_in('User Name' => 'brownie'); |
80
|
|
|
|
|
|
|
$session->fill_in('Email Address' => 'brownie@example.com'); |
81
|
|
|
|
|
|
|
$session->click_button('Login'); |
82
|
|
|
|
|
|
|
like $session->source => qr/Welcome (.+)/; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$session->fill_in(q => 'Brownie'); |
85
|
|
|
|
|
|
|
$session->click_link_or_button('Search'); |
86
|
|
|
|
|
|
|
like $session->title => qr/Search result of Brownie/i; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
done_testing; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 DSL-Style |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use Brownie::DSL; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# external server |
95
|
|
|
|
|
|
|
Brownie->driver('Mechanize'); |
96
|
|
|
|
|
|
|
Brownie->app_host('http://app.example.com:5000'); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# PSGI app |
99
|
|
|
|
|
|
|
Brownie->driver('Mechanize'); |
100
|
|
|
|
|
|
|
Brownie->app(sub { ...(PSGI app)... }); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# psgi file |
103
|
|
|
|
|
|
|
Brownie->driver('Mechanize'); |
104
|
|
|
|
|
|
|
Brownie->app('app.psgi'); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
visit('/'); |
107
|
|
|
|
|
|
|
is page->title, 'Some Title'; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
fill_in('User Name' => 'brownie'); |
110
|
|
|
|
|
|
|
fill_in('Email Address' => 'brownie@example.com'); |
111
|
|
|
|
|
|
|
click_button('Login'); |
112
|
|
|
|
|
|
|
like page->source => qr/Welcome (.+)/; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
fill_in(q => 'Brownie'); |
115
|
|
|
|
|
|
|
lick_link_or_button('Search'); |
116
|
|
|
|
|
|
|
like page->title => qr/Search result of Brownie/i; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
done_testing; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 DESCRIPTION |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Brownie is browser integrtion framework. It is inspired by Capybara (Ruby). |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 VOCABULARY |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * C |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * C |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * C |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * C |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * C |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * C |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * C |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * C |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * C |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * C |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * C |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * C |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * C |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * C |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * C |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * C |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * C |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * C |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * C |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * C |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 AUTHOR |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
NAKAGAWA Masaki Emasaki@cpan.orgE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 LICENSE |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
177
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 SEE ALSO |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |