POE-XUL
view release on metacpan or search on metacpan
t/20_changemanager.t view on Meta::CPAN
is_deeply( $buffer, [[ 'for', '' ],
[ 'set', 'B1', 'selected', 'true' ],
[ 'remove', 'B1', 'selected' ]
], "Remove an attribute" )
or die Dumper $buffer;
##############################
# Test textnode manipulation
my $before = Dumper $CM;
$W->appendChild( 'Hello world' );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ 'textnode', 'top', 1, 'Hello world' ],
], "Added a textnode" )
or die Dumper $buffer;
## Now remove it
$W->removeChild( 1 );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ 'bye-textnode', 'top', 1 ],
], "Removed a textnode" )
or die Dumper $buffer;
## No-op
diag( "The following warning about an unknown child may be ignored" ) unless $ENV{AUTOMATED_TESTING};
$W->removeChild( 1 );
$buffer = $CM->flush;
is_deeply( $buffer, [], "No-op" )
or die Dumper $buffer;
my $after = Dumper $CM;
is( length( Dumper $CM ), length( $before) , "Didn't grow" )
;
## Remove one child
$W->removeChild( 0 );
$buffer = $CM->flush;
is_deeply( $buffer, [ [ 'for', '' ], [ qw( bye B1 ) ] ], "Remove a child" )
or die Dumper $buffer;
##############################
# Test script and CDATA
my $JS = "this is some JS";
$W->appendChild( Script( $JS ) );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ 'new', "PXN5", 'script', 'top', 0 ],
[ 'set', "PXN5", 'type', 'text/javascript' ],
[ 'cdata', 'PXN5', 0, $JS ]
], "Javascript + CDATA" )
or die Dumper $buffer;
## Change the CDATA
my $cdata = $W->firstChild->firstChild;
$JS = "Different JS";
# replaceData
$cdata->replaceData( 0, 100, $JS );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ 'cdata', 'PXN5', 0, $JS ]
], "Changed CDATA" )
or die Dumper $buffer;
# insertData
$cdata->insertData( 0, "Yet again " );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ 'cdata', 'PXN5', 0, "Yet again Different JS" ]
], "Changed CDATA" )
or die Dumper $buffer;
# appendData
$cdata->appendData( " man" );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ 'cdata', 'PXN5', 0, "Yet again Different JS man" ]
], "Changed CDATA" )
or die Dumper $buffer;
# deleteData
$cdata->deleteData( 0, 10 );
$cdata->deleteData( 12, 4 );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ 'cdata', 'PXN5', 0, "Different JS" ]
], "Changed CDATA" )
or die Dumper $buffer;
##############################
$W->appendChild( Label( 'honk' ) );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ qw( new PXN6 label top 1 ) ],
[ qw( textnode PXN6 0 honk ) ]
], "Add a child" )
or die Dumper $buffer;
##############################
$W->appendChild( ListItem( ListCell( label=>'honk' ),
ListCell( label=>'bonk' )
) );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ qw( new PXN9 listitem top 2 ) ],
[ qw( new PXN7 listcell PXN9 0 ) ],
[ qw( set PXN7 label honk ) ],
[ qw( new PXN8 listcell PXN9 1 ) ],
[ qw( set PXN8 label bonk ) ],
], "ListItem" )
or die Dumper $buffer;
##############################
$node = POE::XUL::Node->new( tag => 'box', honk=>'bonk', id=>'zippy' );
is( $node->id, 'zippy', "ID set" );
#use Data::Dumper;
#warn Dumper $node;
$node = POE::XUL::Node->new( 'Click' => bless( sub { "DUMMY" }, 'POE::Session::AnonEvent' ),
'class' => 'NOM_ CLIENT-NOM_',
'id' => 'CLIENT-NOM_',
'maxlength' => '10',
'name' => 'CLIENT-NOM_',
'search' => '!',
'search-tooltiptext' => 'Recherche de client',
'size' => -10,
'value' => ''
);
is( $node->id, 'CLIENT-NOM_', "ID set" );
##############################
$W->scrollTo( 17, 42 );
$buffer = $CM->flush;
is_deeply( $buffer, [[ 'for', '' ],
[ qw( method top scrollTo ), [ 17, 42 ] ],
], "scrollTo" )
or die Dumper $buffer;
( run in 2.673 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )