Skip to content

Commit 3917726

Browse files
author
lukec
committedOct 31, 2006
Finish unit tests for deprecated functions
git-svn-id: http://svn.openqa.org/svn/selenium-rc/trunk/clients/perl-cpan@1582 0891141a-5dea-0310-ad27-ebc607f31677
1 parent 2cf7744 commit 3917726

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed
 

‎t/WWW/Selenium.pm

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ sub new {
2929

3030
sub _set_mock_response_content {
3131
my ($self, $content) = @_;
32-
$self->{__ua}{res} = HTTP::Response->new(content => join(',', 'OK', $content));
32+
my $msg = $content;
33+
if (length($msg) == 0 or $msg !~ /^ERROR/) {
34+
$msg = "OK,$msg";
35+
}
36+
$self->{__ua}{res} = HTTP::Response->new(content => $msg);
3337
}
3438

3539
sub _method_exists {

‎t/selenium-compat.t

+49-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/perl
22
use strict;
33
use warnings;
4-
use Test::More qw/no_plan/;
5-
use t::Utils qw/method_exists/;
4+
use Test::More tests => 20;
65
use Test::Exception;
76

87
# The purpose of these tests are to ensure that WWW::Selenium does not
@@ -39,14 +38,57 @@ Is_location: {
3938
}
4039

4140
Get_checked: {
42-
# XXX - Not sure what SeleniumServer actually returns here.
4341
True: {
44-
$sel->_set_mock_response_content('checked');
45-
is $sel->get_checked('id=foo'), 'checked';
42+
$sel->_set_mock_response_content('true');
43+
is $sel->get_checked('id=foo'), 'true';
44+
}
45+
46+
False: {
47+
$sel->_set_mock_response_content('false');
48+
is $sel->get_checked('id=foo'), 'false';
49+
}
50+
51+
Element_does_not_exist: {
52+
my $error_msg = "Element id=foo not found";
53+
$sel->_set_mock_response_content("ERROR: $error_msg");
54+
throws_ok { $sel->get_checked('id=foo') }
55+
qr/\Q$error_msg\E/;
56+
}
57+
}
58+
59+
Is_selected: {
60+
True: {
61+
$sel->_set_mock_response_content('true');
62+
ok $sel->is_selected('id=foo');
4663
}
4764

4865
False: {
49-
$sel->_set_mock_response_content('unchecked');
50-
is $sel->get_checked('id=foo'), 'unchecked';
66+
$sel->_set_mock_response_content('false');
67+
ok !$sel->is_selected('id=foo');
68+
}
69+
70+
Element_does_not_exist: {
71+
my $error_msg = "Element id=foo not found";
72+
$sel->_set_mock_response_content("ERROR: $error_msg");
73+
throws_ok { $sel->is_selected('id=foo') }
74+
qr/\Q$error_msg\E/;
75+
}
76+
}
77+
78+
Get_selected_options: {
79+
None_selected: {
80+
$sel->_set_mock_response_content('');
81+
is_deeply [$sel->get_selected_options('id=foo')], [''];
82+
}
83+
84+
One_selected: {
85+
$sel->_set_mock_response_content('first response');
86+
is_deeply [$sel->get_selected_options('id=foo')], ['first response'];
87+
}
88+
89+
Two_selected: {
90+
$sel->_set_mock_response_content('first response,second');
91+
is_deeply [$sel->get_selected_options('id=foo')],
92+
['first response', 'second'];
5193
}
5294
}

0 commit comments

Comments
 (0)
Please sign in to comment.