Change testcases to work with the released version of X11::XCB

This commit is contained in:
Michael Stapelberg 2009-10-26 20:04:37 +01:00
parent 153462824b
commit f9d155341e
13 changed files with 58 additions and 67 deletions

View File

@ -1,4 +1,4 @@
test: 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 all: test

View File

@ -10,11 +10,11 @@ BEGIN {
use_ok('X11::XCB::Window'); 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 $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, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect, rect => $original_rect,
background_color => '#C0C0C0', background_color => '#C0C0C0',
@ -24,7 +24,6 @@ isa_ok($window, 'X11::XCB::Window');
is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->create;
$window->map; $window->map;
sleep(0.25); sleep(0.25);

View File

@ -13,11 +13,11 @@ BEGIN {
use_ok('X11::XCB::Window'); 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 $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, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect, rect => $original_rect,
background_color => '#C0C0C0', background_color => '#C0C0C0',
@ -27,7 +27,6 @@ isa_ok($window, 'X11::XCB::Window');
is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->create;
$window->map; $window->map;
sleep(0.25); sleep(0.25);
@ -47,7 +46,7 @@ ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned after fullscr
$window->unmap; $window->unmap;
$window = X11::XCB::Window->new( $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect, rect => $original_rect,
background_color => 61440, background_color => 61440,
@ -55,7 +54,6 @@ $window = X11::XCB::Window->new(
is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->create;
$window->fullscreen(1); $window->fullscreen(1);
$window->map; $window->map;

View File

@ -10,11 +10,11 @@ BEGIN {
use_ok('X11::XCB::Window'); 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 $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, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect, rect => $original_rect,
override_redirect => 1, override_redirect => 1,
@ -25,7 +25,6 @@ isa_ok($window, 'X11::XCB::Window');
is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->create;
$window->map; $window->map;
my $new_rect = $window->rect; my $new_rect = $window->rect;

View File

@ -14,19 +14,19 @@ BEGIN {
use_ok('X11::XCB::Window'); 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 # 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, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30], rect => [ 0, 0, 30, 30],
background_color => '#C0C0C0', 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'); isa_ok($window, 'X11::XCB::Window');
$window->create;
$window->map; $window->map;
sleep(0.25); sleep(0.25);
@ -41,16 +41,15 @@ ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
$window->unmap; $window->unmap;
$window = X11::XCB::Window->new( $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 1, 1, 80, 90], rect => [ 1, 1, 80, 90],
background_color => '#C0C0C0', background_color => '#C0C0C0',
type => 'utility', type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
); );
isa_ok($window, 'X11::XCB::Window'); isa_ok($window, 'X11::XCB::Window');
$window->create;
$window->map; $window->map;
sleep(0.25); sleep(0.25);

View File

@ -15,7 +15,7 @@ BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); 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'); 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); sleep(0.25);
# Create a window so we can get a focus different from NULL # 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); diag("window->id = " . $window->id);
sleep(0.25); sleep(0.25);
my $focus = X11::XCB::Connection->input_focus; my $focus = $x->input_focus;
diag("old focus = $focus"); diag("old focus = $focus");
# Switch to the nineth workspace # Switch to the nineth workspace
@ -45,7 +45,7 @@ $sock->write(i3test::format_ipc_command("9"));
sleep(0.25); sleep(0.25);
my $new_focus = X11::XCB::Connection->input_focus; my $new_focus = $x->input_focus;
isnt($focus, $new_focus, "Focus changed"); isnt($focus, $new_focus, "Focus changed");
diag( "Testing i3, Perl $], $^X" ); diag( "Testing i3, Perl $], $^X" );

View File

@ -18,7 +18,7 @@ BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); 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'); my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX'); isa_ok($sock, 'IO::Socket::UNIX');
@ -36,9 +36,9 @@ sleep(0.25);
$sock->write(i3test::format_ipc_command("d")); $sock->write(i3test::format_ipc_command("d"));
sleep(0.25); sleep(0.25);
my $top = i3test::open_standard_window; my $top = i3test::open_standard_window($x);
my $mid = i3test::open_standard_window; my $mid = i3test::open_standard_window($x);
my $bottom = i3test::open_standard_window; my $bottom = i3test::open_standard_window($x);
sleep(0.25); sleep(0.25);
diag("top id = " . $top->id); diag("top id = " . $top->id);
@ -54,10 +54,10 @@ sub focus_after {
$sock->write(i3test::format_ipc_command($msg)); $sock->write(i3test::format_ipc_command($msg));
sleep(0.5); 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"); is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("k"); $focus = focus_after("k");

View File

@ -18,7 +18,7 @@ BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); 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'); my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX'); isa_ok($sock, 'IO::Socket::UNIX');
@ -32,11 +32,11 @@ sleep(0.25);
# Create two windows and make sure focus switching works # 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); sleep(0.25);
my $mid = i3test::open_standard_window; my $mid = i3test::open_standard_window($x);
sleep(0.25); sleep(0.25);
my $bottom = i3test::open_standard_window; my $bottom = i3test::open_standard_window($x);
sleep(0.25); sleep(0.25);
diag("top id = " . $top->id); diag("top id = " . $top->id);
@ -52,10 +52,10 @@ sub focus_after {
$sock->write(i3test::format_ipc_command($msg)); $sock->write(i3test::format_ipc_command($msg));
sleep(0.5); 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"); is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("ml"); $focus = focus_after("ml");

View File

@ -17,7 +17,7 @@ BEGIN {
use_ok('X11::XCB::Window') or BAIL_OUT('Could not load X11::XCB::Window'); 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'); my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX'); isa_ok($sock, 'IO::Socket::UNIX');
@ -27,37 +27,35 @@ $sock->write(i3test::format_ipc_command("9"));
sleep(0.25); sleep(0.25);
my $tiled_left = i3test::open_standard_window($x);
my $tiled_left = i3test::open_standard_window; my $tiled_right = i3test::open_standard_window($x);
my $tiled_right = i3test::open_standard_window;
sleep(0.25); sleep(0.25);
$sock->write(i3test::format_ipc_command("ml")); $sock->write(i3test::format_ipc_command("ml"));
# Get input focus before creating the floating window # 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 # 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, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 1, 1, 30, 30], rect => [ 1, 1, 30, 30],
background_color => '#C0C0C0', background_color => '#C0C0C0',
type => 'utility', type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
); );
isa_ok($window, 'X11::XCB::Window'); isa_ok($window, 'X11::XCB::Window');
$window->create;
$window->map; $window->map;
sleep(0.25); 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; $window->unmap;
sleep(0.25); 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" ); diag( "Testing i3, Perl $], $^X" );

View File

@ -18,7 +18,7 @@ BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); 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'); my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX'); isa_ok($sock, 'IO::Socket::UNIX');
@ -32,11 +32,11 @@ sleep(0.25);
# Create two windows and make sure focus switching works # 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); sleep(0.25);
my $mid = i3test::open_standard_window; my $mid = i3test::open_standard_window($x);
sleep(0.25); sleep(0.25);
my $bottom = i3test::open_standard_window; my $bottom = i3test::open_standard_window($x);
sleep(0.25); sleep(0.25);
diag("top id = " . $top->id); diag("top id = " . $top->id);
@ -52,10 +52,10 @@ sub focus_after {
$sock->write(i3test::format_ipc_command($msg)); $sock->write(i3test::format_ipc_command($msg));
sleep(0.25); 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"); is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("s"); $focus = focus_after("s");
@ -87,7 +87,7 @@ is($focus, $top->id, "Top window still focused (focus after moving)");
$focus = focus_after("h"); $focus = focus_after("h");
is($focus, $bottom->id, "Bottom window focused (focus after moving)"); 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); sleep(0.25);
# By now, we have this layout: # By now, we have this layout:

View File

@ -16,27 +16,26 @@ BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); 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 # Create a dock window and see if it gets managed
##################################################################### #####################################################################
my $screens = X11::XCB::Connection->screens; my $screens = $x->screens;
# Get the primary screen # Get the primary screen
my $primary = first { $_->primary } @{$screens}; my $primary = first { $_->primary } @{$screens};
# TODO: focus the primary screen before # TODO: focus the primary screen before
my $window = X11::XCB::Window->new( my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30], rect => [ 0, 0, 30, 30],
background_color => '#FF0000', background_color => '#FF0000',
type => 'dock', type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
); );
$window->create;
$window->map; $window->map;
sleep 0.25; sleep 0.25;

View File

@ -19,7 +19,7 @@ BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection'); 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'); my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX'); isa_ok($sock, 'IO::Socket::UNIX');
@ -33,11 +33,11 @@ sleep(0.25);
# Create two windows and make sure focus switching works # 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); sleep(0.25);
my $mid = i3test::open_standard_window; my $mid = i3test::open_standard_window($x);
sleep(0.25); sleep(0.25);
my $bottom = i3test::open_standard_window; my $bottom = i3test::open_standard_window($x);
sleep(0.25); sleep(0.25);
diag("top id = " . $top->id); diag("top id = " . $top->id);
@ -53,10 +53,10 @@ sub focus_after {
$sock->write(i3test::format_ipc_command($msg)); $sock->write(i3test::format_ipc_command($msg));
sleep(0.5); 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"); is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("ml"); $focus = focus_after("ml");

View File

@ -13,15 +13,14 @@ BEGIN {
} }
sub open_standard_window { 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, class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect, rect => [ 0, 0, 30, 30 ],
background_color => '#C0C0C0', background_color => '#C0C0C0',
); );
$window->create;
$window->name('Window ' . counter_window()); $window->name('Window ' . counter_window());
$window->map; $window->map;