1use strict; 2use warnings; 3 4use Test::More; 5use Prima::sys::Test; 6use Prima::Application; 7 8plan tests => 10; 9 10$Prima::sys::Test::timeout *= 4; 11 12my $dong1 = 0; 13my $dong2 = 0; 14 15my @p_rep; 16my @c_rep; 17my $p = create_window( 18 onMove => sub { 19 $dong1 = 1; 20 set_flag; 21 shift; 22 @p_rep = scalar(@p_rep) ? ( @p_rep[0,1], @_[2,3]) : @_; 23 }, 24 name => 'TEST', 25); 26 27 28my $c = $p-> insert( 'Prima::Widget' => 29 clipOwner => 0, 30 growMode => 0, 31 onMove => sub { 32 $dong2 = 1; 33 set_flag; shift; 34 @c_rep = scalar(@c_rep) ? ( @c_rep[0,1], @_[2,3]) : @_; 35 }, 36); 37 38my @p_or = $p-> origin; 39my @c_or = $c-> origin; 40reset_flag; 41$p-> origin( $p-> left + 1, $p-> bottom + 1); 42 43ok(( $dong1 && $dong2) || wait_flag, "onMove message - pass 1" ); 44my @nor = $p-> origin; 45SKIP : { 46 if ( $nor[0] == $p_or[0] + 1 && $nor[1] == $p_or[1] + 1) { 47 pass("correct movement"); 48 } elsif ( Prima::Application-> get_system_info->{apc} != apc::Unix) { 49 fail("correct movement"); 50 } else { 51 skip "WM doesn't respect moving request", 1; 52 } 53}; 54is_deeply( [$p_rep[2],$p_rep[3]], \@nor, "parameters consistency - pass 1" ); 55my @d = ( $nor[0] - $p_or[0], $nor[1] - $p_or[1]); 56ok( scalar(@c_rep), "c_rep move" ); 57is_deeply( \@c_rep, [@c_or, $c_rep[0] + $d[0], $c_rep[0] + $d[1]], "child move consistency" ); 58 59$p-> origin( $p-> left + 1, $p-> bottom + 1); 60$p-> size( $p-> width + 1, $p-> height + 1); 61 62@p_or = $p-> origin; 63@c_or = $c-> origin; 64@p_rep = @c_rep = (); 65 66reset_flag; 67$c-> growMode( gm::DontCare); 68$p-> origin( $p-> left + 2, $p-> bottom + 2); 69ok( wait_flag, "onMove message - pass 2" ); 70@nor = $p-> origin; 71is_deeply( \@p_rep, [@p_or,@nor], "parameters consistency - pass 2" ); 72@p_or = $c-> origin; 73is_deeply( \@p_or, \@c_or, "gmDontCare" ); 74 75@p_or = $c-> origin; 76$c-> owner( create_window() ); 77@nor = $c-> origin; 78$c-> owner( $p); 79is_deeply( \@p_or, \@nor, "recreate consistency" ); 80 81$c-> clipOwner(1); 82@p_or = map { $_ + 10 } $c-> origin; 83$p->scroll( 10, 10, withChildren => 1); 84@c_or = $c-> origin; 85is_deeply( \@p_or, \@c_or, "scroll childrren" ); 86 87$p-> destroy; 88