i3 - improved tiling WM


Add testcase for EWMH desktop names

Patch status: merged

Patch by Tony Crisci

Long description:

Test that the EWMH specified property _NET_DESKTOP_NAMES is updated
properly on the root window. We interpret this as a list of the open
workspace names.

This test is for this commit:

Implement EWMH desktop names

a9c094b7313b48491c182a5da1194a0bb06747aa

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

b/testcases/t/234-ewmh-desktop-names.t

24
@@ -0,0 +1,72 @@
25
+#!perl
26
+# vim:ts=4:sw=4:expandtab
27
+#
28
+# Please read the following documents before working on tests:
29
+# • http://build.i3wm.org/docs/testsuite.html
30
+#   (or docs/testsuite)
31
+#
32
+# • http://build.i3wm.org/docs/lib-i3test.html
33
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
34
+#
35
+# • http://build.i3wm.org/docs/ipc.html
36
+#   (or docs/ipc)
37
+#
38
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
39
+#   (unless you are already familiar with Perl)
40
+#
41
+# Test that the EWMH specified property _NET_DESKTOP_NAMES is updated properly
42
+# on the root window. We interpret this as a list of the open workspace names.
43
+# Ticket: #1241
44
+use i3test;
45
+
46
+sub get_desktop_names {
47
+    my $cookie = $x->get_property(
48
+        0,
49
+        $x->get_root_window(),
50
+        $x->atom(name => '_NET_DESKTOP_NAMES')->id,
51
+        $x->atom(name => 'UTF8_STRING')->id,
52
+        0,
53
+        4096,
54
+    );
55
+
56
+    my $reply = $x->get_property_reply($cookie->{sequence});
57
+
58
+    return 0 if $reply->{value_len} == 0;
59
+
60
+    # the property is a null-delimited list of utf8 strings ;;
61
+    return split /\0/, $reply->{value};
62
+}
63
+
64
+cmd 'workspace foo';
65
+
66
+my @expected_names = ('foo');
67
+my @desktop_names = get_desktop_names;
68
+
69
+is_deeply(\@desktop_names, \@expected_names, '_NET_DESKTOP_NAMES should be an array of the workspace names');
70
+
71
+# open a new workspace and see that the property is updated correctly
72
+open_window;
73
+cmd 'workspace bar';
74
+
75
+@desktop_names = get_desktop_names;
76
+@expected_names = ('foo', 'bar');
77
+
78
+is_deeply(\@desktop_names, \@expected_names, 'it should be updated when a new workspace appears');
79
+
80
+# rename the workspace and see that the property is updated correctly
81
+cmd 'rename workspace bar to baz';
82
+
83
+@desktop_names = get_desktop_names;
84
+@expected_names = ('foo', 'baz');
85
+
86
+is_deeply(\@desktop_names, \@expected_names, 'it should be updated when a workspace is renamed');
87
+
88
+# empty a workspace and see that the property is updated correctly
89
+cmd 'workspace foo';
90
+
91
+@desktop_names = get_desktop_names;
92
+@expected_names = ('foo');
93
+
94
+is_deeply(\@desktop_names, \@expected_names, 'it should be updated when a workspace is emptied');
95
+
96
+done_testing;