i3 - improved tiling WM


Refactor and improve test 514

Patch status: merged

Patch by Tony Crisci

Long description:

Split test 514's assertion into three assertions to make it more
explicit what is being tested, and why a run might fail.

Move critical test code out of the event handler to clarify flow and
allow a query of the actual current workspace to use in assertions.

Works around an issue which caused this test to fail spurriously because
of pointer-related quirks in the i3 test suite which would sometimes
cause i3 to open on workspace 2 (However, the test is now agnostic to
the initial workspace or output).

To apply this patch, use:
curl http://cr.i3wm.org/patch/340/raw.patch | git am

b/testcases/t/514-ipc-workspace-multi-monitor.t

23
@@ -19,6 +19,10 @@
24
 
25
 use i3test i3_autostart => 0;
26
 
27
+# Ensure the pointer is at (0, 0) so that we really start on the first
28
+# (the left) workspace.
29
+$x->root->warp_pointer(0, 0);
30
+
31
 my $config = <<EOT;
32
 # i3 config file (v4)
33
 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
34
@@ -35,7 +39,7 @@ $i3->connect()->recv;
35
 # Workspaces requests and events
36
 ################################
37
 
38
-my $focused = get_ws(focused_ws());
39
+my $old_ws = get_ws(focused_ws);
40
 
41
 # Events
42
 
43
@@ -46,17 +50,11 @@ $i3->subscribe({
44
     workspace => sub {
45
         my ($event) = @_;
46
         if ($event->{change} eq 'focus') {
47
-            # Check that we have the old and new workspace
48
-            $focus->send(
49
-                $event->{current}->{name} == '2' &&
50
-                $event->{old}->{name} == $focused->{name}
51
-            );
52
+            $focus->send($event);
53
         }
54
     }
55
 })->recv;
56
 
57
-cmd 'focus output right';
58
-
59
 my $t;
60
 $t = AnyEvent->timer(
61
     after => 0.5,
62
@@ -65,7 +63,15 @@ $t = AnyEvent->timer(
63
     }
64
 );
65
 
66
-ok($focus->recv, 'Workspace "focus" event received');
67
+cmd 'focus output right';
68
+
69
+my $event = $focus->recv;
70
+
71
+my $current_ws = get_ws(focused_ws);
72
+
73
+ok($event, 'Workspace "focus" event received');
74
+is($event->{current}->{id}, $current_ws->{id}, 'Event gave correct current workspace');
75
+is($event->{old}->{id}, $old_ws->{id}, 'Event gave correct old workspace');
76
 
77
 exit_gracefully($pid);
78