Add testcase for EWMH desktop viewport
Patch status: merged
Patch by Tony Crisci
Long description:
Test that the EWMH specified property _NET_DESKTOP_VIEWPORT is updated properly on the root window. We interpret this as a list of x/y coordinate pairs for the upper left corner of the respective outputs of the workspaces. This test is for this commit: feature: implement ewmh desktop viewport property 4205973135f28a0ab0e25a63dbc8c6fff0d3539e
To apply this patch, use:
curl http://cr.i3wm.org/patch/622/raw.patch | git am
b/testcases/t/521-ewmh-desktop-viewport.t
25 |
@@ -0,0 +1,92 @@ |
26 |
+#!perl |
27 |
+# vim:ts=4:sw=4:expandtab |
28 |
+# |
29 |
+# Please read the following documents before working on tests: |
30 |
+# • http://build.i3wm.org/docs/testsuite.html |
31 |
+# (or docs/testsuite) |
32 |
+# |
33 |
+# • http://build.i3wm.org/docs/lib-i3test.html |
34 |
+# (alternatively: perldoc ./testcases/lib/i3test.pm) |
35 |
+# |
36 |
+# • http://build.i3wm.org/docs/ipc.html |
37 |
+# (or docs/ipc) |
38 |
+# |
39 |
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf |
40 |
+# (unless you are already familiar with Perl) |
41 |
+# |
42 |
+# Test that the EWMH specified property _NET_DESKTOP_VIEWPORT is updated |
43 |
+# properly on the root window. We interpret this as a list of x/y coordinate |
44 |
+# pairs for the upper left corner of the respective outputs of the workspaces |
45 |
+# Ticket: #1241 |
46 |
+use i3test i3_autostart => 0; |
47 |
+ |
48 |
+my $config = <<EOT; |
49 |
+# i3 config file (v4) |
50 |
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 |
51 |
+ |
52 |
+workspace 0 output fake-0 |
53 |
+workspace 1 output fake-1 |
54 |
+ |
55 |
+fake-outputs 1024x768+0+0,1024x768+1024+0 |
56 |
+EOT |
57 |
+ |
58 |
+my $pid = launch_with_config($config); |
59 |
+ |
60 |
+sub get_desktop_viewport { |
61 |
+ my $cookie = $x->get_property( |
62 |
+ 0, |
63 |
+ $x->get_root_window(), |
64 |
+ $x->atom(name => '_NET_DESKTOP_VIEWPORT')->id, |
65 |
+ $x->atom(name => 'CARDINAL')->id, |
66 |
+ 0, |
67 |
+ 4096 |
68 |
+ ); |
69 |
+ |
70 |
+ my $reply = $x->get_property_reply($cookie->{sequence}); |
71 |
+ |
72 |
+ return 0 if $reply->{value_len} == 0; |
73 |
+ |
74 |
+ my $len = $reply->{length}; |
75 |
+ |
76 |
+ return unpack ("L$len", $reply->{value}); |
77 |
+} |
78 |
+ |
79 |
+# initialize the workspaces |
80 |
+cmd 'workspace 1'; |
81 |
+cmd 'workspace 0'; |
82 |
+ |
83 |
+my @expected_viewport = (0, 0, 1024, 0); |
84 |
+my @desktop_viewport = get_desktop_viewport; |
85 |
+ |
86 |
+is_deeply(\@desktop_viewport, \@expected_viewport, |
87 |
+ '_NET_DESKTOP_VIEWPORT should be an array of x/y coordinate pairs for the upper left corner of the respective outputs of the workspaces'); |
88 |
+ |
89 |
+cmd 'workspace 0'; |
90 |
+open_window; |
91 |
+cmd 'workspace 3'; |
92 |
+ |
93 |
+@expected_viewport = (0, 0, 0, 0, 1024, 0); |
94 |
+@desktop_viewport = get_desktop_viewport; |
95 |
+ |
96 |
+is_deeply(\@desktop_viewport, \@expected_viewport, |
97 |
+ 'it should be updated when a new workspace appears'); |
98 |
+ |
99 |
+cmd 'rename workspace 3 to 2'; |
100 |
+ |
101 |
+@expected_viewport = (0, 0, 0, 0, 1024, 0); |
102 |
+@desktop_viewport = get_desktop_viewport; |
103 |
+ |
104 |
+is_deeply(\@desktop_viewport, \@expected_viewport, |
105 |
+ 'it should stay up to date when a workspace is renamed'); |
106 |
+ |
107 |
+cmd 'workspace 0'; |
108 |
+ |
109 |
+@expected_viewport = (0, 0, 1024, 0); |
110 |
+@desktop_viewport = get_desktop_viewport; |
111 |
+ |
112 |
+is_deeply(\@desktop_viewport, \@expected_viewport, |
113 |
+ 'it should be updated when a workspace is emptied'); |
114 |
+ |
115 |
+exit_gracefully($pid); |
116 |
+ |
117 |
+done_testing; |