From a2748a1fa33341ca82d2a9136f954950401cbe56 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 28 Sep 2016 16:39:07 -0400 Subject: [PATCH] tests: Test client focus stealing filters. --- tests/test-awful-client.lua | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/test-awful-client.lua b/tests/test-awful-client.lua index 25d9bfa2..26c11968 100644 --- a/tests/test-awful-client.lua +++ b/tests/test-awful-client.lua @@ -77,6 +77,54 @@ end end } +local original_count, c1, c2 = 0 + +-- Check request::activate +table.insert(steps, function() + c1, c2 = client.get()[1], client.get()[2] + + -- This should still be the case + assert(client.focus == c1) + + c2:emit_signal("request::activate", "i_said_so") + + return true +end) + +-- Check if writing a focus stealing filter works. +table.insert(steps, function() + -- This should still be the case + assert(client.focus == c2) + + original_count = #awful.ewmh.generic_activate_filters + + awful.ewmh.add_activate_filter(function(c) + if c == c1 then return false end + end) + + c1:emit_signal("request::activate", "i_said_so") + + return true +end) + +table.insert(steps, function() + -- The request should have been denied + assert(client.focus == c2) + + -- Test the remove function + awful.ewmh.remove_activate_filter(function() end) + + awful.ewmh.add_activate_filter(awful.ewmh.generic_activate_filters[1]) + + awful.ewmh.remove_activate_filter(awful.ewmh.generic_activate_filters[1]) + + assert(original_count == #awful.ewmh.generic_activate_filters) + + c1:emit_signal("request::activate", "i_said_so") + + return client.focus == c1 +end) + local has_error -- Disable awful.screen.preferred(c)