From 072ff10cf0ae96fdf9b65deb6d1d81b0bea9ec52 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 4 Aug 2016 18:12:59 -0400 Subject: [PATCH] tests: Test the slider widget. --- .../examples/wibox/widget/defaults/slider.lua | 22 +++++++++++++ .../wibox/widget/slider/bar_border.lua | 26 ++++++++++++++++ .../wibox/widget/slider/bar_color.lua | 26 ++++++++++++++++ .../wibox/widget/slider/bar_height.lua | 26 ++++++++++++++++ .../wibox/widget/slider/bar_margins.lua | 31 +++++++++++++++++++ .../wibox/widget/slider/bar_shape.lua | 28 +++++++++++++++++ .../wibox/widget/slider/handle_border.lua | 26 ++++++++++++++++ .../wibox/widget/slider/handle_color.lua | 26 ++++++++++++++++ .../wibox/widget/slider/handle_margins.lua | 31 +++++++++++++++++++ .../wibox/widget/slider/handle_shape.lua | 28 +++++++++++++++++ .../wibox/widget/slider/handle_width.lua | 27 ++++++++++++++++ tests/examples/wibox/widget/slider/value.lua | 27 ++++++++++++++++ 12 files changed, 324 insertions(+) create mode 100644 tests/examples/wibox/widget/defaults/slider.lua create mode 100644 tests/examples/wibox/widget/slider/bar_border.lua create mode 100644 tests/examples/wibox/widget/slider/bar_color.lua create mode 100644 tests/examples/wibox/widget/slider/bar_height.lua create mode 100644 tests/examples/wibox/widget/slider/bar_margins.lua create mode 100644 tests/examples/wibox/widget/slider/bar_shape.lua create mode 100644 tests/examples/wibox/widget/slider/handle_border.lua create mode 100644 tests/examples/wibox/widget/slider/handle_color.lua create mode 100644 tests/examples/wibox/widget/slider/handle_margins.lua create mode 100644 tests/examples/wibox/widget/slider/handle_shape.lua create mode 100644 tests/examples/wibox/widget/slider/handle_width.lua create mode 100644 tests/examples/wibox/widget/slider/value.lua diff --git a/tests/examples/wibox/widget/defaults/slider.lua b/tests/examples/wibox/widget/defaults/slider.lua new file mode 100644 index 000000000..9fd266dc3 --- /dev/null +++ b/tests/examples/wibox/widget/defaults/slider.lua @@ -0,0 +1,22 @@ +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 { + bar_shape = gears.shape.rounded_rect, + bar_height = 3, + bar_color = beautiful.border_color, + handle_color = beautiful.bg_normal, + handle_shape = gears.shape.circle, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + value = 25, + widget = wibox.widget.slider, + forced_height = 50, --DOC_HIDE + forced_width = 100, --DOC_HIDE +} + +) --DOC_HIDE diff --git a/tests/examples/wibox/widget/slider/bar_border.lua b/tests/examples/wibox/widget/slider/bar_border.lua new file mode 100644 index 000000000..f7f0d7b87 --- /dev/null +++ b/tests/examples/wibox/widget/slider/bar_border.lua @@ -0,0 +1,26 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = val, + bar_border_width = 4, + bar_margins = {}, + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen("#ff0000"), gen("#00ff00"), gen("#0000ff"), gen("#ff00ff"), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/bar_color.lua b/tests/examples/wibox/widget/slider/bar_color.lua new file mode 100644 index 000000000..5401e94a0 --- /dev/null +++ b/tests/examples/wibox/widget/slider/bar_color.lua @@ -0,0 +1,26 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 1, + bar_margins = {}, + bar_color = val, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen("#ff0000"), gen("#00ff00"), gen("#0000ff"), gen("#ff00ff"), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/bar_height.lua b/tests/examples/wibox/widget/slider/bar_height.lua new file mode 100644 index 000000000..2d94f0643 --- /dev/null +++ b/tests/examples/wibox/widget/slider/bar_height.lua @@ -0,0 +1,26 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 1, + bar_height = val, + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen(3), gen(9), gen(16), gen(nil), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/bar_margins.lua b/tests/examples/wibox/widget/slider/bar_margins.lua new file mode 100644 index 000000000..68428e7c5 --- /dev/null +++ b/tests/examples/wibox/widget/slider/bar_margins.lua @@ -0,0 +1,31 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 2, + bar_margins = val, + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 2, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen(0), gen(3), gen(6), gen({ + top = 12, + bottom = 12, + left = 12, + right = 12, + }), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/bar_shape.lua b/tests/examples/wibox/widget/slider/bar_shape.lua new file mode 100644 index 000000000..d33dac7fd --- /dev/null +++ b/tests/examples/wibox/widget/slider/bar_shape.lua @@ -0,0 +1,28 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local gears = {shape = require("gears.shape")} +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_shape = gears.shape[val], + bar_border_color = beautiful.border_color, + bar_border_width = 1, + bar_margins = {}, + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen("rectangle"), gen("hexagon"), gen("rounded_bar"), gen("octogon"), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/handle_border.lua b/tests/examples/wibox/widget/slider/handle_border.lua new file mode 100644 index 000000000..2e4bf039b --- /dev/null +++ b/tests/examples/wibox/widget/slider/handle_border.lua @@ -0,0 +1,26 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 1, + bar_margins = {}, + handle_color = beautiful.bg_normal, + handle_border_color = val, + handle_border_width = 4, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen("#ff0000"), gen("#00ff00"), gen("#0000ff"), gen("#ff00ff"), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/handle_color.lua b/tests/examples/wibox/widget/slider/handle_color.lua new file mode 100644 index 000000000..4af7fe2ba --- /dev/null +++ b/tests/examples/wibox/widget/slider/handle_color.lua @@ -0,0 +1,26 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 1, + bar_margins = {}, + handle_color = val, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen("#ff0000"), gen("#00ff00"), gen("#0000ff"), gen("#ff00ff"), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/handle_margins.lua b/tests/examples/wibox/widget/slider/handle_margins.lua new file mode 100644 index 000000000..4da171bba --- /dev/null +++ b/tests/examples/wibox/widget/slider/handle_margins.lua @@ -0,0 +1,31 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 2, + handle_margins = val, + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 2, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen(0), gen(3), gen(6), gen({ + top = 12, + bottom = 12, + left = 12, + right = 12, + }), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/handle_shape.lua b/tests/examples/wibox/widget/slider/handle_shape.lua new file mode 100644 index 000000000..18ba7acdd --- /dev/null +++ b/tests/examples/wibox/widget/slider/handle_shape.lua @@ -0,0 +1,28 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local gears = {shape = require("gears.shape")} +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 1, + bar_margins = {}, + handle_shape = gears.shape[val], + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen("rectangle"), gen("losange"), gen("circle"), gen("isosceles_triangle"), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/handle_width.lua b/tests/examples/wibox/widget/slider/handle_width.lua new file mode 100644 index 000000000..ae61daa11 --- /dev/null +++ b/tests/examples/wibox/widget/slider/handle_width.lua @@ -0,0 +1,27 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + bar_border_width = 2, + handle_width = val, + value = 50, + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 2, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen(0), gen(10), gen(30), gen(50), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l) diff --git a/tests/examples/wibox/widget/slider/value.lua b/tests/examples/wibox/widget/slider/value.lua new file mode 100644 index 000000000..cce0b7295 --- /dev/null +++ b/tests/examples/wibox/widget/slider/value.lua @@ -0,0 +1,27 @@ +--DOC_HIDE_ALL +local parent = ... +local wibox = require("wibox") +local beautiful = require("beautiful") + +local function gen(val) + return wibox.widget { + bar_border_color = beautiful.border_color, + value = val, + bar_border_width = 4, + bar_margins = {}, + handle_color = beautiful.bg_normal, + handle_border_color = beautiful.border_color, + handle_border_width = 1, + widget = wibox.widget.slider, + } +end + +local l = wibox.layout { + gen(0), gen(33), gen(66), gen(100), + forced_height = 30, + forced_width = 400, + spacing = 5, + layout = wibox.layout.flex.horizontal +} + +parent:add(l)