tests: clean up/beautify all tests (code style / test style)

This commit is contained in:
Michael Stapelberg
2011-03-09 20:25:17 +01:00
parent 57e7cc8f6a
commit 2524b5262d
53 changed files with 334 additions and 415 deletions

View File

@ -1,9 +1,8 @@
#!perl
# vim:ts=4:sw=4:expandtab
use i3test tests => 10;
use i3test;
use X11::XCB qw(:all);
use Time::HiRes qw(sleep);
use List::Util qw(first);
BEGIN {
@ -12,23 +11,21 @@ BEGIN {
my $x = X11::XCB::Connection->new;
my $i3 = i3("/tmp/nestedcons");
my $tmp = get_unused_workspace();
$i3->command("workspace $tmp")->recv;
my $tmp = fresh_workspace;
#####################################################################
# Create two windows and put them in stacking mode
#####################################################################
$i3->command('split v')->recv;
cmd 'split v';
my $top = i3test::open_standard_window($x);
my $bottom = i3test::open_standard_window($x);
my $top = open_standard_window($x);
my $bottom = open_standard_window($x);
my @urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
is(@urgent, 0, 'no window got the urgent flag');
#$i3->command('layout stacking')->recv;
# cmd 'layout stacking';
#####################################################################
# Add the urgency hint, switch to a different workspace and back again
@ -45,7 +42,7 @@ is($top_info->{urgent}, 1, 'top window is marked urgent');
is($bottom_info->{urgent}, 0, 'bottom window is not marked urgent');
is(@urgent, 1, 'exactly one window got the urgent flag');
$i3->command('[id="' . $top->id . '"] focus')->recv;
cmd '[id="' . $top->id . '"] focus';
@urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
is(@urgent, 0, 'no window got the urgent flag after focusing');
@ -62,8 +59,7 @@ is(@urgent, 0, 'no window got the urgent flag after re-setting urgency hint');
my $ws = get_ws($tmp);
is($ws->{urgent}, 0, 'urgent flag not set on workspace');
my $otmp = get_unused_workspace();
$i3->command("workspace $otmp")->recv;
my $otmp = fresh_workspace;
$top->add_hint('urgency');
sleep 0.5;
@ -71,9 +67,9 @@ sleep 0.5;
$ws = get_ws($tmp);
is($ws->{urgent}, 1, 'urgent flag set on workspace');
$i3->command("workspace $tmp")->recv;
cmd "workspace $tmp";
$ws = get_ws($tmp);
is($ws->{urgent}, 0, 'urgent flag not set on workspace after switching');
diag( "Testing i3, Perl $], $^X" );
done_testing;