From bb47aa5861bf0ca9ce9407bd68a0360106e48d42 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 9 Apr 2016 02:57:56 -0400 Subject: [PATCH] tests: Test all client layouts --- tests/test-awful-layout.lua | 122 ++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 tests/test-awful-layout.lua diff --git a/tests/test-awful-layout.lua b/tests/test-awful-layout.lua new file mode 100644 index 000000000..bc8ced7d9 --- /dev/null +++ b/tests/test-awful-layout.lua @@ -0,0 +1,122 @@ +-- This test hit the client layout code paths to see if there is errors. +-- it doesn't check if the layout are correct. + +local awful = require("awful") + +local first_layout = nil + +local t = nil + +local has_spawned = false + +local steps = { + +-- Add enough clients +function(count) + if count <= 1 and not has_spawned then + for _=1, 5 do awful.spawn("xterm") end + has_spawned = true + elseif #client.get() >= 5 then + + first_layout = client.focus:tags()[1].layout + + t = client.focus:tags()[1] + + return true + end +end, + +} + +local function next_layout() + awful.layout.inc(1) + + assert(client.focus:tags()[1].layout ~= first_layout) + + return true +end + +-- Test most properties for each layouts +local common_steps = { + function() + assert(#t:clients() == 5) + + t.master_count = 2 + + return true + end, + function() + t.master_count = 0 + + return true + end, + function() + t.master_count = 6 --more than #client.get(1) + + return true + end, + function() + t.master_count = 1 + + return true + end, + function() + t.column_count = 2 + + return true + end, + function() + t.column_count = 6 --more than #client.get(1) + + return true + end, + function() + t.column_count = 1 + + return true + end, + function() + t.master_fill_policy = t.master_fill_policy == "mwfact" and + "expand" or "mwfact" + + return true + end, + function() + t.master_width_factor = 0.75 + + return true + end, + function() + t.master_width_factor = 0 + + return true + end, + function() + t.master_width_factor = 1 + + return true + end, + function() + t.master_width_factor = 0.5 + + return true + end, + function() + t.gap = t.gap == 0 and 5 or 0 + + return true + end, +} + +local first = false +for _ in ipairs(awful.layout.layouts) do + if not first then + first = true + else + awful.util.table.merge(steps, {next_layout}) + end + + awful.util.table.merge(steps, common_steps) +end + +require("_runner").run_steps(steps)