POE-XUL
view release on metacpan or search on metacpan
t/90_complete.t view on Meta::CPAN
my $text = Dumper $message;
ok( ( $text =~ /Clicked button #1/ ), "Clicked OK" );
############################################################
my $B2 = $browser->get_node( 'B2' );
ok( $B2, "Found the button" );
$resp = Click( $browser, $B2 );
$data = $browser->decode_resp( $resp, 'click B2' );
$browser->handle_resp( $data, 'click B2' );
$text = Dumper $message;
ok( ( $text =~ /Clicked button #2/ ), "Clicked OK" );
is( $B2->{label}, "Click #1", "Button updated" );
############################################################
my $TB1 = $browser->get_node( 'TB1' );
ok( $TB1, "Found the first textbox" );
my $B3 = $browser->get_node( 'B3' );
ok( $B3, "Found the third button" );
ok( $B3->{disabled}, " ... it is disabled" );
$TB1->{value} = "Hello world!";
$resp = Change( $browser, $TB1 );
$data = $browser->decode_resp( $resp, 'change TB1' );
$browser->handle_resp( $data, 'change TB1' );
is( $TB1->{value}, '', "First textbox was emptied" );
my $TB2 = $browser->get_node( 'TB2' );
ok( $TB2, "Found the second textbox" );
is( $TB2->{value}, "Hello world!", " ... it was updated" );
ok( !$B3->{disabled}, "Third button was enabled" );
$resp = Click( $browser, $B3 );
$data = $browser->decode_resp( $resp, 'click B3' );
$browser->handle_resp( $data, 'click B3' );
$text = Dumper $message;
ok( ( $text =~ /Hello world!/ ), "Clicked OK" );
is( $TB1->{value}, '', "Second textbox was emptied" );
############################################################
# Test javascript and CDATA
my $AB = $browser->get_node( 'alert-button' );
ok( $AB, "Found the alert-button" )
or die "I really need that button";
$resp = Click( $browser, $AB );
$data = $browser->decode_resp( $resp, 'click alert-button' );
$browser->handle_resp( $data, 'click alert-button' );
my $JS = $browser->{W}->{zC}[-1];
ok( ($JS and $JS->{type} eq 'text/javascript'), "Found the javascript" )
or die "I really need that javascript";
my $code = delete $JS->{zC}[0]{cdata};
ok( ($code =~ /alert/), "Got the javascript" )
or die $JS;
############################################################
# Test menulist
my $ML = $browser->get_node( 'ML1' );
ok( $ML, "Got the menulist" );
die Dumper $ML unless $ML->{zC};
$ML->{selectedIndex} = 2; # Bears
$resp = Select( $browser, $ML );
$data = $browser->decode_resp( $resp, 'select bears' );
$browser->handle_resp( $data, 'select bears' );
is( $ML->{selectedIndex}, 2, "Bears were selected" );
my $I = $ML->{zC}[0]{zC}[ $ML->{selectedIndex} ];
ok( $I, "Found the selected item" );
is( $I->{label}, "Bears", " ... and it's bears" )
or die Dumper $ML;
my $other;
SKIP: {
skip "Side-effects no longer echoed back to browser", 2;
ok( $I->{selected}, " ... and it's selected" )
or die Dumper $ML;
$other = $ML->{zC}[0]{zC}[ 0 ];
ok( !$other->{selected}, " ... and the other one isn't" )
or die Dumper $ML;
}
###########
$ML->{selectedIndex} = 0; # Lions
$resp = Select( $browser, $ML );
$data = $browser->decode_resp( $resp, 'select lions' );
$browser->handle_resp( $data, 'select lions' );
is( $ML->{selectedIndex}, 0, "Lions were selected" );
$I = $ML->{zC}[0]{zC}[ $ML->{selectedIndex} ];
ok( $I, "Found the selected item" );
is( $I->{label}, "Lions", " ... and it's lions" )
or die Dumper $ML;
SKIP: {
skip "Side-effects no longer echoed back to browser", 2;
ok( $I->{selected}, " ... and it's selected" )
or die Dumper $ML;
$other = $ML->{zC}[0]{zC}[ 2 ];
ok( !exists $other->{selected}, " ... and the other one isn't" )
or die Dumper $ML;
}
############################################################
# Test textnode manipulation
my $MC = $browser->get_node( 'message-clear' );
t/90_complete.t view on Meta::CPAN
ok( ($text =~ /hello world/), " ... and it's the one we want" )
or die $text;
############################################################
# Test radio buttons
my $RG1 = $browser->get_node( 'RG1' );
ok( $RG1, "Got the radiogroup" );
$resp = RadioClick( $browser, $RG1, 0 );
$data = $browser->decode_resp( $resp, 'orange' );
$browser->handle_resp( $data, 'orange' );
#########
$text = Dumper $message;
$count = () = ($text =~ /nodeValue/g);
is( $count, 2, "Two messages" )
or die $text;
ok( ($text =~ /Orange/), " ... and one we want" )
or die $text;
# CSS updated
ok( ($text =~/background-color: orange;/), " ... it's in orange" );
#########
my $R = RadioSelected( $RG1 );
is( $R->{label}, 'Orange', "I like orange" );
#########
$resp = RadioClick( $browser, $RG1, 1 );
$data = $browser->decode_resp( $resp, 'violet' );
$browser->handle_resp( $data, 'violet' );
#########
$text = Dumper $message;
$count = () = ($text =~ /nodeValue/g);
is( $count, 3, "Two messages" )
or die $text;
ok( ($text =~ /Violet/), " ... and one we want" )
or die $text;
# CSS updated
ok( ($text =~/background-color: violet;/), " ... it's in violet" );
#########
$R = RadioSelected( $RG1 );
SKIP: {
skip "Side-effects no longer echoed back to browser", 1;
is( $R->{label}, 'Violet', "Start wearing purple all the time" );
}
#########
$JS = $browser->{W}->{zC}[-1];
ok( $JS, "Found the javascript" )
or die "I really need that javascript";
is( $JS->{type}, 'text/javascript', "Found the javascript" )
or die Dumper $JS;
$code = $JS->{zC}[0]{cdata};
ok( !$code, "Didn't get more javascript" )
or die Dumper $JS;
############################################################
# Test listbox
my $SB = $browser->get_node( 'SB1' );
ok( $SB, "Got the listbox" );
die Dumper $SB unless $SB->{zC};
my $Cosmo = $SB->{zC}[5]; # Cosmo 3 + listcols + listheaders
$SB->{selectedIndex} = 3;
$resp = Select( $browser, $SB );
$data = $browser->decode_resp( $resp, 'select Cosmo' );
$browser->handle_resp( $data, 'select Cosmo' );
SKIP: {
skip "Side-effects no longer echoed back to browser", 1;
is( $Cosmo->{selected}, 'true', "Cosmo was selected" );
}
$text = Dumper $message;
$count = () = ($text =~ /Cosmo-Female-White/g);
is( $count, 1, "Got the one message" )
or die $text;
#########
my $Butter = $SB->{zC}[11]; # Butter 9 + listcols + listheaders
$SB->{selectedIndex} = 9;
$resp = Select( $browser, $SB );
$data = $browser->decode_resp( $resp, 'select Butter' );
$browser->handle_resp( $data, 'select Butter' );
SKIP: {
skip "Side-effects no longer echoed back to browser", 2;
is( $Butter->{selected}, 'true', "Butter was selected" );
is( $Cosmo->{selected}, undef(), " ... and cosmo isn't" );
}
$text = Dumper $message;
$count = () = ($text =~ /Butter-Male-Orange/g);
is( $count, 1, "Got the one message" )
or die $text;
############################################################
sub Click
{
my( $browser, $button ) = @_;
my $URI = $browser->Click_uri( $button );
return $UA->get( $URI );
}
( run in 0.418 second using v1.01-cache-2.11-cpan-0d23b851a93 )