tests: introduce is_num_children test

This makes it clearer what the tests are actually doing and kills quite
a bit of useless repetitions
This commit is contained in:
Michael Stapelberg
2012-09-04 22:24:13 +02:00
parent 65e5bcfdf4
commit 232d6ccce9
11 changed files with 123 additions and 90 deletions

View File

@ -58,7 +58,7 @@ END_OF_C_CODE
my $first_ws = fresh_workspace;
is(@{get_ws_content($first_ws)}, 0, 'no containers on this workspace yet');
is_num_children($first_ws, 0, 'no containers on this workspace yet');
######################################################################
# 1) initiate startup, switch workspace, create window
@ -95,7 +95,7 @@ is(get_startup_id(), $startup_id, 'libstartup-notification returns the same id')
my $second_ws = fresh_workspace;
is(@{get_ws_content($second_ws)}, 0, 'no containers on the second workspace yet');
is_num_children($second_ws, 0, 'no containers on the second workspace yet');
my $win = open_window({ dont_map => 1 });
mark_window($win->id);
@ -105,8 +105,8 @@ $win->map;
# We sync with i3 here to make sure $x->input_focus is updated.
sync_with_i3;
is(@{get_ws_content($second_ws)}, 0, 'still no containers on the second workspace');
is(@{get_ws_content($first_ws)}, 1, 'one container on the first workspace');
is_num_children($second_ws, 0, 'still no containers on the second workspace');
is_num_children($first_ws, 1, 'one container on the first workspace');
######################################################################
# same thing, but with _NET_STARTUP_ID set on the leader
@ -119,8 +119,8 @@ $win = open_window({ dont_map => 1, client_leader => $leader });
$win->map;
sync_with_i3;
is(@{get_ws_content($second_ws)}, 0, 'still no containers on the second workspace');
is(@{get_ws_content($first_ws)}, 2, 'two containers on the first workspace');
is_num_children($second_ws, 0, 'still no containers on the second workspace');
is_num_children($first_ws, 2, 'two containers on the first workspace');
######################################################################
# 2) open another window after the startup process is completed
@ -131,7 +131,7 @@ complete_startup();
sync_with_i3;
my $otherwin = open_window;
is(@{get_ws_content($second_ws)}, 1, 'one container on the second workspace');
is_num_children($second_ws, 1, 'one container on the second workspace');
######################################################################
# 3) test that the --no-startup-id flag for exec leads to no DESKTOP_STARTUP_ID
@ -166,5 +166,4 @@ unlink($tmp);
is($startup_id, '', 'startup_id empty');
done_testing;