Merge branch 'testsuite' into next

next
Michael Stapelberg 2011-11-21 23:52:18 +00:00
commit bf105e1d7d
57 changed files with 258 additions and 471 deletions

View File

@ -12,6 +12,7 @@ use EV;
use List::Util qw(first);
use Time::HiRes qw(sleep);
use Cwd qw(abs_path);
use Scalar::Util qw(blessed);
use SocketActivation;
use v5.10;
@ -39,6 +40,7 @@ our @EXPORT = qw(
wait_for_event
wait_for_map
wait_for_unmap
$x
);
my $tester = Test::Builder->new();
@ -46,6 +48,8 @@ my $_cached_socket_path = undef;
my $_sync_window = undef;
my $tmp_socket_path = undef;
our $x;
BEGIN {
my $window_count = 0;
sub counter_window {
@ -56,16 +60,23 @@ BEGIN {
sub import {
my $class = shift;
my $pkg = caller;
eval "package $pkg;
use Test::Most" . (@_ > 0 ? " qw(@_)" : "") . ";
my $test_most_args = @_ ? "qw(@_)" : "";
local $@;
eval << "__";
package $pkg;
use Test::Most $test_most_args;
use Data::Dumper;
use AnyEvent::I3;
use Time::HiRes qw(sleep);
use Test::Deep qw(eq_deeply cmp_deeply cmp_set cmp_bag cmp_methods useclass noclass set bag subbagof superbagof subsetof supersetof superhashof subhashof bool str arraylength Isa ignore methods regexprefonly regexpmatches num regexponly scalref reftype hashkeysonly blessed array re hash regexpref hash_each shallow array_each code arrayelementsonly arraylengthonly scalarrefonly listmethods any hashkeys isa);
use v5.10;
use strict;
use warnings;
";
use Test::Deep qw(eq_deeply cmp_deeply);
__
$tester->bail_out("$@") if $@;
feature->import(":5.10");
strict->import;
warnings->import;
$x ||= i3test::X11->new;
@_ = ($class);
goto \&Exporter::import;
}
@ -80,7 +91,7 @@ use warnings;
# wait_for_event $x, 0.25, sub { $_[0]->{response_type} == MAP_NOTIFY };
#
sub wait_for_event {
my ($x, $timeout, $cb) = @_;
my ($timeout, $cb) = @_;
my $cv = AE::cv;
@ -112,16 +123,22 @@ sub wait_for_event {
# thin wrapper around wait_for_event which waits for MAP_NOTIFY
# make sure to include 'structure_notify' in the windows event_mask attribute
sub wait_for_map {
my ($x) = @_;
wait_for_event $x, 2, sub { $_[0]->{response_type} == MAP_NOTIFY };
my ($win) = @_;
my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
wait_for_event 2, sub {
$_[0]->{response_type} == MAP_NOTIFY and $_[0]->{window} == $id
};
}
# Wrapper around wait_for_event which waits for UNMAP_NOTIFY. Also calls
# sync_with_i3 to make sure i3 also picked up and processed the UnmapNotify
# event.
sub wait_for_unmap {
my ($x) = @_;
wait_for_event $x, 2, sub { $_[0]->{response_type} == UNMAP_NOTIFY };
my ($win) = @_;
# my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
wait_for_event 2, sub {
$_[0]->{response_type} == UNMAP_NOTIFY # and $_[0]->{window} == $id
};
sync_with_i3($x);
}
@ -139,7 +156,7 @@ sub wait_for_unmap {
# name => 'Window <n>'
#
sub open_window {
my ($x, $args) = @_;
my ($args) = @_;
my %args = ($args ? %$args : ());
my $dont_map = delete $args{dont_map};
@ -155,7 +172,7 @@ sub open_window {
return $window if $dont_map;
$window->map;
wait_for_map($x);
wait_for_map($window);
# We sync with i3 here to make sure $x->input_focus is updated.
sync_with_i3($x);
return $window;
@ -169,7 +186,7 @@ sub open_floating_window {
$args{window_type} = $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY');
return open_window($x, \%args);
return open_window(\%args);
}
sub open_empty_con {
@ -324,7 +341,7 @@ sub sync_with_i3 {
$_sync_window->map;
wait_for_event $x, 2, sub { $_[0]->{response_type} == MAP_NOTIFY };
wait_for_event 2, sub { $_[0]->{response_type} == MAP_NOTIFY };
}
my $root = $x->get_root_window();
@ -350,7 +367,7 @@ sub sync_with_i3 {
$x->send_event(0, $root, EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg);
# now wait until the reply is here
return wait_for_event $x, 2, sub {
return wait_for_event 2, sub {
my ($event) = @_;
# TODO: const
return 0 unless $event->{response_type} == 161;
@ -398,7 +415,6 @@ sub get_socket_path {
return $_cached_socket_path;
}
my $x = X11::XCB::Connection->new;
my $atom = $x->atom(name => 'I3_SOCKET_PATH');
my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256);
my $reply = $x->get_property_reply($cookie->{sequence});
@ -449,4 +465,14 @@ sub launch_with_config {
return $pid;
}
package i3test::X11;
use parent 'X11::XCB::Connection';
sub input_focus {
my $self = shift;
i3test::sync_with_i3($self);
return $self->SUPER::input_focus(@_);
}
1

View File

@ -2,13 +2,7 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT';
my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);

View File

@ -3,12 +3,8 @@
#
# checks if i3 supports I3_SYNC
#
use X11::XCB qw(:all);
use X11::XCB::Connection;
use i3test;
my $x = X11::XCB::Connection->new;
my $result = sync_with_i3($x);
ok($result, 'syncing was successful');

View File

@ -3,8 +3,6 @@
use i3test;
my $x = X11::XCB::Connection->new;
fresh_workspace;
#####################################################################
@ -12,7 +10,7 @@ fresh_workspace;
#####################################################################
# Create a window so we can get a focus different from NULL
my $window = open_window($x);
my $window = open_window;
my $focus = $x->input_focus;

View File

@ -2,13 +2,7 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT';
my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);

View File

@ -2,13 +2,7 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
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(
@ -24,7 +18,7 @@ isa_ok($window, 'X11::XCB::Window');
$window->map;
wait_for_map $x;
wait_for_map $window;
my ($absolute, $top) = $window->rect;
@ -48,7 +42,7 @@ isa_ok($window, 'X11::XCB::Window');
$window->map;
wait_for_map $x;
wait_for_map $window;
($absolute, $top) = $window->rect;
@ -79,9 +73,10 @@ isa_ok($window, 'X11::XCB::Window');
$window->map;
wait_for_map $x;
wait_for_map $window;
cmd 'floating enable';
sync_with_i3($x);
($absolute, $top) = $window->rect;

View File

@ -2,7 +2,7 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT';
use List::Util qw(first);
my $i3 = i3(get_socket_path());
@ -26,12 +26,6 @@ for my $o (@outputs) {
}
}
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
##################################
# map a window, then fullscreen it
##################################
@ -51,7 +45,7 @@ is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->map;
wait_for_map $x;
wait_for_map $window;
# open another container to make the window get only half of the screen
cmd 'open';
@ -101,7 +95,7 @@ is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->fullscreen(1);
$window->map;
wait_for_map $x;
wait_for_map $window;
$new_rect = $window->rect;
ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned after fullscreen");

View File

@ -3,8 +3,6 @@
use i3test;
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
#####################################################################
@ -15,9 +13,9 @@ my $tmp = fresh_workspace;
cmd 'layout default';
cmd 'split v';
my $top = open_window($x);
my $mid = open_window($x);
my $bottom = open_window($x);
my $top = open_window;
my $mid = open_window;
my $bottom = open_window;
#
# Returns the input focus after sending the given command to i3 via IPC
@ -31,7 +29,7 @@ sub focus_after {
return $x->input_focus;
}
$focus = $x->input_focus;
my $focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after('focus up');

View File

@ -2,15 +2,9 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
use X11::XCB 'PROP_MODE_REPLACE';
use List::Util qw(first);
BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
my $x = X11::XCB::Connection->new;
#####################################################################
# verify that there is no dock window yet
#####################################################################
@ -29,7 +23,7 @@ my $screens = $x->screens;
my $primary = first { $_->primary } @{$screens};
# TODO: focus the primary screen before
my $window = open_window($x, {
my $window = open_window({
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
@ -73,7 +67,7 @@ is($docknode->{rect}->{height}, 40, 'dock height changed');
$window->destroy;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients();
is(@docked, 0, 'no more dock clients');
@ -82,13 +76,13 @@ is(@docked, 0, 'no more dock clients');
# check if it gets placed on bottom (by coordinates)
#####################################################################
$window = open_window($x, {
$window = open_window({
rect => [ 0, 1000, 30, 30 ],
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
my $rect = $window->rect;
$rect = $window->rect;
is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
is($rect->height, 30, 'height is unchanged');
@ -97,7 +91,7 @@ is(@docked, 1, 'dock client on bottom');
$window->destroy;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients();
is(@docked, 0, 'no more dock clients');
@ -106,7 +100,7 @@ is(@docked, 0, 'no more dock clients');
# check if it gets placed on bottom (by hint)
#####################################################################
$window = open_window($x, {
$window = open_window({
dont_map => 1,
rect => [ 0, 1000, 30, 30 ],
background_color => '#FF0000',
@ -131,19 +125,19 @@ $x->change_property(
$window->map;
wait_for_map $x;
wait_for_map $window;
@docked = get_dock_clients('top');
is(@docked, 1, 'dock client on top');
$window->destroy;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients();
is(@docked, 0, 'no more dock clients');
$window = open_window($x, {
$window = open_window({
dont_map => 1,
rect => [ 0, 1000, 30, 30 ],
background_color => '#FF0000',
@ -153,8 +147,8 @@ $window = open_window($x, {
$window->_create();
# Add a _NET_WM_STRUT_PARTIAL hint
my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
my $atomtype = $x->atom(name => 'CARDINAL');
$atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
$atomtype = $x->atom(name => 'CARDINAL');
$x->change_property(
PROP_MODE_REPLACE,
@ -168,7 +162,7 @@ $x->change_property(
$window->map;
wait_for_map $x;
wait_for_map $window;
@docked = get_dock_clients('bottom');
is(@docked, 1, 'dock client on bottom');
@ -180,7 +174,7 @@ $window->destroy;
# regression test: transient dock client
#####################################################################
$fwindow = open_window($x, {
my $fwindow = open_window({
dont_map => 1,
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
@ -189,7 +183,7 @@ $fwindow = open_window($x, {
$fwindow->transient_for($window);
$fwindow->map;
wait_for_map $x;
wait_for_map $fwindow;
does_i3_live;

View File

@ -48,7 +48,7 @@ sub focus_after {
return $x->input_focus;
}
$focus = $x->input_focus;
my $focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("ml");

View File

@ -5,13 +5,11 @@
use i3test;
my $x = X11::XCB::Connection->new;
fresh_workspace;
cmd 'split h';
my $tiled_left = open_window($x);
my $tiled_right = open_window($x);
my $tiled_left = open_window;
my $tiled_right = open_window;
# Get input focus before creating the floating window
my $focus = $x->input_focus;
@ -23,7 +21,7 @@ is($x->input_focus, $window->id, 'floating window focused');
$window->unmap;
wait_for_unmap($x);
wait_for_unmap $window;
is($x->input_focus, $focus, 'Focus correctly restored');

View File

@ -46,7 +46,7 @@ sub focus_after {
return $x->input_focus;
}
$focus = $x->input_focus;
my $focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("s");

View File

@ -4,8 +4,6 @@
use i3test;
use File::Temp;
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
cmd 'split h';
@ -14,9 +12,9 @@ cmd 'split h';
# Create two windows and make sure focus switching works
#####################################################################
my $top = open_window($x);
my $mid = open_window($x);
my $bottom = open_window($x);
my $top = open_window;
my $mid = open_window;
my $bottom = open_window;
#
# Returns the input focus after sending the given command to i3 via IPC
@ -30,7 +28,7 @@ sub focus_after {
return $x->input_focus;
}
$focus = $x->input_focus;
my $focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after('focus left');

View File

@ -2,13 +2,6 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
my $x = X11::XCB::Connection->new;
fresh_workspace;

View File

@ -2,15 +2,8 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
use List::Util qw(first);
BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
#####################################################################
@ -19,8 +12,8 @@ my $tmp = fresh_workspace;
cmd 'split v';
my $top = open_window($x);
my $bottom = open_window($x);
my $top = open_window;
my $bottom = open_window;
my @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
is(@urgent, 0, 'no window got the urgent flag');
@ -33,10 +26,10 @@ is(@urgent, 0, 'no window got the urgent flag');
$top->add_hint('urgency');
sync_with_i3($x);
@content = @{get_ws_content($tmp)};
my @content = @{get_ws_content($tmp)};
@urgent = grep { $_->{urgent} } @content;
$top_info = first { $_->{window} == $top->id } @content;
$bottom_info = first { $_->{window} == $bottom->id } @content;
my $top_info = first { $_->{window} == $top->id } @content;
my $bottom_info = first { $_->{window} == $bottom->id } @content;
ok($top_info->{urgent}, 'top window is marked urgent');
ok(!$bottom_info->{urgent}, 'bottom window is not marked urgent');

View File

@ -2,13 +2,6 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
@ -20,8 +13,8 @@ my $tmp = fresh_workspace;
# one of both (depending on your screen resolution) will be positioned wrong.
####################################################################################
my $left = open_window($x, { name => 'Left' });
my $right = open_window($x, { name => 'Right' });
my $left = open_window({ name => 'Left' });
my $right = open_window({ name => 'Right' });
my ($abs, $rgeom) = $right->rect;
@ -32,7 +25,7 @@ my $child = open_floating_window($x, {
$child->client_leader($right);
$child->map;
ok(wait_for_map($x), 'child window mapped');
ok(wait_for_map($child), 'child window mapped');
my $cgeom;
($abs, $cgeom) = $child->rect;
@ -45,17 +38,17 @@ my $child2 = open_floating_window($x, {
$child2->client_leader($left);
$child2->map;
ok(wait_for_map($x), 'second child window mapped');
ok(wait_for_map($child2), 'second child window mapped');
($abs, $cgeom) = $child2->rect;
cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
# check wm_transient_for
my $fwindow = open_window($x, { dont_map => 1 });
my $fwindow = open_window({ dont_map => 1 });
$fwindow->transient_for($right);
$fwindow->map;
ok(wait_for_map($x), 'transient window mapped');
ok(wait_for_map($fwindow), 'transient window mapped');
my ($absolute, $top) = $fwindow->rect;
ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
@ -67,10 +60,10 @@ SKIP: {
# Create a parent window
#####################################################################
my $window = open_window($x, { dont_map => 1, name => 'Parent window' });
my $window = open_window({ dont_map => 1, name => 'Parent window' });
$window->map;
ok(wait_for_map($x), 'parent window mapped');
ok(wait_for_map($window), 'parent window mapped');
#########################################################################
# Switch to a different workspace and open a child window. It should be opened
@ -78,11 +71,11 @@ ok(wait_for_map($x), 'parent window mapped');
#########################################################################
fresh_workspace;
my $child = open_window($x, { dont_map => 1, name => 'Child window' });
my $child = open_window({ dont_map => 1, name => 'Child window' });
$child->client_leader($window);
$child->map;
ok(wait_for_map($x), 'child window mapped');
ok(wait_for_map($child), 'child window mapped');
isnt($x->input_focus, $child->id, "Child window focused");

View File

@ -108,12 +108,12 @@ ok(defined($ws), "workspace 3: $tmp was created");
is($ws->{num}, 3, 'workspace number is 3');
cmd "workspace 0: $tmp";
my $ws = get_ws("0: $tmp");
$ws = get_ws("0: $tmp");
ok(defined($ws), "workspace 0: $tmp was created");
is($ws->{num}, 0, 'workspace number is 0');
cmd "workspace aa: $tmp";
my $ws = get_ws("aa: $tmp");
$ws = get_ws("aa: $tmp");
ok(defined($ws), "workspace aa: $tmp was created");
is($ws->{num}, -1, 'workspace number is -1');

View File

@ -4,15 +4,14 @@
# Tests all kinds of matching methods
#
use i3test;
use X11::XCB qw(:all);
use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT);
my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
# Open a new window
my $x = X11::XCB::Connection->new;
my $window = open_window($x);
my $window = open_window;
my $content = get_ws_content($tmp);
ok(@{$content} == 1, 'window mapped');
my $win = $content->[0];
@ -35,7 +34,7 @@ cmd 'nop now killing the window';
my $id = $win->{id};
cmd qq|[con_id="$id"] kill|;
wait_for_unmap $x;
wait_for_unmap $window;
cmd 'nop checking if its gone';
$content = get_ws_content($tmp);
@ -81,7 +80,7 @@ $left->_create;
set_wm_class($left->id, 'special', 'special');
$left->name('left');
$left->map;
ok(wait_for_map($x), 'left window mapped');
ok(wait_for_map($left), 'left window mapped');
my $right = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
@ -94,7 +93,7 @@ $right->_create;
set_wm_class($right->id, 'special', 'special');
$right->name('right');
$right->map;
ok(wait_for_map($x), 'right window mapped');
ok(wait_for_map($right), 'right window mapped');
# two windows should be here
$content = get_ws_content($tmp);
@ -124,7 +123,7 @@ $left->_create;
set_wm_class($left->id, 'special7', 'special7');
$left->name('left');
$left->map;
ok(wait_for_map($x), 'left window mapped');
ok(wait_for_map($left), 'left window mapped');
# two windows should be here
$content = get_ws_content($tmp);
@ -132,7 +131,7 @@ ok(@{$content} == 1, 'window opened');
cmd '[class="^special[0-9]$"] kill';
wait_for_unmap $x;
wait_for_unmap $left;
$content = get_ws_content($tmp);
is(@{$content}, 0, 'window killed');
@ -154,7 +153,7 @@ $left->_create;
set_wm_class($left->id, 'special7', 'special7');
$left->name('ä 3');
$left->map;
ok(wait_for_map($x), 'left window mapped');
ok(wait_for_map($left), 'left window mapped');
# two windows should be here
$content = get_ws_content($tmp);
@ -162,7 +161,7 @@ ok(@{$content} == 1, 'window opened');
cmd '[title="^\w [3]$"] kill';
wait_for_unmap $x;
wait_for_unmap $left;
$content = get_ws_content($tmp);
is(@{$content}, 0, 'window killed');

View File

@ -8,9 +8,7 @@
# 4) move a container in a different direction so that we need to go up in tree
#
use i3test;
use X11::XCB::Connection;
my $x = X11::XCB::Connection->new;
my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;

View File

@ -27,7 +27,7 @@ isnt($first, $second, 'different container focused');
cmd qq|[con_id="$first"] focus|;
cmd 'open';
$content = get_ws_content($tmp);
my $content = get_ws_content($tmp);
ok(@{$content} == 3, 'three containers opened');
is($content->[0]->{id}, $first, 'first container unmodified');

View File

@ -4,11 +4,8 @@
# Check if the focus is correctly restored after closing windows.
#
use i3test;
use X11::XCB qw(:all);
use List::Util qw(first);
my $x = X11::XCB::Connection->new;
my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
@ -102,7 +99,7 @@ $first = open_empty_con($i3);
$middle = open_empty_con($i3);
# XXX: the $right empty con will be filled with the x11 window we are creating afterwards
$right = open_empty_con($i3);
my $win = open_window($x, { background_color => '#00ff00' });
my $win = open_window({ background_color => '#00ff00' });
cmd qq|[con_id="$middle"] focus|;
$win->destroy;

View File

@ -17,7 +17,7 @@ cmd qq|[con_id="$first"] focus|;
cmd 'split v';
($nodes, $focus) = get_ws_content($tmp);
my ($nodes, $focus) = get_ws_content($tmp);
is($nodes->[0]->{focused}, 0, 'split container not focused');
@ -27,7 +27,7 @@ cmd 'level up';
my $split = $focus->[0];
cmd 'level down';
my $second = open_empty_con($i3);
$second = open_empty_con($i3);
isnt($first, $second, 'different container focused');
@ -62,10 +62,10 @@ is($nodes->[0]->{focused}, 0, 'split container not focused');
# focus the split container
cmd 'level up';
($nodes, $focus) = get_ws_content($tmp);
my $split = $focus->[0];
$split = $focus->[0];
cmd 'level down';
my $second = open_empty_con($i3);
$second = open_empty_con($i3);
isnt($first, $second, 'different container focused');

View File

@ -9,7 +9,6 @@ my $i3 = i3(get_socket_path());
# We move the pointer out of our way to avoid a bug where the focus will
# be set to the window under the cursor
my $x = X11::XCB::Connection->new;
$x->root->warp_pointer(0, 0);
my $tmp = get_unused_workspace();

View File

@ -5,13 +5,11 @@
#
use i3test;
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $win = open_window($x, { dont_map => 1 });
my $win = open_window({ dont_map => 1 });
# XXX: we should check screen size. in screens with an AR of 2.0,
# this is not a good idea.
my $aspect = X11::XCB::Sizehints::Aspect->new;
@ -21,7 +19,7 @@ $aspect->max_num(600);
$aspect->max_den(300);
$win->_create;
$win->map;
wait_for_map $x;
wait_for_map $win;
$win->hints->aspect($aspect);
$x->flush;

View File

@ -2,10 +2,6 @@
# vim:ts=4:sw=4:expandtab
use i3test;
use X11::XCB qw(:all);
use X11::XCB::Connection;
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
@ -13,8 +9,8 @@ my $tmp = fresh_workspace;
# 1: see if focus stays the same when toggling tiling/floating mode
#############################################################################
my $first = open_window($x);
my $second = open_window($x);
my $first = open_window;
my $second = open_window;
is($x->input_focus, $second->id, 'second window focused');
@ -30,9 +26,9 @@ is($x->input_focus, $second->id, 'second window still focused after mode toggle'
$tmp = fresh_workspace;
$first = open_window($x); # window 2
$second = open_window($x); # window 3
my $third = open_window($x); # window 4
$first = open_window; # window 2
$second = open_window; # window 3
my $third = open_window; # window 4
is($x->input_focus, $third->id, 'last container focused');
@ -49,7 +45,7 @@ cmd 'floating enable';
# now kill the third one (it's floating). focus should stay unchanged
cmd '[id="' . $third->id . '"] kill';
wait_for_unmap($x);
wait_for_unmap($third);
is($x->input_focus, $second->id, 'second con still focused after killing third');
@ -61,9 +57,9 @@ is($x->input_focus, $second->id, 'second con still focused after killing third')
$tmp = fresh_workspace;
$first = open_window($x, { background_color => '#ff0000' }); # window 5
$second = open_window($x, { background_color => '#00ff00' }); # window 6
my $third = open_window($x, { background_color => '#0000ff' }); # window 7
$first = open_window({ background_color => '#ff0000' }); # window 5
$second = open_window({ background_color => '#00ff00' }); # window 6
$third = open_window({ background_color => '#0000ff' }); # window 7
is($x->input_focus, $third->id, 'last container focused');
@ -80,12 +76,12 @@ cmd 'floating enable';
# now kill the second one. focus should fall back to the third one, which is
# also floating
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($second);
is($x->input_focus, $third->id, 'third con focused');
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($third);
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
@ -95,11 +91,11 @@ is($x->input_focus, $first->id, 'first con focused after killing all floating co
$tmp = fresh_workspace;
$first = open_window($x, { background_color => '#ff0000' }); # window 5
$first = open_window({ background_color => '#ff0000' }); # window 5
cmd 'split v';
cmd 'layout stacked';
$second = open_window($x, { background_color => '#00ff00' }); # window 6
$third = open_window($x, { background_color => '#0000ff' }); # window 7
$second = open_window({ background_color => '#00ff00' }); # window 6
$third = open_window({ background_color => '#0000ff' }); # window 7
is($x->input_focus, $third->id, 'last container focused');
@ -118,12 +114,12 @@ sync_with_i3($x);
# now kill the second one. focus should fall back to the third one, which is
# also floating
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($second);
is($x->input_focus, $third->id, 'third con focused');
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($third);
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
@ -133,8 +129,8 @@ is($x->input_focus, $first->id, 'first con focused after killing all floating co
$tmp = fresh_workspace;
$first = open_window($x, { background_color => '#ff0000' }); # window 8
$second = open_window($x, { background_color => '#00ff00' }); # window 9
$first = open_window({ background_color => '#ff0000' }); # window 8
$second = open_window({ background_color => '#00ff00' }); # window 9
sync_with_i3($x);

View File

@ -3,11 +3,6 @@
# Regression test: when only having a floating window on a workspace, it should not be deleted.
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $i3 = i3(get_socket_path());
@ -19,8 +14,6 @@ my $tmp = fresh_workspace;
ok(workspace_exists($tmp), "workspace $tmp exists");
my $x = X11::XCB::Connection->new;
# Create a floating window which is smaller than the minimum enforced size of i3
my $window = open_floating_window($x);
ok($window->mapped, 'Window is mapped');

View File

@ -4,11 +4,6 @@
# to a different workspace.
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $i3 = i3(get_socket_path());
@ -18,8 +13,6 @@ my $tmp = fresh_workspace;
# 1: open a floating window, get it mapped
#############################################################################
my $x = X11::XCB::Connection->new;
# Create a floating window which is smaller than the minimum enforced size of i3
my $window = open_floating_window($x);
ok($window->mapped, 'Window is mapped');

View File

@ -4,11 +4,6 @@
# if only a floating window is present on the workspace.
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $i3 = i3(get_socket_path());
@ -18,8 +13,6 @@ my $tmp = fresh_workspace;
# 1: open a floating window, get it mapped
#############################################################################
my $x = X11::XCB::Connection->new;
# Create a floating window
my $window = open_floating_window($x);
ok($window->mapped, 'Window is mapped');
@ -31,7 +24,7 @@ is(@{$ws->{floating_nodes}}, 1, 'one floating node');
is(@{$nodes}, 0, 'no tiling nodes');
# Create a tiling window
my $twindow = open_window($x);
my $twindow = open_window;
($nodes, $focus) = get_ws_content($tmp);
@ -44,8 +37,8 @@ is(@{$nodes}, 1, 'one tiling node');
$tmp = fresh_workspace;
my $first = open_window($x);
my $second = open_window($x);
my $first = open_window;
my $second = open_window;
cmd 'layout stacked';
@ -54,14 +47,14 @@ is(@{$ws->{floating_nodes}}, 0, 'no floating nodes so far');
is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
# Create a floating window
my $window = open_floating_window($x);
$window = open_floating_window($x);
ok($window->mapped, 'Window is mapped');
$ws = get_ws($tmp);
is(@{$ws->{floating_nodes}}, 1, 'one floating nodes');
is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
my $third = open_window($x);
my $third = open_window;
$ws = get_ws($tmp);

View File

@ -3,14 +3,8 @@
# Check if numbered workspaces and named workspaces are sorted in the right way
# in get_workspaces IPC output (necessary for i3bar etc.).
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $i3 = i3(get_socket_path());
my $x = X11::XCB::Connection->new;
sub check_order {
my ($msg) = @_;
@ -30,7 +24,7 @@ check_order('workspace order alright before testing');
cmd "workspace 93";
open_window($x);
open_window;
my @ws = @{$i3->get_workspaces->recv};
my @f = grep { defined($_->{num}) && $_->{num} == 93 } @ws;
@ -38,23 +32,23 @@ is(@f, 1, 'ws 93 found by num');
check_order('workspace order alright after opening 93');
cmd "workspace 92";
open_window($x);
open_window;
check_order('workspace order alright after opening 92');
cmd "workspace 94";
open_window($x);
open_window;
check_order('workspace order alright after opening 94');
cmd "workspace 96";
open_window($x);
open_window;
check_order('workspace order alright after opening 96');
cmd "workspace foo";
open_window($x);
open_window;
check_order('workspace order alright after opening foo');
cmd "workspace 91";
open_window($x);
open_window;
check_order('workspace order alright after opening 91');
done_testing;

View File

@ -3,14 +3,8 @@
# Regression: Check if the focus stays the same when switching the layout
# bug introduced by 77d0d42ed2d7ac8cafe267c92b35a81c1b9491eb
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $i3 = i3(get_socket_path());
my $x = X11::XCB::Connection->new;
sub check_order {
my ($msg) = @_;
@ -24,9 +18,9 @@ sub check_order {
my $tmp = fresh_workspace;
my $left = open_window($x);
my $mid = open_window($x);
my $right = open_window($x);
my $left = open_window;
my $mid = open_window;
my $right = open_window;
sync_with_i3($x);

View File

@ -2,20 +2,13 @@
# vim:ts=4:sw=4:expandtab
# Tests resizing tiling containers
use i3test;
use X11::XCB qw(:all);
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
cmd 'split v';
my $top = open_window($x);
my $bottom = open_window($x);
my $top = open_window;
my $bottom = open_window;
sync_with_i3($x);
@ -54,8 +47,8 @@ $tmp = fresh_workspace;
cmd 'split v';
$top = open_window($x);
$bottom = open_window($x);
$top = open_window;
$bottom = open_window;
cmd 'split h';
cmd 'layout stacked';
@ -76,7 +69,7 @@ is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
$tmp = fresh_workspace;
$top = open_window($x);
$top = open_window;
cmd 'floating enable';

View File

@ -8,17 +8,13 @@
#
use i3test;
use List::Util qw(sum);
use X11::XCB::Connection;
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
cmd 'exec /usr/bin/urxvt';
wait_for_map $x;
sleep 0.5;
cmd 'exec /usr/bin/urxvt';
wait_for_map $x;
sleep 0.5;
my ($nodes, $focus) = get_ws_content($tmp);
my $old_sum = sum map { $_->{rect}->{width} } @{$nodes};
#cmd 'open';
@ -26,13 +22,12 @@ cmd 'resize grow left 10 px or 25 ppt';
cmd 'split v';
#cmd 'open';
cmd 'exec /usr/bin/urxvt';
wait_for_map $x;
sleep 0.5;
cmd 'mode toggle';
sync_with_i3 $x;
sleep 0.5;
cmd 'kill';
wait_for_unmap $x;
sleep 0.5;
($nodes, $focus) = get_ws_content($tmp);
my $new_sum = sum map { $_->{rect}->{width} } @{$nodes};

View File

@ -10,16 +10,13 @@
#
# This testcase checks that the tree is properly flattened after moving.
#
use X11::XCB qw(:all);
use i3test;
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
my $left = open_window($x);
my $mid = open_window($x);
my $right = open_window($x);
my $left = open_window;
my $mid = open_window;
my $right = open_window;
cmd 'move up';
cmd 'move right';

View File

@ -1,22 +1,15 @@
#!perl
# vim:ts=4:sw=4:expandtab
#
use X11::XCB qw(:all);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
my $left = open_window($x);
my $mid = open_window($x);
my $left = open_window;
my $mid = open_window;
cmd 'split v';
my $bottom = open_window($x);
my $bottom = open_window;
my ($nodes, $focus) = get_ws_content($tmp);
@ -37,7 +30,7 @@ is(@{$nodes->[1]->{nodes}}, 2, 'two windows in split con');
cmd 'floating toggle';
my ($nodes, $focus) = get_ws_content($tmp);
($nodes, $focus) = get_ws_content($tmp);
is(@{$nodes->[1]->{nodes}}, 3, 'three windows in split con after floating toggle');

View File

@ -4,21 +4,13 @@
# Regression test for moving a con outside of a floating con when there are no
# tiling cons on a workspace
#
use X11::XCB qw(:all);
use Time::HiRes qw(sleep);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
my $left = open_window($x);
my $mid = open_window($x);
my $right = open_window($x);
my $left = open_window;
my $mid = open_window;
my $right = open_window;
# go to workspace level
cmd 'level up';

View File

@ -4,25 +4,18 @@
# Regression test for correct focus behaviour when moving a floating con to
# another workspace.
#
use X11::XCB qw(:all);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
# open a tiling window on the first workspace
open_window($x);
open_window;
#sleep 0.25;
my $first = get_focused($tmp);
# on a different ws, open a floating window
my $otmp = fresh_workspace;
open_window($x);
open_window;
#sleep 0.25;
my $float = get_focused($otmp);
cmd 'mode toggle';

View File

@ -3,15 +3,8 @@
#
# Regression test for inplace restarting with dock clients
#
use X11::XCB qw(:all);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
#####################################################################
@ -25,7 +18,7 @@ is(@docked, 0, 'no dock clients yet');
# open a dock client
my $window = open_window($x, {
my $window = open_window({
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
@ -62,7 +55,7 @@ is($docknode->{rect}->{height}, 30, 'dock node has unchanged height after restar
$window->destroy;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients;
is(@docked, 0, 'no dock clients found');
@ -71,7 +64,7 @@ is(@docked, 0, 'no dock clients found');
# create a dock client with a 1px border
#####################################################################
$window = open_window($x, {
$window = open_window({
border => 1,
rect => [ 0, 0, 30, 20 ],
background_color => '#00FF00',

View File

@ -3,15 +3,12 @@
#
# Test if the requested width/height is set after making the window floating.
#
use X11::XCB qw(:all);
use i3test;
my $tmp = fresh_workspace;
my $x = X11::XCB::Connection->new;
# Create a floating window which is smaller than the minimum enforced size of i3
my $window = open_window($x, { rect => [ 0, 0, 400, 150 ] });
my $window = open_window({ rect => [ 0, 0, 400, 150 ] });
my ($absolute, $top) = $window->rect;

View File

@ -3,15 +3,8 @@
#
# Regression test for closing one of multiple dock clients
#
use X11::XCB qw(:all);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
#####################################################################
@ -27,7 +20,7 @@ is(@docked, 0, 'no dock clients yet');
# open a dock client
#####################################################################
my $first = open_window($x, {
my $first = open_window({
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
@ -36,7 +29,7 @@ my $first = open_window($x, {
# Open a second dock client
#####################################################################
my $second = open_window($x, {
my $second = open_window({
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});

View File

@ -4,22 +4,15 @@
# Test to see if i3 combines the geometry of all children in a split container
# when setting the split container to floating
#
use X11::XCB qw(:all);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
#####################################################################
# open a window with 200x80
#####################################################################
my $first = open_window($x, {
my $first = open_window({
rect => [ 0, 0, 200, 80],
background_color => '#FF0000',
});
@ -28,7 +21,7 @@ my $first = open_window($x, {
# Open a second window with 300x90
#####################################################################
my $second = open_window($x, {
my $second = open_window({
rect => [ 0, 0, 300, 90],
background_color => '#00FF00',
});

View File

@ -4,14 +4,8 @@
# Test if new containers get focused when there is a fullscreen container at
# the time of launching the new one.
#
use X11::XCB qw(:all);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
@ -20,7 +14,7 @@ my $tmp = fresh_workspace;
# open the left window
#####################################################################
my $left = open_window($x, { background_color => '#ff0000' });
my $left = open_window({ background_color => '#ff0000' });
is($x->input_focus, $left->id, 'left window focused');
@ -30,7 +24,7 @@ diag("left = " . $left->id);
# Open the right window
#####################################################################
my $right = open_window($x, { background_color => '#00ff00' });
my $right = open_window({ background_color => '#00ff00' });
diag("right = " . $right->id);
@ -44,7 +38,7 @@ cmd 'fullscreen';
# Open a third window
#####################################################################
my $third = open_window($x, {
my $third = open_window({
background_color => '#0000ff',
name => 'Third window',
dont_map => 1,

View File

@ -3,22 +3,15 @@
#
# Regression test: level up should be a noop during fullscreen mode
#
use X11::XCB qw(:all);
use i3test;
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $tmp = fresh_workspace;
#####################################################################
# open a window, verify its not in fullscreen mode
#####################################################################
my $win = open_window($x);
my $win = open_window;
my $nodes = get_ws_content $tmp;
is(@$nodes, 1, 'exactly one client');
@ -31,7 +24,7 @@ is($nodes->[0]->{fullscreen_mode}, 0, 'client not fullscreen');
cmd 'nop making fullscreen';
cmd 'fullscreen';
my $nodes = get_ws_content $tmp;
$nodes = get_ws_content $tmp;
is($nodes->[0]->{fullscreen_mode}, 1, 'client fullscreen now');
#####################################################################
@ -40,7 +33,7 @@ is($nodes->[0]->{fullscreen_mode}, 1, 'client fullscreen now');
cmd 'level up';
cmd 'fullscreen';
my $nodes = get_ws_content $tmp;
$nodes = get_ws_content $tmp;
is($nodes->[0]->{fullscreen_mode}, 0, 'client not fullscreen any longer');
does_i3_live;

View File

@ -3,18 +3,14 @@
#
# Tests if the WM_TAKE_FOCUS protocol is correctly handled by i3
#
use X11::XCB qw(:all);
use i3test;
use v5.10;
my $x = X11::XCB::Connection->new;
subtest 'Window without WM_TAKE_FOCUS', sub {
fresh_workspace;
my $window = open_window($x);
my $window = open_window;
ok(!wait_for_event($x, 1, sub { $_[0]->{response_type} == 161 }), 'did not receive ClientMessage');
ok(!wait_for_event(1, sub { $_[0]->{response_type} == 161 }), 'did not receive ClientMessage');
done_testing;
};
@ -24,14 +20,14 @@ subtest 'Window with WM_TAKE_FOCUS', sub {
my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS');
my $window = open_window($x, {
my $window = open_window({
dont_map => 1,
protocols => [ $take_focus ],
});
$window->map;
ok(wait_for_event($x, 1, sub {
ok(wait_for_event(1, sub {
return 0 unless $_[0]->{response_type} == 161;
my ($data, $time) = unpack("L2", $_[0]->{data});
return ($data == $take_focus->id);

View File

@ -5,14 +5,12 @@
# restart.
# found in eb8ad348b28e243cba1972e802ca8ee636472fc9
#
use X11::XCB qw(:all);
use List::Util qw(first);
use i3test;
my $x = X11::XCB::Connection->new;
my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
my $window = open_window($x);
my $window = open_window;
sub get_border_style {
my @content = @{get_ws_content($tmp)};

View File

@ -4,14 +4,9 @@
# Regression test for setting the urgent hint on dock clients.
# found in 4be3178d4d360c2996217d811e61161c84d25898
#
use X11::XCB qw(:all);
use i3test;
use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT';
BEGIN {
use_ok('X11::XCB::Window');
}
my $x = X11::XCB::Connection->new;
my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;

View File

@ -4,12 +4,10 @@
# Tests if WM_STATE is WM_STATE_NORMAL when mapped and WM_STATE_WITHDRAWN when
# unmapped.
#
use X11::XCB qw(:all);
use i3test;
use X11::XCB qw(ICCCM_WM_STATE_NORMAL ICCCM_WM_STATE_WITHDRAWN);
my $x = X11::XCB::Connection->new;
my $window = open_window($x);
my $window = open_window;
sync_with_i3($x);
@ -17,7 +15,7 @@ is($window->state, ICCCM_WM_STATE_NORMAL, 'WM_STATE normal');
$window->unmap;
wait_for_unmap $x;
wait_for_unmap $window;
is($window->state, ICCCM_WM_STATE_WITHDRAWN, 'WM_STATE withdrawn');

View File

@ -6,15 +6,13 @@
#
use i3test;
my $x = X11::XCB::Connection->new;
sub two_windows {
my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $first = open_window($x);
my $second = open_window($x);
my $first = open_window;
my $second = open_window;
sync_with_i3 $x;
@ -42,7 +40,7 @@ ok(@{get_ws_content($tmp)} == 1, 'one container left after killing');
# 'kill window'
##############################################################
my $tmp = two_windows;
$tmp = two_windows;
cmd 'kill window';
@ -55,7 +53,7 @@ ok(@{get_ws_content($tmp)} == 1, 'one container left after killing');
# and check if both are gone
##############################################################
my $tmp = two_windows;
$tmp = two_windows;
cmd 'kill client';

View File

@ -3,11 +3,8 @@
# !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
#
#
use X11::XCB qw(:all);
use X11::XCB::Connection;
use i3test;
my $x = X11::XCB::Connection->new;
use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT);
##############################################################
# 1: test the following directive:
@ -37,16 +34,16 @@ my $window = $x->root->create_child(
$window->name('Border window');
$window->map;
wait_for_map $x;
wait_for_map $window;
my @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'normal border');
$window->unmap;
wait_for_unmap $x;
wait_for_unmap $window;
my @content = @{get_ws_content($tmp)};
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
diag('content = '. Dumper(\@content));
@ -81,14 +78,14 @@ sub set_wm_class {
set_wm_class($window->id, 'borderless', 'borderless');
$window->name('Borderless window');
$window->map;
wait_for_map $x;
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->unmap;
wait_for_unmap $x;
wait_for_unmap $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
@ -120,7 +117,7 @@ $window = $x->root->create_child(
$window->name('special title');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -147,7 +144,7 @@ sync_with_i3 $x;
is($content[0]->{border}, 'normal', 'still normal border');
$window->unmap;
wait_for_unmap $x;
wait_for_unmap $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
@ -180,13 +177,13 @@ $window = $x->root->create_child(
$window->name('special mark title');
$window->map;
wait_for_map $x;
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');
my $other = open_window($x);
my $other = open_window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 2, 'two nodes');
@ -227,14 +224,14 @@ $window->_create;
set_wm_class($window->id, 'borderless', 'borderless');
$window->name('usethis');
$window->map;
wait_for_map $x;
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');
cmd 'kill';
wait_for_unmap $x;
wait_for_unmap $window;
$window->destroy;
# give i3 a chance to delete the window from its tree
@ -248,7 +245,7 @@ $window->_create;
set_wm_class($window->id, 'borderless', 'borderless');
$window->name('notthis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -283,7 +280,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -318,7 +315,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -355,7 +352,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -403,7 +400,7 @@ $x->change_property(
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -440,7 +437,7 @@ $window->_create;
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');

View File

@ -5,11 +5,7 @@
# Tests if assignments work
#
use i3test;
use X11::XCB qw(:all);
use X11::XCB::Connection;
use v5.10;
my $x = X11::XCB::Connection->new;
use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT);
# TODO: move to X11::XCB
sub set_wm_class {
@ -57,7 +53,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace');
@ -84,7 +80,7 @@ ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $workspaces = get_workspace_names;
ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
my $window = $x->root->create_child(
$window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30 ],
background_color => '#0000ff',
@ -95,7 +91,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
ok(@{get_ws_content($tmp)} == 0, 'still no containers');
ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists');
@ -124,7 +120,7 @@ $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
ok("targetws" ~~ @{get_workspace_names()}, 'targetws does not exist yet');
my $window = $x->root->create_child(
$window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30 ],
background_color => '#0000ff',
@ -162,10 +158,10 @@ $pid = launch_with_config($config);
$tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $workspaces = get_workspace_names;
$workspaces = get_workspace_names;
ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
my $window = $x->root->create_child(
$window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30 ],
background_color => '#0000ff',
@ -176,7 +172,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
my $content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');
@ -203,10 +199,10 @@ $pid = launch_with_config($config);
$tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $workspaces = get_workspace_names;
$workspaces = get_workspace_names;
ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
my $window = $x->root->create_child(
$window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30 ],
background_color => '#0000ff',
@ -217,9 +213,9 @@ $window->_create;
set_wm_class($window->id, 'SPEcial', 'SPEcial');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
my $content = get_ws($tmp);
$content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');
ok(@{$content->{floating_nodes}} == 1, 'one floating con');
@ -255,7 +251,7 @@ my @docked = get_dock_clients;
# syntax
is(@docked, 1, 'one dock client yet');
my $window = $x->root->create_child(
$window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30 ],
background_color => '#0000ff',
@ -267,9 +263,9 @@ $window->_create;
set_wm_class($window->id, 'special', 'special');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
my $content = get_ws($tmp);
$content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');
ok(@{$content->{floating_nodes}} == 0, 'one floating con');
@docked = get_dock_clients;

View File

@ -6,10 +6,6 @@
#
use i3test;
use X11::XCB qw(:all);
use X11::XCB::Connection;
my $x = X11::XCB::Connection->new;
#####################################################################
# 1: check that with an empty config, cons are place next to each
@ -27,13 +23,14 @@ my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $first = open_window($x);
my $second = open_window($x);
my $first = open_window;
my $second = open_window;
sync_with_i3($x);
is($x->input_focus, $second->id, 'second window focused');
ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
my @content = @{get_ws_content($tmp)};
ok(@content == 2, 'two containers opened');
isnt($content[0]->{layout}, 'stacked', 'layout not stacked');
isnt($content[1]->{layout}, 'stacked', 'layout not stacked');
@ -56,13 +53,13 @@ $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
$first = open_window($x);
$second = open_window($x);
$first = open_window;
$second = open_window;
sync_with_i3($x);
is($x->input_focus, $second->id, 'second window focused');
my @content = @{get_ws_content($tmp)};
@content = @{get_ws_content($tmp)};
ok(@content == 1, 'one con at workspace level');
is($content[0]->{layout}, 'stacked', 'layout stacked');
@ -72,8 +69,8 @@ is($content[0]->{layout}, 'stacked', 'layout stacked');
#####################################################################
cmd 'focus parent';
my $right_top = open_window($x);
my $right_bot = open_window($x);
my $right_top = open_window;
my $right_bot = open_window;
@content = @{get_ws_content($tmp)};
is(@content, 2, 'two cons at workspace level after focus parent');

View File

@ -4,15 +4,11 @@
# Verifies that i3 survives inplace restarts with fullscreen containers
#
use i3test;
use X11::XCB qw(:all);
use X11::XCB::Connection;
my $x = X11::XCB::Connection->new;
fresh_workspace;
open_window($x);
open_window($x);
open_window;
open_window;
cmd 'layout stacking';
sleep 1;

View File

@ -6,20 +6,6 @@
#
use i3test;
{
package i3test::X11;
use parent 'X11::XCB::Connection';
sub input_focus {
my $self = shift;
i3test::sync_with_i3($self);
return $self->SUPER::input_focus(@_);
}
}
my $x = i3test::X11->new;
#####################################################################
# 1: test the wrapping behaviour without force_focus_wrapping
#####################################################################
@ -35,13 +21,13 @@ my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $first = open_window($x);
my $second = open_window($x);
my $first = open_window;
my $second = open_window;
cmd 'layout tabbed';
cmd 'focus parent';
my $third = open_window($x);
my $third = open_window;
is($x->input_focus, $third->id, 'third window focused');
cmd 'focus left';
@ -76,13 +62,13 @@ $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
$first = open_window($x);
$second = open_window($x);
$first = open_window;
$second = open_window;
cmd 'layout tabbed';
cmd 'focus parent';
$third = open_window($x);
$third = open_window;
sync_with_i3($x);

View File

@ -4,12 +4,8 @@
#
# checks if i3 starts up on workspace '1' or the first configured named workspace
#
use X11::XCB qw(:all);
use X11::XCB::Connection;
use i3test;
my $x = X11::XCB::Connection->new;
##############################################################
# 1: i3 should start with workspace '1'
##############################################################
@ -39,7 +35,7 @@ EOT
$pid = launch_with_config($config);
my @names = @{get_workspace_names()};
@names = @{get_workspace_names()};
cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar');
exit_gracefully($pid);
@ -57,7 +53,7 @@ EOT
$pid = launch_with_config($config);
my @names = @{get_workspace_names()};
@names = @{get_workspace_names()};
cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar');
exit_gracefully($pid);

View File

@ -6,11 +6,7 @@
# assigned to an invisible workspace
#
use i3test;
use X11::XCB qw(:all);
use X11::XCB::Connection;
use v5.10;
my $x = X11::XCB::Connection->new;
use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT);
# TODO: move to X11::XCB
sub set_wm_class {

View File

@ -7,8 +7,6 @@
use i3test;
my $x = X11::XCB::Connection->new;
#####################################################################
# 1: check that new windows start with 'normal' border unless configured
# otherwise
@ -25,7 +23,7 @@ my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $first = open_window($x);
my $first = open_window;
my @content = @{get_ws_content($tmp)};
ok(@content == 1, 'one container opened');
@ -51,7 +49,7 @@ $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
$first = open_window($x);
$first = open_window;
@content = @{get_ws_content($tmp)};
ok(@content == 1, 'one container opened');

View File

@ -8,7 +8,6 @@ use i3test;
use POSIX qw(mkfifo);
use File::Temp qw(:POSIX);
my $x = X11::XCB::Connection->new;
use ExtUtils::PkgConfig;
# setup dependency on libstartup-notification using pkg-config
@ -98,7 +97,7 @@ my $second_ws = fresh_workspace;
is(@{get_ws_content($second_ws)}, 0, 'no containers on the second workspace yet');
my $win = open_window($x, { dont_map => 1 });
my $win = open_window({ dont_map => 1 });
mark_window($win->id);
$win->map;
# We dont use wait_for_map because the window will not get mapped -- it is on
@ -113,10 +112,10 @@ is(@{get_ws_content($first_ws)}, 1, 'one container on the first workspace');
# same thing, but with _NET_STARTUP_ID set on the leader
######################################################################
my $leader = open_window($x, { dont_map => 1 });
my $leader = open_window({ dont_map => 1 });
mark_window($leader->id);
$win = open_window($x, { dont_map => 1, client_leader => $leader });
$win = open_window({ dont_map => 1, client_leader => $leader });
$win->map;
sync_with_i3($x);
@ -131,7 +130,7 @@ is(@{get_ws_content($first_ws)}, 2, 'two containers on the first workspace');
complete_startup();
sync_with_i3($x);
my $otherwin = open_window($x);
my $otherwin = open_window;
is(@{get_ws_content($second_ws)}, 1, 'one container on the second workspace');
######################################################################

View File

@ -7,9 +7,6 @@
#
use i3test;
use X11::XCB::Connection;
my $x = X11::XCB::Connection->new;
my $config = <<EOT;
# i3 config file (v4)