From 52cca3b8b7062a3bf2e409e2e39ee4e6965b6eb8 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 26 Jul 2016 02:08:56 -0400 Subject: [PATCH] tests: Test the checkbox widget. --- tests/examples/wibox/widget/checkbox/bg.lua | 20 +++++++++++ .../wibox/widget/checkbox/check_shape.lua | 27 +++++++++++++++ .../examples/wibox/widget/checkbox/custom.lua | 33 +++++++++++++++++++ .../examples/wibox/widget/checkbox/shape.lua | 27 +++++++++++++++ .../wibox/widget/defaults/checkbox.lua | 31 +++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 tests/examples/wibox/widget/checkbox/bg.lua create mode 100644 tests/examples/wibox/widget/checkbox/check_shape.lua create mode 100644 tests/examples/wibox/widget/checkbox/custom.lua create mode 100644 tests/examples/wibox/widget/checkbox/shape.lua create mode 100644 tests/examples/wibox/widget/defaults/checkbox.lua diff --git a/tests/examples/wibox/widget/checkbox/bg.lua b/tests/examples/wibox/widget/checkbox/bg.lua new file mode 100644 index 000000000..059c376d0 --- /dev/null +++ b/tests/examples/wibox/widget/checkbox/bg.lua @@ -0,0 +1,20 @@ +local parent = ... --DOC_HIDE +local wibox = require( "wibox" ) --DOC_HIDE +local beautiful = require( "beautiful" ) --DOC_HIDE + +parent:add( --DOC_HIDE +wibox.widget { + checked = true, + color = beautiful.bg_normal, + bg = "#ff00ff", + border_width = 3, + paddings = 4, + border_color = "#0000ff", + check_color = "#ff0000", + forced_width = 20, --DOC_HIDE + forced_height = 20, --DOC_HIDE + check_border_color = "#ffff00", + check_border_width = 1, + widget = wibox.widget.checkbox +} +) --DOC_HIDE diff --git a/tests/examples/wibox/widget/checkbox/check_shape.lua b/tests/examples/wibox/widget/checkbox/check_shape.lua new file mode 100644 index 000000000..8c953e890 --- /dev/null +++ b/tests/examples/wibox/widget/checkbox/check_shape.lua @@ -0,0 +1,27 @@ +local parent = ... --DOC_HIDE +local wibox = require( "wibox" ) --DOC_HIDE +local beautiful = require( "beautiful" ) --DOC_HIDE +local gears = {shape = require("gears.shape")} --DOC_HIDE + +local l = wibox.widget { --DOC_HIDE + spacing = 4, --DOC_HIDE + layout = wibox.layout.fixed.horizontal --DOC_HIDE +} --DOC_HIDE + +for _, s in ipairs {"rectangle", "circle", "losange", "octogon"} do + +l:add( --DOC_HIDE + wibox.widget { + checked = true, + color = beautiful.bg_normal, + paddings = 2, + forced_width = 20, --DOC_HIDE + forced_height = 20, --DOC_HIDE + check_shape = gears.shape[s], + widget = wibox.widget.checkbox + } +) --DOC_HIDE + +end + +parent:add(l) --DOC_HIDE diff --git a/tests/examples/wibox/widget/checkbox/custom.lua b/tests/examples/wibox/widget/checkbox/custom.lua new file mode 100644 index 000000000..2309a4445 --- /dev/null +++ b/tests/examples/wibox/widget/checkbox/custom.lua @@ -0,0 +1,33 @@ +local parent = ... --DOC_NO_USAGE --DOC_HIDE +local wibox = require( "wibox" ) --DOC_HIDE +local beautiful = require( "beautiful" ) --DOC_HIDE + +parent:add( --DOC_HIDE + wibox.widget { + checked = true, + color = beautiful.bg_normal, + paddings = 2, + forced_width = 20, --DOC_HIDE + forced_height = 20, --DOC_HIDE + check_shape = function(cr, width, height) + local rs = math.min(width, height) + + cr:move_to( 0 , 0 ) + cr:line_to( rs , 0 ) + cr:move_to( 0 , 0 ) + cr:line_to( 0 , rs ) + cr:move_to( 0 , rs ) + cr:line_to( rs , rs ) + cr:move_to( rs , 0 ) + cr:line_to( rs , rs ) + cr:move_to( 0 , 0 ) + cr:line_to( rs , rs ) + cr:move_to( 0 , rs ) + cr:line_to( rs , 0 ) + end, + check_border_color = "#ff0000", + check_color = "#00000000", + check_border_width = 1, + widget = wibox.widget.checkbox + } +) --DOC_HIDE diff --git a/tests/examples/wibox/widget/checkbox/shape.lua b/tests/examples/wibox/widget/checkbox/shape.lua new file mode 100644 index 000000000..680f474b1 --- /dev/null +++ b/tests/examples/wibox/widget/checkbox/shape.lua @@ -0,0 +1,27 @@ +local parent = ... --DOC_HIDE +local wibox = require( "wibox" ) --DOC_HIDE +local beautiful = require( "beautiful" ) --DOC_HIDE +local gears = {shape = require("gears.shape")} --DOC_HIDE + +local l = wibox.widget { --DOC_HIDE + spacing = 4, --DOC_HIDE + layout = wibox.layout.fixed.horizontal --DOC_HIDE +} --DOC_HIDE + +for _, s in ipairs {"rectangle", "circle", "losange", "octogon"} do + +l:add( --DOC_HIDE + wibox.widget { + checked = true, + color = beautiful.bg_normal, + paddings = 2, + forced_width = 20, --DOC_HIDE + forced_height = 20, --DOC_HIDE + shape = gears.shape[s], + widget = wibox.widget.checkbox + } +) --DOC_HIDE + +end + +parent:add(l) --DOC_HIDE diff --git a/tests/examples/wibox/widget/defaults/checkbox.lua b/tests/examples/wibox/widget/defaults/checkbox.lua new file mode 100644 index 000000000..981aa4e03 --- /dev/null +++ b/tests/examples/wibox/widget/defaults/checkbox.lua @@ -0,0 +1,31 @@ +local parent = ... --DOC_HIDE +local wibox = require( "wibox" ) --DOC_HIDE +local beautiful = require( "beautiful" ) --DOC_HIDE +local gears = {shape = require("gears.shape")} --DOC_HIDE + +parent:add( --DOC_HIDE +wibox.widget { --DOC_HIDE +wibox.widget { + checked = true, + color = beautiful.bg_normal, + paddings = 2, + forced_width = 20, --DOC_HIDE + forced_height = 20, --DOC_HIDE + shape = gears.shape.circle, + widget = wibox.widget.checkbox +} +, --DOC_HIDE +wibox.widget { --DOC_HIDE + checked = false, --DOC_HIDE + color = beautiful.bg_normal, --DOC_HIDE + paddings = 2, --DOC_HIDE + forced_width = 20, --DOC_HIDE + forced_height = 20, --DOC_HIDE + shape = gears.shape.circle, --DOC_HIDE + widget = wibox.widget.checkbox --DOC_HIDE +}, --DOC_HIDE +spacing = 4, --DOC_HIDE +layout = wibox.layout.fixed.horizontal --DOC_HIDE +} --DOC_HIDE + +) --DOC_HIDE