diff --git a/spec/menubar/home/.icons/awesome b/spec/menubar/home/.icons/awesome new file mode 120000 index 000000000..bb8c1e361 --- /dev/null +++ b/spec/menubar/home/.icons/awesome @@ -0,0 +1 @@ +../../icons/awesome \ No newline at end of file diff --git a/spec/menubar/home/.icons/icon5.png b/spec/menubar/home/.icons/icon5.png new file mode 120000 index 000000000..245b18443 --- /dev/null +++ b/spec/menubar/home/.icons/icon5.png @@ -0,0 +1 @@ +../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/home/.local/share/icons/icon4.png b/spec/menubar/home/.local/share/icons/icon4.png new file mode 120000 index 000000000..101d373da --- /dev/null +++ b/spec/menubar/home/.local/share/icons/icon4.png @@ -0,0 +1 @@ +../../../../../../icons/awesome16.png \ No newline at end of file diff --git a/spec/menubar/home/.local/share/icons/icon5.png b/spec/menubar/home/.local/share/icons/icon5.png new file mode 120000 index 000000000..101d373da --- /dev/null +++ b/spec/menubar/home/.local/share/icons/icon5.png @@ -0,0 +1 @@ +../../../../../../icons/awesome16.png \ No newline at end of file diff --git a/spec/menubar/icons/awesome/64x64/apps/awesome2.png b/spec/menubar/icons/awesome/64x64/apps/awesome2.png new file mode 120000 index 000000000..0fee3812b --- /dev/null +++ b/spec/menubar/icons/awesome/64x64/apps/awesome2.png @@ -0,0 +1 @@ +awesome.png \ No newline at end of file diff --git a/spec/menubar/icons/awesome/scalable/apps/awesome2.png b/spec/menubar/icons/awesome/scalable/apps/awesome2.png new file mode 120000 index 000000000..a5d82d713 --- /dev/null +++ b/spec/menubar/icons/awesome/scalable/apps/awesome2.png @@ -0,0 +1 @@ +../../64x64/apps/awesome.png \ No newline at end of file diff --git a/spec/menubar/usr/local/share/icons/icon3.png b/spec/menubar/usr/local/share/icons/icon3.png new file mode 120000 index 000000000..5737dc593 --- /dev/null +++ b/spec/menubar/usr/local/share/icons/icon3.png @@ -0,0 +1 @@ +../../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/local/share/icons/icon4.png b/spec/menubar/usr/local/share/icons/icon4.png new file mode 120000 index 000000000..5737dc593 --- /dev/null +++ b/spec/menubar/usr/local/share/icons/icon4.png @@ -0,0 +1 @@ +../../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/local/share/icons/icon5.png b/spec/menubar/usr/local/share/icons/icon5.png new file mode 120000 index 000000000..5737dc593 --- /dev/null +++ b/spec/menubar/usr/local/share/icons/icon5.png @@ -0,0 +1 @@ +../../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/icons/icon2.png b/spec/menubar/usr/share/icons/icon2.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/icons/icon2.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/icons/icon3.png b/spec/menubar/usr/share/icons/icon3.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/icons/icon3.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/icons/icon4.png b/spec/menubar/usr/share/icons/icon4.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/icons/icon4.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/icons/icon5.png b/spec/menubar/usr/share/icons/icon5.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/icons/icon5.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/pixmaps/icon1.png b/spec/menubar/usr/share/pixmaps/icon1.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/pixmaps/icon1.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/pixmaps/icon2.png b/spec/menubar/usr/share/pixmaps/icon2.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/pixmaps/icon2.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/pixmaps/icon3.png b/spec/menubar/usr/share/pixmaps/icon3.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/pixmaps/icon3.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/pixmaps/icon4.png b/spec/menubar/usr/share/pixmaps/icon4.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/pixmaps/icon4.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/usr/share/pixmaps/icon5.png b/spec/menubar/usr/share/pixmaps/icon5.png new file mode 120000 index 000000000..c69a7b3d1 --- /dev/null +++ b/spec/menubar/usr/share/pixmaps/icon5.png @@ -0,0 +1 @@ +../../../icons/fallback.png \ No newline at end of file diff --git a/spec/menubar/utils_spec.lua b/spec/menubar/utils_spec.lua index daa04dae2..f71f5a7aa 100644 --- a/spec/menubar/utils_spec.lua +++ b/spec/menubar/utils_spec.lua @@ -4,6 +4,8 @@ --------------------------------------------------------------------------- local utils = require("menubar.utils") +local theme = require("beautiful") +local glib = require("lgi").GLib describe("menubar.utils unescape", function() local single_strings = { @@ -50,4 +52,64 @@ describe("menubar.utils unescape", function() end end) +describe("menubar.utils lookup_icon_uncached", function() + local shimmed = {} + local icon_theme + + local function assert_found_in_path(icon, path) + assert.matches(path .. '$', utils.lookup_icon_uncached(icon) or '') + end + + setup(function() + local root = (os.getenv("SOURCE_DIRECTORY") or '.') .. "/spec/menubar" + + local function shim(name, retval) + shimmed[name] = glib[name] + glib[name] = function() return retval end + end + + shim('get_home_dir', root .. "/home") + shim('get_user_data_dir', root .. "/home/.local/share") + shim('get_system_data_dirs', { + root .. "/usr/local/share", + root .. "/usr/share" + }) + + icon_theme = theme.icon_theme + theme.icon_theme = 'awesome' + end) + + teardown(function() + for name, func in pairs(shimmed) do + glib[name] = func + end + theme.icon_theme = icon_theme + end) + + it('finds icons in icon base directories, in correct order', function() + + -- Shimmed icon base directories contain the following icons: + -- + -- usr/share/pixmaps/icon[1-5].png + -- usr/share/icons/icon[2-5].png + -- usr/local/share/icons/icon[3-5].png + -- .local/share/icons/icon[4-5].png + -- .icons/icon5.png + + assert_found_in_path('icon1', '/usr/share/pixmaps/icon1.png') + assert_found_in_path('icon2', '/usr/share/icons/icon2.png') + assert_found_in_path('icon3', '/usr/local/share/icons/icon3.png') + assert_found_in_path('icon4', '/.local/share/icons/icon4.png') + assert_found_in_path('icon5', '/.icons/icon5.png') + end) + + it('finds icons in $HOME/.icons///apps/', function() + + -- Theme 'awesome' in shimmed $HOME/.icons: + + assert_found_in_path('awesome', '/.icons/awesome/64x64/apps/awesome.png') + assert_found_in_path('awesome2', '/.icons/awesome/scalable/apps/awesome2.png') + end) +end) + -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80