Commit | Line | Data |
676409e6 |
1 | use Test::Builder; |
2 | BEGIN { |
3 | package Test::Builder; |
4 | |
5 | use Class::Method::Modifiers; |
6 | use ExtUtils::MakeMaker qw(prompt); |
7 | |
8 | if (!$ENV{AUTOMATED_TESTING}) { |
9 | around ok => sub { |
10 | my ($orig, $self) = (shift, shift); |
11 | my $res = $self->$orig(@_); |
12 | unless ($res) { |
13 | if ('y' eq prompt "Well that didn't work, did it. Bail out?", 'y') { |
14 | exit 255; |
15 | } |
16 | } |
17 | return $res; |
18 | }; |
19 | } |
20 | } |
21 | |
22 | my $CAT_SERVER_PORT = 15000 + $<; |
23 | my $VNC_SERVER_PORT = 5900 + $<; |
24 | my $SEL_SERVER_PORT = 6900 + $<; |
25 | |
26 | sub gimme_table ($file) { |
27 | my $te = HTML::TableExtract->new; |
28 | $te->parse(do { local (@ARGV, $/) = ($file); <> }); |
29 | [ do { |
30 | my @r = map { |
31 | [ map { (!defined or $_ eq "\240") ? () : $_ } @$_ ] |
32 | } ($te->tables)[0]->rows; |
33 | shift @r; @r; |
34 | } |
35 | ] |
36 | } |
37 | |
38 | sub start_server ($port) { |
39 | my $server = Proc::Background->new( |
40 | { |
41 | die_upon_destroy => 1 |
42 | }, |
43 | 'script/app_server.pl', '-p', $port |
44 | ); |
45 | sleep 3; |
46 | $server; |
47 | } |
48 | |
49 | sub setup_selenium ($system, $port, $browser, $server_url) { |
50 | Socialtext::WikiFixture::Selenese->new( |
51 | selenium => do { my $s = Test::WWW::Selenium->new( |
52 | host => $system, |
53 | port => $port, |
54 | browser => $browser, |
55 | browser_url => $server_url, |
56 | ); $s->start; $s } |
57 | ); |
58 | } |
59 | |
60 | --- t/sel-local-lib/lib/perl5/Socialtext/WikiFixture/Selenese.pm 2007-06-21 18:28:37.000000000 -0400 |
61 | +++ t/sel-overrides/Socialtext/WikiFixture/Selenese.pm 2010-06-29 14:11:17.000000000 -0400 |
62 | @@ -128,7 +128,7 @@ |
63 | } |
64 | |
65 | # Try to guess _ok methods |
66 | - $command .= '_ok' if { map { $_ => 1 } qw(open type) }->{$command}; |
67 | + $command .= '_ok' if { map { $_ => 1 } qw(open type click) }->{$command}; |
68 | $self->$command($opt1, $opt2); |
69 | } |
70 | |
71 | @@ -149,6 +149,12 @@ |
72 | $command = lc($1) . '_like'; |
73 | } |
74 | |
75 | + # mst is guessing. |
76 | + |
77 | + if ($command =~ /^(?:assert|verify)_(\w+)$/) { |
78 | + $command = lc($1) . '_is'; |
79 | + } |
80 | + |
81 | return $command; |
82 | } |
83 | |
84 | @@ -200,6 +206,16 @@ |
85 | $sel->wait_for_page_to_load_ok($self->{selenium_timeout}, @args); |
86 | } |
87 | |
88 | +sub select_and_wait { |
89 | + my ($self, $opt1, $opt2) = @_; |
90 | + my $sel = $self->{selenium}; |
91 | + |
92 | + my @args; |
93 | + push @args, $opt2 if $opt2; |
94 | + $sel->select_ok($opt1, @args); |
95 | + $sel->wait_for_page_to_load_ok($self->{selenium_timeout}, @args); |
96 | +} |
97 | + |
98 | =head2 text_present_like() |
99 | |
100 | Search entire body for given text |
101 | |