]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/19-match.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 19-match.t
index e4fc6ec0225bbbd5116c6c8a7fac26676e2ed86e..8b9d21d3e0da46fbc422bda5041cd9365fcbbb61 100644 (file)
@@ -12,20 +12,7 @@ ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
 
 # Open a new window
 my $x = X11::XCB::Connection->new;
-my $window = $x->root->create_child(
-    class => WINDOW_CLASS_INPUT_OUTPUT,
-    rect => [ 0, 0, 30, 30 ],
-    background_color => '#C0C0C0',
-);
-
-$window->map;
-# give it some time to be picked up by the window manager
-# TODO: better check for $window->mapped or something like that?
-# maybe we can even wait for getting mapped?
-my $c = 0;
-while (@{get_ws_content($tmp)} == 0 and $c++ < 5) {
-    sleep 0.25;
-}
+my $window = open_window($x);
 my $content = get_ws_content($tmp);
 ok(@{$content} == 1, 'window mapped');
 my $win = $content->[0];
@@ -48,8 +35,7 @@ cmd 'nop now killing the window';
 my $id = $win->{id};
 cmd qq|[con_id="$id"] kill|;
 
-# give i3 some time to pick up the UnmapNotify event
-sleep 0.25;
+wait_for_unmap $x;
 
 cmd 'nop checking if its gone';
 $content = get_ws_content($tmp);
@@ -88,25 +74,27 @@ my $left = $x->root->create_child(
     class => WINDOW_CLASS_INPUT_OUTPUT,
     rect => [ 0, 0, 30, 30 ],
     background_color => '#0000ff',
+    event_mask => [ 'structure_notify' ],
 );
 
 $left->_create;
 set_wm_class($left->id, 'special', 'special');
 $left->name('left');
 $left->map;
-sleep 0.25;
+ok(wait_for_map($x), 'left window mapped');
 
 my $right = $x->root->create_child(
     class => WINDOW_CLASS_INPUT_OUTPUT,
     rect => [ 0, 0, 30, 30 ],
     background_color => '#0000ff',
+    event_mask => [ 'structure_notify' ],
 );
 
 $right->_create;
 set_wm_class($right->id, 'special', 'special');
 $right->name('right');
 $right->map;
-sleep 0.25;
+ok(wait_for_map($x), 'right window mapped');
 
 # two windows should be here
 $content = get_ws_content($tmp);
@@ -114,7 +102,7 @@ ok(@{$content} == 2, 'two windows opened');
 
 cmd '[class="special" title="left"] kill';
 
-sleep 0.25;
+sync_with_i3($x);
 
 $content = get_ws_content($tmp);
 is(@{$content}, 1, 'one window still there');
@@ -129,13 +117,14 @@ $left = $x->root->create_child(
     class => WINDOW_CLASS_INPUT_OUTPUT,
     rect => [ 0, 0, 30, 30 ],
     background_color => '#0000ff',
+    event_mask => [ 'structure_notify' ],
 );
 
 $left->_create;
 set_wm_class($left->id, 'special7', 'special7');
 $left->name('left');
 $left->map;
-sleep 0.25;
+ok(wait_for_map($x), 'left window mapped');
 
 # two windows should be here
 $content = get_ws_content($tmp);
@@ -143,7 +132,7 @@ ok(@{$content} == 1, 'window opened');
 
 cmd '[class="^special[0-9]$"] kill';
 
-sleep 0.25;
+wait_for_unmap $x;
 
 $content = get_ws_content($tmp);
 is(@{$content}, 0, 'window killed');
@@ -158,13 +147,14 @@ $left = $x->root->create_child(
     class => WINDOW_CLASS_INPUT_OUTPUT,
     rect => [ 0, 0, 30, 30 ],
     background_color => '#0000ff',
+    event_mask => [ 'structure_notify' ],
 );
 
 $left->_create;
 set_wm_class($left->id, 'special7', 'special7');
 $left->name('รค 3');
 $left->map;
-sleep 0.25;
+ok(wait_for_map($x), 'left window mapped');
 
 # two windows should be here
 $content = get_ws_content($tmp);
@@ -172,7 +162,7 @@ ok(@{$content} == 1, 'window opened');
 
 cmd '[title="^\w [3]$"] kill';
 
-sleep 0.25;
+wait_for_unmap $x;
 
 $content = get_ws_content($tmp);
 is(@{$content}, 0, 'window killed');