From 7b7d09edff48c06c83fbce88ed6547506b425cf4 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 28 Mar 2016 01:53:39 -0400 Subject: [PATCH] tests: Test all `awful.placement.stretch` aliases --- tests/examples/awful/placement/stretch_down.lua | 17 +++++++++++++++++ tests/examples/awful/placement/stretch_left.lua | 14 ++++++++++++++ .../examples/awful/placement/stretch_right.lua | 14 ++++++++++++++ tests/examples/awful/placement/stretch_up.lua | 17 +++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 tests/examples/awful/placement/stretch_down.lua create mode 100644 tests/examples/awful/placement/stretch_left.lua create mode 100644 tests/examples/awful/placement/stretch_right.lua create mode 100644 tests/examples/awful/placement/stretch_up.lua diff --git a/tests/examples/awful/placement/stretch_down.lua b/tests/examples/awful/placement/stretch_down.lua new file mode 100644 index 000000000..12a074b10 --- /dev/null +++ b/tests/examples/awful/placement/stretch_down.lua @@ -0,0 +1,17 @@ +-- Stretch the drawable to the bottom of the parent area. --DOC_HEADER +-- @tparam drawable d A drawable (like `client` or `wibox`) --DOC_HEADER +-- @tparam[opt={}] table args Other arguments --DOC_HEADER +-- @name stretch_down --DOC_HEADER +-- @class function --DOC_HEADER + +screen[1]._resize {width = 128, height = 96} --DOC_HIDE +local placement = require("awful.placement") --DOC_HIDE + +local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE +placement.stretch_down(client.focus) + +assert(c.x==45) --DOC_HIDE +assert(c.y==35) --DOC_HIDE +assert(c.width == 40) --DOC_HIDE +assert(c.y+c.height == --DOC_HIDE + screen[1].geometry.y + screen[1].geometry.height) --DOC_HIDE diff --git a/tests/examples/awful/placement/stretch_left.lua b/tests/examples/awful/placement/stretch_left.lua new file mode 100644 index 000000000..7db11c77a --- /dev/null +++ b/tests/examples/awful/placement/stretch_left.lua @@ -0,0 +1,14 @@ +-- Stretch the drawable to the left of the parent area. --DOC_HEADER +-- @tparam drawable d A drawable (like `client` or `wibox`) --DOC_HEADER +-- @tparam[opt={}] table args Other arguments --DOC_HEADER +-- @name stretch_left --DOC_HEADER +-- @class function --DOC_HEADER + +screen[1]._resize {width = 128, height = 96} --DOC_HIDE +local placement = require("awful.placement") --DOC_HIDE + +local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE +placement.stretch_left(client.focus) + +assert(c.x == c.border_width and c.y == 35 and c.height == 30 --DOC_HIDE + and c.width == 45+40) --DOC_HIDE diff --git a/tests/examples/awful/placement/stretch_right.lua b/tests/examples/awful/placement/stretch_right.lua new file mode 100644 index 000000000..79b2687d7 --- /dev/null +++ b/tests/examples/awful/placement/stretch_right.lua @@ -0,0 +1,14 @@ +-- Stretch the drawable to the right of the parent area. --DOC_HEADER +-- @tparam drawable d A drawable (like `client` or `wibox`) --DOC_HEADER +-- @tparam[opt={}] table args Other arguments --DOC_HEADER +-- @name stretch_right --DOC_HEADER +-- @class function --DOC_HEADER + +screen[1]._resize {width = 128, height = 96} --DOC_HIDE +local placement = require("awful.placement") --DOC_HIDE + +local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE +placement.stretch_right(client.focus) + +local right = screen[1].geometry.x + screen[1].geometry.width --DOC_HIDE +assert(c.height == 30 and c.x == 45 and c.x+c.width+c.border_width == right) --DOC_HIDE diff --git a/tests/examples/awful/placement/stretch_up.lua b/tests/examples/awful/placement/stretch_up.lua new file mode 100644 index 000000000..87bea473b --- /dev/null +++ b/tests/examples/awful/placement/stretch_up.lua @@ -0,0 +1,17 @@ +-- Stretch the drawable to the top of the parent area. --DOC_HEADER +-- @tparam drawable d A drawable (like `client` or `wibox`) --DOC_HEADER +-- @tparam[opt={}] table args Other arguments --DOC_HEADER +-- @name stretch_up --DOC_HEADER +-- @class function --DOC_HEADER + +screen[1]._resize {width = 128, height = 96} --DOC_HIDE +local placement = require("awful.placement") --DOC_HIDE + +local c = client.gen_fake {x = 45, y = 35, width=40, height=30} --DOC_HIDE +placement.stretch_up(client.focus) + +assert(c.y==c.border_width) --DOC_HIDE +assert(c.x==45) --DOC_HIDE +assert(c.width == 40) --DOC_HIDE +print(c.height) +assert(c.height == 35+30) --DOC_HIDE