From f9d155341e539edb75973a40f9c66ed698bdf4e7 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 26 Oct 2009 20:04:37 +0100 Subject: [PATCH] Change testcases to work with the released version of X11::XCB --- testcases/Makefile | 2 +- testcases/t/01-tile.t | 5 ++--- testcases/t/02-fullscreen.t | 8 +++----- testcases/t/03-unmanaged.t | 5 ++--- testcases/t/04-floating.t | 13 ++++++------- testcases/t/05-ipc.t | 8 ++++---- testcases/t/06-focus.t | 12 ++++++------ testcases/t/07-move.t | 12 ++++++------ testcases/t/08-focus-stack.t | 18 ++++++++---------- testcases/t/09-stacking.t | 14 +++++++------- testcases/t/10-dock.t | 9 ++++----- testcases/t/11-goto.t | 12 ++++++------ testcases/t/lib/i3test.pm | 7 +++---- 13 files changed, 58 insertions(+), 67 deletions(-) diff --git a/testcases/Makefile b/testcases/Makefile index 678312a9..d37450ab 100644 --- a/testcases/Makefile +++ b/testcases/Makefile @@ -1,4 +1,4 @@ test: - PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1, '/home/michael//X11-XCB/lib/', '/home/michael//X11-XCB/blib/lib', '/home/michael//X11-XCB/blib/arch', '/home/michael/X11-XCB/X11-XCB-XS/lib', '/home/michael/X11-XCB/X11-XCB-XS/blib/arch')" t/11-*.t + PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1)" t/*.t all: test diff --git a/testcases/t/01-tile.t b/testcases/t/01-tile.t index c80c5e15..a5aa143d 100644 --- a/testcases/t/01-tile.t +++ b/testcases/t/01-tile.t @@ -10,11 +10,11 @@ BEGIN { use_ok('X11::XCB::Window'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -my $window = X11::XCB::Window->new( +my $window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => $original_rect, background_color => '#C0C0C0', @@ -24,7 +24,6 @@ isa_ok($window, 'X11::XCB::Window'); is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); -$window->create; $window->map; sleep(0.25); diff --git a/testcases/t/02-fullscreen.t b/testcases/t/02-fullscreen.t index b4ebd26b..40a7d983 100644 --- a/testcases/t/02-fullscreen.t +++ b/testcases/t/02-fullscreen.t @@ -13,11 +13,11 @@ BEGIN { use_ok('X11::XCB::Window'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -my $window = X11::XCB::Window->new( +my $window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => $original_rect, background_color => '#C0C0C0', @@ -27,7 +27,6 @@ isa_ok($window, 'X11::XCB::Window'); is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); -$window->create; $window->map; sleep(0.25); @@ -47,7 +46,7 @@ ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned after fullscr $window->unmap; -$window = X11::XCB::Window->new( +$window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => $original_rect, background_color => 61440, @@ -55,7 +54,6 @@ $window = X11::XCB::Window->new( is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); -$window->create; $window->fullscreen(1); $window->map; diff --git a/testcases/t/03-unmanaged.t b/testcases/t/03-unmanaged.t index 482c7645..3cd9833a 100644 --- a/testcases/t/03-unmanaged.t +++ b/testcases/t/03-unmanaged.t @@ -10,11 +10,11 @@ BEGIN { use_ok('X11::XCB::Window'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); -my $window = X11::XCB::Window->new( +my $window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => $original_rect, override_redirect => 1, @@ -25,7 +25,6 @@ isa_ok($window, 'X11::XCB::Window'); is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); -$window->create; $window->map; my $new_rect = $window->rect; diff --git a/testcases/t/04-floating.t b/testcases/t/04-floating.t index b0651241..9049b9dc 100644 --- a/testcases/t/04-floating.t +++ b/testcases/t/04-floating.t @@ -14,19 +14,19 @@ BEGIN { use_ok('X11::XCB::Window'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; # Create a floating window which is smaller than the minimum enforced size of i3 -my $window = X11::XCB::Window->new( +my $window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 0, 0, 30, 30], background_color => '#C0C0C0', - type => 'utility', + # replace the type with 'utility' as soon as the coercion works again in X11::XCB + type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), ); isa_ok($window, 'X11::XCB::Window'); -$window->create; $window->map; sleep(0.25); @@ -41,16 +41,15 @@ ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)'); $window->unmap; -$window = X11::XCB::Window->new( +$window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 1, 1, 80, 90], background_color => '#C0C0C0', - type => 'utility', + type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), ); isa_ok($window, 'X11::XCB::Window'); -$window->create; $window->map; sleep(0.25); diff --git a/testcases/t/05-ipc.t b/testcases/t/05-ipc.t index b34ba4f2..ac52911a 100644 --- a/testcases/t/05-ipc.t +++ b/testcases/t/05-ipc.t @@ -15,7 +15,7 @@ BEGIN { use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock'); @@ -32,12 +32,12 @@ $sock->write(i3test::format_ipc_command("1")); sleep(0.25); # Create a window so we can get a focus different from NULL -my $window = i3test::open_standard_window; +my $window = i3test::open_standard_window($x); diag("window->id = " . $window->id); sleep(0.25); -my $focus = X11::XCB::Connection->input_focus; +my $focus = $x->input_focus; diag("old focus = $focus"); # Switch to the nineth workspace @@ -45,7 +45,7 @@ $sock->write(i3test::format_ipc_command("9")); sleep(0.25); -my $new_focus = X11::XCB::Connection->input_focus; +my $new_focus = $x->input_focus; isnt($focus, $new_focus, "Focus changed"); diag( "Testing i3, Perl $], $^X" ); diff --git a/testcases/t/06-focus.t b/testcases/t/06-focus.t index f34095ca..efdf5749 100644 --- a/testcases/t/06-focus.t +++ b/testcases/t/06-focus.t @@ -18,7 +18,7 @@ BEGIN { use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock'); isa_ok($sock, 'IO::Socket::UNIX'); @@ -36,9 +36,9 @@ sleep(0.25); $sock->write(i3test::format_ipc_command("d")); sleep(0.25); -my $top = i3test::open_standard_window; -my $mid = i3test::open_standard_window; -my $bottom = i3test::open_standard_window; +my $top = i3test::open_standard_window($x); +my $mid = i3test::open_standard_window($x); +my $bottom = i3test::open_standard_window($x); sleep(0.25); diag("top id = " . $top->id); @@ -54,10 +54,10 @@ sub focus_after { $sock->write(i3test::format_ipc_command($msg)); sleep(0.5); - return X11::XCB::Connection->input_focus; + return $x->input_focus; } -$focus = X11::XCB::Connection->input_focus; +$focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after("k"); diff --git a/testcases/t/07-move.t b/testcases/t/07-move.t index a4f9f424..10cb9830 100644 --- a/testcases/t/07-move.t +++ b/testcases/t/07-move.t @@ -18,7 +18,7 @@ BEGIN { use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock'); isa_ok($sock, 'IO::Socket::UNIX'); @@ -32,11 +32,11 @@ sleep(0.25); # Create two windows and make sure focus switching works ##################################################################### -my $top = i3test::open_standard_window; +my $top = i3test::open_standard_window($x); sleep(0.25); -my $mid = i3test::open_standard_window; +my $mid = i3test::open_standard_window($x); sleep(0.25); -my $bottom = i3test::open_standard_window; +my $bottom = i3test::open_standard_window($x); sleep(0.25); diag("top id = " . $top->id); @@ -52,10 +52,10 @@ sub focus_after { $sock->write(i3test::format_ipc_command($msg)); sleep(0.5); - return X11::XCB::Connection->input_focus; + return $x->input_focus; } -$focus = X11::XCB::Connection->input_focus; +$focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after("ml"); diff --git a/testcases/t/08-focus-stack.t b/testcases/t/08-focus-stack.t index d88239df..370369d8 100644 --- a/testcases/t/08-focus-stack.t +++ b/testcases/t/08-focus-stack.t @@ -17,7 +17,7 @@ BEGIN { use_ok('X11::XCB::Window') or BAIL_OUT('Could not load X11::XCB::Window'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock'); isa_ok($sock, 'IO::Socket::UNIX'); @@ -27,37 +27,35 @@ $sock->write(i3test::format_ipc_command("9")); sleep(0.25); - -my $tiled_left = i3test::open_standard_window; -my $tiled_right = i3test::open_standard_window; +my $tiled_left = i3test::open_standard_window($x); +my $tiled_right = i3test::open_standard_window($x); sleep(0.25); $sock->write(i3test::format_ipc_command("ml")); # Get input focus before creating the floating window -my $focus = X11::XCB::Connection->input_focus; +my $focus = $x->input_focus; # Create a floating window which is smaller than the minimum enforced size of i3 -my $window = X11::XCB::Window->new( +my $window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 1, 1, 30, 30], background_color => '#C0C0C0', - type => 'utility', + type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'), ); isa_ok($window, 'X11::XCB::Window'); -$window->create; $window->map; sleep(0.25); -is(X11::XCB::Connection->input_focus, $window->id, 'floating window focused'); +is($x->input_focus, $window->id, 'floating window focused'); $window->unmap; sleep(0.25); -is(X11::XCB::Connection->input_focus, $focus, 'Focus correctly restored'); +is($x->input_focus, $focus, 'Focus correctly restored'); diag( "Testing i3, Perl $], $^X" ); diff --git a/testcases/t/09-stacking.t b/testcases/t/09-stacking.t index 083961fb..8f40047e 100644 --- a/testcases/t/09-stacking.t +++ b/testcases/t/09-stacking.t @@ -18,7 +18,7 @@ BEGIN { use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock'); isa_ok($sock, 'IO::Socket::UNIX'); @@ -32,11 +32,11 @@ sleep(0.25); # Create two windows and make sure focus switching works ##################################################################### -my $top = i3test::open_standard_window; +my $top = i3test::open_standard_window($x); sleep(0.25); -my $mid = i3test::open_standard_window; +my $mid = i3test::open_standard_window($x); sleep(0.25); -my $bottom = i3test::open_standard_window; +my $bottom = i3test::open_standard_window($x); sleep(0.25); diag("top id = " . $top->id); @@ -52,10 +52,10 @@ sub focus_after { $sock->write(i3test::format_ipc_command($msg)); sleep(0.25); - return X11::XCB::Connection->input_focus; + return $x->input_focus; } -$focus = X11::XCB::Connection->input_focus; +$focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after("s"); @@ -87,7 +87,7 @@ is($focus, $top->id, "Top window still focused (focus after moving)"); $focus = focus_after("h"); is($focus, $bottom->id, "Bottom window focused (focus after moving)"); -my $new = i3test::open_standard_window; +my $new = i3test::open_standard_window($x); sleep(0.25); # By now, we have this layout: diff --git a/testcases/t/10-dock.t b/testcases/t/10-dock.t index a3824fb9..97ac5f41 100644 --- a/testcases/t/10-dock.t +++ b/testcases/t/10-dock.t @@ -16,27 +16,26 @@ BEGIN { use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; ##################################################################### # Create a dock window and see if it gets managed ##################################################################### -my $screens = X11::XCB::Connection->screens; +my $screens = $x->screens; # Get the primary screen my $primary = first { $_->primary } @{$screens}; # TODO: focus the primary screen before -my $window = X11::XCB::Window->new( +my $window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 0, 0, 30, 30], background_color => '#FF0000', - type => 'dock', + type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), ); -$window->create; $window->map; sleep 0.25; diff --git a/testcases/t/11-goto.t b/testcases/t/11-goto.t index b08509f8..47675903 100644 --- a/testcases/t/11-goto.t +++ b/testcases/t/11-goto.t @@ -19,7 +19,7 @@ BEGIN { use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); } -X11::XCB::Connection->connect(':0'); +my $x = X11::XCB::Connection->new; my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock'); isa_ok($sock, 'IO::Socket::UNIX'); @@ -33,11 +33,11 @@ sleep(0.25); # Create two windows and make sure focus switching works ##################################################################### -my $top = i3test::open_standard_window; +my $top = i3test::open_standard_window($x); sleep(0.25); -my $mid = i3test::open_standard_window; +my $mid = i3test::open_standard_window($x); sleep(0.25); -my $bottom = i3test::open_standard_window; +my $bottom = i3test::open_standard_window($x); sleep(0.25); diag("top id = " . $top->id); @@ -53,10 +53,10 @@ sub focus_after { $sock->write(i3test::format_ipc_command($msg)); sleep(0.5); - return X11::XCB::Connection->input_focus; + return $x->input_focus; } -$focus = X11::XCB::Connection->input_focus; +$focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after("ml"); diff --git a/testcases/t/lib/i3test.pm b/testcases/t/lib/i3test.pm index 8ca1cee4..a60fd6d2 100644 --- a/testcases/t/lib/i3test.pm +++ b/testcases/t/lib/i3test.pm @@ -13,15 +13,14 @@ BEGIN { } sub open_standard_window { - my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30); + my ($x) = @_; - my $window = X11::XCB::Window->new( + my $window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, - rect => $original_rect, + rect => [ 0, 0, 30, 30 ], background_color => '#C0C0C0', ); - $window->create; $window->name('Window ' . counter_window()); $window->map; -- 2.39.5