From 475dc3c5321d9d8bebd1b737a4ac7b543dcf3a9e Mon Sep 17 00:00:00 2001 From: Maik Fischer Date: Wed, 23 Nov 2011 17:22:43 +0100 Subject: [PATCH] testcases: use open_window everywhere --- testcases/lib/i3test.pm | 11 +- testcases/t/001-tile.t | 11 +- testcases/t/004-unmanaged.t | 6 +- testcases/t/005-floating.t | 38 +----- testcases/t/100-fullscreen.t | 19 +-- testcases/t/119-match.t | 70 +++-------- testcases/t/122-split.t | 1 - testcases/t/162-regress-dock-urgent.t | 10 +- testcases/t/165-for_window.t | 168 ++++++------------------- testcases/t/166-assign.t | 91 +++----------- testcases/t/173-regress-focus-assign.t | 37 ++---- 11 files changed, 107 insertions(+), 355 deletions(-) diff --git a/testcases/lib/i3test.pm b/testcases/lib/i3test.pm index 4de97c1f..8437a534 100644 --- a/testcases/lib/i3test.pm +++ b/testcases/lib/i3test.pm @@ -334,17 +334,10 @@ sub sync_with_i3 { # one on the first call of sync_with_i3. It will be re-used in all # subsequent calls. if (!defined($_sync_window)) { - $_sync_window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => X11::XCB::Rect->new(x => -15, y => -15, width => 10, height => 10 ), + $_sync_window = open_window( + rect => [ -15, -15, 10, 10 ], override_redirect => 1, - background_color => '#ff0000', - event_mask => [ 'structure_notify' ], ); - - $_sync_window->map; - - wait_for_event 2, sub { $_[0]->{response_type} == MAP_NOTIFY }; } my $root = $x->get_root_window(); diff --git a/testcases/t/001-tile.t b/testcases/t/001-tile.t index 65af8d74..c13b87c4 100644 --- a/testcases/t/001-tile.t +++ b/testcases/t/001-tile.t @@ -2,23 +2,16 @@ # vim:ts=4:sw=4:expandtab use i3test; -use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT'; my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => $original_rect, - background_color => '#C0C0C0', -); - +my $window = open_window(rect => $original_rect, dont_map => 1); isa_ok($window, 'X11::XCB::Window'); is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); $window->map; - -sleep(0.5); +wait_for_map $window; my $new_rect = $window->rect; ok(!eq_hash($new_rect, $original_rect), "Window got repositioned"); diff --git a/testcases/t/004-unmanaged.t b/testcases/t/004-unmanaged.t index 70bdb557..e998eb46 100644 --- a/testcases/t/004-unmanaged.t +++ b/testcases/t/004-unmanaged.t @@ -2,15 +2,13 @@ # vim:ts=4:sw=4:expandtab use i3test; -use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT'; my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, +my $window = open_window( rect => $original_rect, override_redirect => 1, - background_color => '#C0C0C0', + dont_map => 1, ); isa_ok($window, 'X11::XCB::Window'); diff --git a/testcases/t/005-floating.t b/testcases/t/005-floating.t index 6de3ea80..9ac45627 100644 --- a/testcases/t/005-floating.t +++ b/testcases/t/005-floating.t @@ -2,24 +2,12 @@ # vim:ts=4:sw=4:expandtab use i3test; -use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT'; # Create a floating window which is smaller than the minimum enforced size of i3 -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30], - background_color => '#C0C0C0', - # replace the type with 'utility' as soon as the coercion works again in X11::XCB - window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), - event_mask => [ 'structure_notify' ], -); +my $window = open_floating_window; isa_ok($window, 'X11::XCB::Window'); -$window->map; - -wait_for_map $window; - my ($absolute, $top) = $window->rect; ok($window->mapped, 'Window is mapped'); @@ -30,20 +18,10 @@ ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)'); $window->unmap; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 1, 1, 80, 90], - background_color => '#C0C0C0', - window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), - event_mask => [ 'structure_notify' ], -); +$window = open_floating_window(rect => [ 1, 1, 80, 90 ]); isa_ok($window, 'X11::XCB::Window'); -$window->map; - -wait_for_map $window; - ($absolute, $top) = $window->rect; cmp_ok($absolute->{width}, '==', 80, "i3 let the width at 80"); @@ -61,20 +39,10 @@ $window->unmap; # at least the size of its initial geometry ##################################################################### -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 1, 1, 80, 90], - background_color => '#C0C0C0', - #window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), - event_mask => [ 'structure_notify' ], -); +$window = open_window(rect => [ 1, 1, 80, 90 ]); isa_ok($window, 'X11::XCB::Window'); -$window->map; - -wait_for_map $window; - cmd 'floating enable'; sync_with_i3; diff --git a/testcases/t/100-fullscreen.t b/testcases/t/100-fullscreen.t index 4a8f87a7..cc893adc 100644 --- a/testcases/t/100-fullscreen.t +++ b/testcases/t/100-fullscreen.t @@ -2,7 +2,6 @@ # vim:ts=4:sw=4:expandtab use i3test; -use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT'; use List::Util qw(first); my $i3 = i3(get_socket_path()); @@ -32,11 +31,9 @@ for my $o (@outputs) { my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, +my $window = open_window( rect => $original_rect, - background_color => '#C0C0C0', - event_mask => [ 'structure_notify' ], + dont_map => 1, ); isa_ok($window, 'X11::XCB::Window'); @@ -83,11 +80,9 @@ $window->unmap; cmd 'open'; $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, +$window = open_window( rect => $original_rect, - background_color => 61440, - event_mask => [ 'structure_notify' ], + dont_map => 1, ); is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); @@ -114,11 +109,9 @@ ok(abs($wrect->{height} - $orect->{height}) < $threshold, 'height coordinate ful ############################################################################### $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -my $swindow = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, +my $swindow = open_window( rect => $original_rect, - background_color => '#C0C0C0', - event_mask => [ 'structure_notify' ], + dont_map => 1, ); $swindow->map; diff --git a/testcases/t/119-match.t b/testcases/t/119-match.t index 2124c02e..e6a4e832 100644 --- a/testcases/t/119-match.t +++ b/testcases/t/119-match.t @@ -4,7 +4,7 @@ # Tests all kinds of matching methods # use i3test; -use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT); +use X11::XCB qw(PROP_MODE_REPLACE); my $tmp = fresh_workspace; @@ -69,31 +69,21 @@ sub set_wm_class { ); } -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; -ok(wait_for_map($left), '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; -ok(wait_for_map($right), 'right window mapped'); +sub open_special { + my %args = @_; + my $wm_class = delete($args{wm_class}) || 'special'; + + return open_window( + %args, + before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) }, + ); +} + +my $left = open_special(name => 'left'); +ok($left->mapped, 'left window mapped'); + +my $right = open_special(name => 'right'); +ok($right->mapped, 'right window mapped'); # two windows should be here $content = get_ws_content($tmp); @@ -112,18 +102,8 @@ is(@{$content}, 1, 'one window still there'); $tmp = fresh_workspace; -$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; -ok(wait_for_map($left), 'left window mapped'); +$left = open_special(name => 'left', wm_class => 'special7'); +ok($left->mapped, 'left window mapped'); # two windows should be here $content = get_ws_content($tmp); @@ -142,18 +122,8 @@ is(@{$content}, 0, 'window killed'); $tmp = fresh_workspace; -$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; -ok(wait_for_map($left), 'left window mapped'); +$left = open_special(name => 'ä 3', wm_class => 'special7'); +ok($left->mapped, 'left window mapped'); # two windows should be here $content = get_ws_content($tmp); diff --git a/testcases/t/122-split.t b/testcases/t/122-split.t index 3484c7fc..71736db4 100644 --- a/testcases/t/122-split.t +++ b/testcases/t/122-split.t @@ -4,7 +4,6 @@ # Tests splitting # use i3test; -use X11::XCB qw(:all); my $tmp = fresh_workspace; diff --git a/testcases/t/162-regress-dock-urgent.t b/testcases/t/162-regress-dock-urgent.t index 7a0ac487..3562ba7a 100644 --- a/testcases/t/162-regress-dock-urgent.t +++ b/testcases/t/162-regress-dock-urgent.t @@ -5,7 +5,6 @@ # found in 4be3178d4d360c2996217d811e61161c84d25898 # use i3test; -use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT'; my $i3 = i3(get_socket_path()); @@ -22,17 +21,10 @@ is(@docked, 0, 'no dock clients yet'); # open a dock client -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30], - background_color => '#FF0000', +my $window = open_window( window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), ); -$window->map; - -sleep 0.25; - ##################################################################### # check that we can find it in the layout tree at the expected position ##################################################################### diff --git a/testcases/t/165-for_window.t b/testcases/t/165-for_window.t index c7601809..0ca5bd11 100644 --- a/testcases/t/165-for_window.t +++ b/testcases/t/165-for_window.t @@ -4,7 +4,7 @@ # # use i3test; -use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT); +use X11::XCB qw(PROP_MODE_REPLACE); ############################################################## # 1: test the following directive: @@ -25,16 +25,7 @@ my $pid = launch_with_config($config); my $tmp = fresh_workspace; -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], -); - -$window->name('Border window'); -$window->map; -wait_for_map $window; +my $window = open_window(name => 'Border window'); my @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); @@ -47,14 +38,6 @@ wait_for_unmap $window; cmp_ok(@content, '==', 0, 'no more nodes'); diag('content = '. Dumper(\@content)); -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], -); - -$window->_create; # TODO: move this to X11::XCB::Window sub set_wm_class { @@ -75,10 +58,10 @@ sub set_wm_class { ); } -set_wm_class($window->id, 'borderless', 'borderless'); -$window->name('Borderless window'); -$window->map; -wait_for_map $window; +$window = open_window( + name => 'Borderless window', + before_map => sub { set_wm_class($_->id, 'borderless', 'borderless') }, +); @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); @@ -108,16 +91,7 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], -); - -$window->name('special title'); -$window->map; -wait_for_map $window; +$window = open_window(name => 'special title'); @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); @@ -168,16 +142,7 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], -); - -$window->name('special mark title'); -$window->map; -wait_for_map $window; +$window = open_window(name => 'special mark title'); @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); @@ -212,20 +177,11 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], +$window = open_window( + name => 'usethis', + before_map => sub { set_wm_class($_->id, 'borderless', 'borderless') }, ); -$window->_create; - -set_wm_class($window->id, 'borderless', 'borderless'); -$window->name('usethis'); -$window->map; -wait_for_map $window; - @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); is($content[0]->{border}, 'none', 'no border'); @@ -268,19 +224,11 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], -); - -$window->_create; -set_wm_class($window->id, 'bar', 'foo'); -$window->name('usethis'); -$window->map; -wait_for_map $window; +$window = open_window( + name => 'usethis', + before_map => sub { set_wm_class($_->id, 'bar', 'foo') }, +); @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); @@ -303,20 +251,11 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], +$window = open_window( + name => 'usethis', + before_map => sub { set_wm_class($_->id, 'bar', 'foo') }, ); -$window->_create; - -set_wm_class($window->id, 'bar', 'foo'); -$window->name('usethis'); -$window->map; -wait_for_map $window; - @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); is($content[0]->{border}, 'none', 'no border'); @@ -340,20 +279,11 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], +$window = open_window( + name => 'usethis', + before_map => sub { set_wm_class($_->id, 'bar', 'foo') }, ); -$window->_create; - -set_wm_class($window->id, 'bar', 'foo'); -$window->name('usethis'); -$window->map; -wait_for_map $window; - @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); is($content[0]->{border}, 'normal', 'normal border'); @@ -377,31 +307,24 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], +$window = open_window( + name => 'usethis', + before_map => sub { + my ($window) = @_; + my $atomname = $x->atom(name => 'WM_WINDOW_ROLE'); + my $atomtype = $x->atom(name => 'STRING'); + $x->change_property( + PROP_MODE_REPLACE, + $window->id, + $atomname->id, + $atomtype->id, + 8, + length("i3test") + 1, + "i3test\x00" + ); + }, ); -$window->_create; - -my $atomname = $x->atom(name => 'WM_WINDOW_ROLE'); -my $atomtype = $x->atom(name => 'STRING'); -$x->change_property( - PROP_MODE_REPLACE, - $window->id, - $atomname->id, - $atomtype->id, - 8, - length("i3test") + 1, - "i3test\x00" -); - -$window->name('usethis'); -$window->map; -wait_for_map $window; - @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); is($content[0]->{border}, 'none', 'no border (window_role)'); @@ -426,25 +349,14 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#00ff00', - event_mask => [ 'structure_notify' ], -); - -$window->_create; - -$window->name('usethis'); -$window->map; -wait_for_map $window; +$window = open_window(name => 'usethis'); @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 1, 'one node on this workspace now'); is($content[0]->{border}, 'normal', 'normal border (window_role 2)'); -$atomname = $x->atom(name => 'WM_WINDOW_ROLE'); -$atomtype = $x->atom(name => 'STRING'); +my $atomname = $x->atom(name => 'WM_WINDOW_ROLE'); +my $atomtype = $x->atom(name => 'STRING'); $x->change_property( PROP_MODE_REPLACE, $window->id, diff --git a/testcases/t/166-assign.t b/testcases/t/166-assign.t index a10516a6..254616c5 100644 --- a/testcases/t/166-assign.t +++ b/testcases/t/166-assign.t @@ -5,7 +5,7 @@ # Tests if assignments work # use i3test; -use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT); +use X11::XCB qw(PROP_MODE_REPLACE); # TODO: move to X11::XCB sub set_wm_class { @@ -26,6 +26,16 @@ sub set_wm_class { ); } +sub open_special { + my %args = @_; + my $wm_class = delete($args{wm_class}) || 'special'; + $args{name} //= 'special window'; + + return open_window( + %args, + before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) }, + ); +} ##################################################################### # start a window and see that it does not get assigned with an empty config @@ -42,18 +52,7 @@ my $tmp = fresh_workspace; ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', - event_mask => [ 'structure_notify' ], -); - -$window->_create; -set_wm_class($window->id, 'special', 'special'); -$window->name('special window'); -$window->map; -wait_for_map $window; +my $window = open_special; ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace'); @@ -80,18 +79,7 @@ ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); my $workspaces = get_workspace_names; ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet'); -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', - event_mask => [ 'structure_notify' ], -); - -$window->_create; -set_wm_class($window->id, 'special', 'special'); -$window->name('special window'); -$window->map; -wait_for_map $window; +$window = open_special; ok(@{get_ws_content($tmp)} == 0, 'still no containers'); ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists'); @@ -120,21 +108,12 @@ $tmp = fresh_workspace; ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); ok("targetws" ~~ @{get_workspace_names()}, 'targetws does not exist yet'); -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', - event_mask => [ 'structure_notify' ], -); - -$window->_create; -set_wm_class($window->id, 'special', 'special'); -$window->name('special window'); -$window->map; # We use sync_with_i3 instead of wait_for_map here because i3 will not actually # map the window -- it will be assigned to a different workspace and will only # be mapped once you switch to that workspace +$window = open_special(dont_map => 1); +$window->map; sync_with_i3; ok(@{get_ws_content($tmp)} == 0, 'still no containers'); @@ -161,18 +140,7 @@ ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); $workspaces = get_workspace_names; ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet'); -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', - event_mask => [ 'structure_notify' ], -); - -$window->_create; -set_wm_class($window->id, 'special', 'special'); -$window->name('special window'); -$window->map; -wait_for_map $window; +$window = open_special; my $content = get_ws($tmp); ok(@{$content->{nodes}} == 0, 'no tiling cons'); @@ -202,18 +170,7 @@ ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); $workspaces = get_workspace_names; ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet'); -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', - event_mask => [ 'structure_notify' ], -); - -$window->_create; -set_wm_class($window->id, 'SPEcial', 'SPEcial'); -$window->name('special window'); -$window->map; -wait_for_map $window; +$window = open_special(wm_class => 'SPEcial'); $content = get_ws($tmp); ok(@{$content->{nodes}} == 0, 'no tiling cons'); @@ -251,20 +208,10 @@ my @docked = get_dock_clients; # syntax is(@docked, 1, 'one dock client yet'); -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', +$window = open_special( window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), - event_mask => [ 'structure_notify' ], ); -$window->_create; -set_wm_class($window->id, 'special', 'special'); -$window->name('special window'); -$window->map; -wait_for_map $window; - $content = get_ws($tmp); ok(@{$content->{nodes}} == 0, 'no tiling cons'); ok(@{$content->{floating_nodes}} == 0, 'one floating con'); @@ -277,6 +224,4 @@ does_i3_live; exit_gracefully($pid); -sleep 0.25; - done_testing; diff --git a/testcases/t/173-regress-focus-assign.t b/testcases/t/173-regress-focus-assign.t index bd0ff647..cf3385cc 100644 --- a/testcases/t/173-regress-focus-assign.t +++ b/testcases/t/173-regress-focus-assign.t @@ -6,7 +6,7 @@ # assigned to an invisible workspace # use i3test; -use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT); +use X11::XCB qw(PROP_MODE_REPLACE); # TODO: move to X11::XCB sub set_wm_class { @@ -27,6 +27,16 @@ sub set_wm_class { ); } +sub open_special { + my %args = @_; + my $wm_class = delete($args{wm_class}) || 'special'; + $args{name} //= 'special window'; + + return open_window( + %args, + before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) }, + ); +} ##################################################################### # start a window and see that it does not get assigned with an empty config @@ -45,18 +55,7 @@ my $tmp = fresh_workspace; ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); ok(get_ws($tmp)->{focused}, 'current workspace focused'); -my $window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', -); - -$window->_create; -set_wm_class($window->id, 'special', 'special'); -$window->name('special window'); -$window->map; -sleep 0.25; - +my $window = open_special; ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace'); ok(@{get_ws_content('targetws')} == 1, 'special window on targetws'); @@ -66,20 +65,10 @@ ok(get_ws($tmp)->{focused}, 'current workspace still focused'); # the same test, but with a floating window ##################################################################### -$window = $x->root->create_child( - class => WINDOW_CLASS_INPUT_OUTPUT, - rect => [ 0, 0, 30, 30 ], - background_color => '#0000ff', +$window = open_special( window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), ); -$window->_create; -set_wm_class($window->id, 'special', 'special'); -$window->name('special window'); -$window->map; -sleep 0.25; - - ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace'); ok(@{get_ws_content('targetws')} == 1, 'special window on targetws'); ok(get_ws($tmp)->{focused}, 'current workspace still focused'); -- 2.39.5