Browse Source

test(awful: hotkeys_popup): test pagination and app-specific hotkeys (on vim example)

actionless 1 month ago
parent
commit
0374bf1b1b
2 changed files with 46 additions and 1 deletions
  1. 1
    0
      .travis.yml
  2. 45
    1
      tests/test-awesomerc.lua

+ 1
- 0
.travis.yml View File

@@ -42,6 +42,7 @@ addons:
42 42
       - xvfb
43 43
       - zsh
44 44
       - x11-apps
45
+      - vim-nox
45 46
       # Need xorg-macros
46 47
       - xutils-dev
47 48
       # lgi.

+ 45
- 1
tests/test-awesomerc.lua View File

@@ -24,6 +24,8 @@ local function num_pairs(container_table)
24 24
   return number_of_items
25 25
 end
26 26
 
27
+local test_context = {}
28
+
27 29
 local steps = {
28 30
     function(count)
29 31
         if count <= 5 then
@@ -239,11 +241,22 @@ local steps = {
239 241
         elseif count == 2 then
240 242
             assert(num_pairs(cached_wiboxes) > 0)
241 243
             assert(num_pairs(cached_wiboxes[s]) == 1)
244
+
245
+        elseif (
246
+            test_context.hotkeys01_count_vim and
247
+            (count - test_context.hotkeys01_count_vim) == 2
248
+        ) then
249
+            -- new wibox instance should be generated for including vim hotkeys:
250
+            assert(num_pairs(cached_wiboxes[s]) == 2)
242 251
         end
243 252
 
244 253
         local hotkeys_wibox
254
+        local visible_hotkeys_widget
245 255
         for _, widget in pairs(cached_wiboxes[s]) do
246 256
             hotkeys_wibox = widget.wibox
257
+            if hotkeys_wibox.visible then
258
+                visible_hotkeys_widget = widget
259
+            end
247 260
         end
248 261
 
249 262
         if count == 2 then
@@ -255,7 +268,38 @@ local steps = {
255 268
         elseif count == 3 then
256 269
             assert(not hotkeys_wibox.visible)
257 270
             root.fake_input("key_release", "Super_L")
258
-            return true
271
+            -- now let's run vim so hotkeys widget will show hotkeys for it:
272
+            test_context.hotkeys01_clients_before = #client.get()
273
+            awful.spawn("xterm -e vim")
274
+
275
+        elseif not test_context.hotkeys01_count_vim then
276
+            -- if xterm with vim got already opened:
277
+            if (
278
+                    test_context.hotkeys01_clients_before and
279
+                    test_context.hotkeys01_clients_before < #client.get()
280
+            ) then
281
+                -- open hotkeys popup with vim hotkeys:
282
+                awful.key.execute({modkey}, "s")
283
+                test_context.hotkeys01_count_vim = count
284
+            end
285
+
286
+        elseif test_context.hotkeys01_count_vim then
287
+            if (count - test_context.hotkeys01_count_vim) == 1 then
288
+                assert(visible_hotkeys_widget ~= nil)
289
+                assert(visible_hotkeys_widget.current_page == 1)
290
+                -- Should change the page on PgDn:
291
+                root.fake_input("key_press", "Next")
292
+            elseif (count - test_context.hotkeys01_count_vim) == 2 then
293
+                assert(visible_hotkeys_widget ~= nil)
294
+                assert(visible_hotkeys_widget.current_page == 2)
295
+                root.fake_input("key_release", "Next")
296
+                -- Should disappear on anykey
297
+                root.fake_input("key_press", "Super_L")
298
+            elseif (count - test_context.hotkeys01_count_vim) == 3 then
299
+                assert(not visible_hotkeys_widget)
300
+                root.fake_input("key_release", "Super_L")
301
+                return true
302
+            end
259 303
         end
260 304
     end,
261 305
 

Loading…
Cancel
Save