tests: clean up/beautify all tests (code style / test style)
This commit is contained in:
@ -7,13 +7,11 @@
|
||||
# 3) move a container inside another container
|
||||
# 4) move a container in a different direction so that we need to go up in tree
|
||||
#
|
||||
use i3test tests => 16;
|
||||
use X11::XCB qw(:all);
|
||||
use i3test;
|
||||
|
||||
my $i3 = i3("/tmp/nestedcons");
|
||||
|
||||
my $tmp = get_unused_workspace();
|
||||
cmd "workspace $tmp";
|
||||
my $tmp = fresh_workspace;
|
||||
|
||||
######################################################################
|
||||
# 1) move a container which cannot be moved
|
||||
@ -26,10 +24,10 @@ is(@{$old_content}, 1, 'one container on this workspace');
|
||||
|
||||
my $first = $old_content->[0]->{id};
|
||||
|
||||
#$i3->command('move before h')->recv;
|
||||
#$i3->command('move before v')->recv;
|
||||
#$i3->command('move after v')->recv;
|
||||
#$i3->command('move after h')->recv;
|
||||
#cmd 'move before h';
|
||||
#cmd 'move before v';
|
||||
#cmd 'move after v';
|
||||
#cmd 'move after h';
|
||||
|
||||
my $content = get_ws_content($tmp);
|
||||
#is_deeply($old_content, $content, 'workspace unmodified after useless moves');
|
||||
@ -38,7 +36,7 @@ my $content = get_ws_content($tmp);
|
||||
# 2) move a container before another single container
|
||||
######################################################################
|
||||
|
||||
$i3->command('open')->recv;
|
||||
cmd 'open';
|
||||
$content = get_ws_content($tmp);
|
||||
is(@{$content}, 2, 'two containers on this workspace');
|
||||
my $second = $content->[1]->{id};
|
||||
@ -46,22 +44,22 @@ my $second = $content->[1]->{id};
|
||||
is($content->[0]->{id}, $first, 'first container unmodified');
|
||||
|
||||
# Move the second container before the first one (→ swap them)
|
||||
$i3->command('move left')->recv;
|
||||
cmd 'move left';
|
||||
$content = get_ws_content($tmp);
|
||||
is($content->[0]->{id}, $second, 'first container modified');
|
||||
|
||||
# We should not be able to move any further
|
||||
$i3->command('move left')->recv;
|
||||
cmd 'move left';
|
||||
$content = get_ws_content($tmp);
|
||||
is($content->[0]->{id}, $second, 'first container unmodified');
|
||||
|
||||
# Now move in the other direction
|
||||
$i3->command('move right')->recv;
|
||||
cmd 'move right';
|
||||
$content = get_ws_content($tmp);
|
||||
is($content->[0]->{id}, $first, 'first container modified');
|
||||
|
||||
# We should not be able to move any further
|
||||
$i3->command('move right')->recv;
|
||||
cmd 'move right';
|
||||
$content = get_ws_content($tmp);
|
||||
is($content->[0]->{id}, $first, 'first container unmodified');
|
||||
|
||||
@ -76,15 +74,15 @@ is($content->[0]->{id}, $first, 'first container unmodified');
|
||||
# | first | ------ | third |
|
||||
# | | | |
|
||||
# --------------------------
|
||||
$i3->command('split v')->recv;
|
||||
$i3->command('level up')->recv;
|
||||
$i3->command('open')->recv;
|
||||
cmd 'split v';
|
||||
cmd 'level up';
|
||||
cmd 'open';
|
||||
|
||||
$content = get_ws_content($tmp);
|
||||
is(@{$content}, 3, 'three containers on this workspace');
|
||||
my $third = $content->[2]->{id};
|
||||
|
||||
$i3->command('move left')->recv;
|
||||
cmd 'move left';
|
||||
$content = get_ws_content($tmp);
|
||||
is(@{$content}, 2, 'only two containers on this workspace');
|
||||
my $nodes = $content->[1]->{nodes};
|
||||
@ -95,19 +93,19 @@ is($nodes->[1]->{id}, $third, 'third container on bottom');
|
||||
# move it inside the split container
|
||||
######################################################################
|
||||
|
||||
$i3->command('move up')->recv;
|
||||
cmd 'move up';
|
||||
$nodes = get_ws_content($tmp)->[1]->{nodes};
|
||||
is($nodes->[0]->{id}, $third, 'third container on top');
|
||||
is($nodes->[1]->{id}, $second, 'second container on bottom');
|
||||
|
||||
# move it outside again
|
||||
$i3->command('move left')->recv;
|
||||
cmd 'move left';
|
||||
$content = get_ws_content($tmp);
|
||||
is(@{$content}, 3, 'three nodes on this workspace');
|
||||
|
||||
# due to automatic flattening/cleanup, the remaining split container
|
||||
# will be replaced by the con itself, so we will still have 3 nodes
|
||||
$i3->command('move right')->recv;
|
||||
cmd 'move right';
|
||||
$content = get_ws_content($tmp);
|
||||
is(@{$content}, 2, 'two nodes on this workspace');
|
||||
|
||||
@ -117,21 +115,20 @@ is(@{$content}, 2, 'two nodes on this workspace');
|
||||
# container needs to be closed. Verify that it will be closed.
|
||||
######################################################################
|
||||
|
||||
my $otmp = get_unused_workspace();
|
||||
cmd "workspace $otmp";
|
||||
my $otmp = fresh_workspace;
|
||||
|
||||
$i3->command("open")->recv;
|
||||
$i3->command("open")->recv;
|
||||
$i3->command("split v")->recv;
|
||||
$i3->command("open")->recv;
|
||||
$i3->command("prev h")->recv;
|
||||
$i3->command("split v")->recv;
|
||||
$i3->command("open")->recv;
|
||||
$i3->command("move right")->recv;
|
||||
$i3->command("prev h")->recv;
|
||||
$i3->command("move right")->recv;
|
||||
cmd "open";
|
||||
cmd "open";
|
||||
cmd "split v";
|
||||
cmd "open";
|
||||
cmd "prev h";
|
||||
cmd "split v";
|
||||
cmd "open";
|
||||
cmd "move right";
|
||||
cmd "prev h";
|
||||
cmd "move right";
|
||||
|
||||
$content = get_ws_content($otmp);
|
||||
is(@{$content}, 1, 'only one nodes on this workspace');
|
||||
|
||||
diag( "Testing i3, Perl $], $^X" );
|
||||
done_testing;
|
||||
|
Reference in New Issue
Block a user