From aae9655e41e5de9c6a6bb83abd4acf65e70c4642 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 28 Jan 2017 21:39:25 -0500 Subject: [PATCH] tests: Test the custom rule sources --- tests/test-awful-rules.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test-awful-rules.lua b/tests/test-awful-rules.lua index 59b1b43f..d99fccdb 100644 --- a/tests/test-awful-rules.lua +++ b/tests/test-awful-rules.lua @@ -264,6 +264,34 @@ test_rule { end } +-- Test the custom sources +assert(awful.rules.add_rule_source("high_priority", function(c, props, _) + assert(type(c) == "client") + assert(props.random2) + + props.random1 = true +end, {"awful.spawn"}, {"awful.rules", "low_priority"})) + +assert(awful.rules.add_rule_source("before2", function() + error("This function should not be called") +end, {"awful.spawn"}, {"awful.rules"})) + +assert(awful.rules.remove_rule_source("before2")) + +assert(awful.rules.add_rule_source("low_priority", function(c, props, _) + assert(type(c) == "client") + assert(not props.random1) + + props.random2 = true +end, {"awful.spawn", "high_priority"}, {"void", "awful.rules"})) + +local temp = gears.debug.print_warning +gears.debug.print_warning = function() end +assert(not awful.rules.add_rule_source("invalid_source", function() + assert(false, "This cannot happen") +end, {"awful.rules"}, {"awful.spawn"})) +gears.debug.print_warning = temp + -- Test tag and switchtotag test_rule { properties = { @@ -295,10 +323,17 @@ test_rule { assert(c.screen.selected_tag.name ~= "8") + -- Test the custom sources + assert(c.random1) + assert(c.random2) + assert(not c.random3) + return true end } + + -- Wait until all the auto-generated clients are ready local function spawn_clients() if #client.get() >= #tests then