From bc4aa0cfe9a81aab7e98ee4dae74f1ea9700d7d6 Mon Sep 17 00:00:00 2001 From: FreeSlave Date: Tue, 7 Jun 2016 02:17:10 +0300 Subject: [PATCH] Update .travis.yml. Tests for findLargestIcon --- .travis.yml | 3 +-- source/icontheme/lookup.d | 34 +++++++++++++++++++++++--- test/Tango/32x32/places/desktop.png | 0 test/Tango/scalable/places/desktop.svg | 0 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 test/Tango/32x32/places/desktop.png create mode 100644 test/Tango/scalable/places/desktop.svg diff --git a/.travis.yml b/.travis.yml index 49607ca..8aac0ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,13 @@ language: d matrix: allow_failures: - d: gdc-4.9.2 - - d: ldc-0.14.0 + - d: ldc-0.15.1 include: - d: dmd-2.069.2 env: USE_DOVERALLS=true - d: dmd-2.067.1 - d: gdc-4.9.2 - d: ldc-0.15.1 - - d: ldc-0.14.0 script: - chmod +x travis-script.sh diff --git a/source/icontheme/lookup.d b/source/icontheme/lookup.d index bfcf5db..fad45cc 100644 --- a/source/icontheme/lookup.d +++ b/source/icontheme/lookup.d @@ -198,14 +198,14 @@ if (isInputRange!(IconThemes) && isForwardRange!(BaseDirs) && isForwardRange!(Ex { alias Tuple!(string, IconSubDir, ElementType!IconThemes) Tripplet; - return iconThemes.filter!(iconTheme => iconTheme !is null && iconTheme.internalName().length != 0) + return inputRangeObject(iconThemes.filter!(iconTheme => iconTheme !is null && iconTheme.internalName().length != 0) .map!(iconTheme => tuple(iconTheme, searchIconDirs.map!(dir => buildPath(dir, iconTheme.internalName())) .filter!(function(themeBaseDir) { bool ok; collectException(themeBaseDir.isDir, ok); return ok; - }).array)) - .cache().map!(delegate(t) { + }).array))) + .map!(delegate(t) { auto iconTheme = t[0]; auto themeBaseDirs = t[1]; return iconTheme.bySubdir().filter!(subdirFilter).map!(delegate(subdir) { @@ -494,11 +494,37 @@ string findLargestIcon(alias subdirFilter = (a => true), IconThemes, BaseDirs, E } } +/// +unittest +{ + auto baseDirs = ["test"]; + auto iconThemes = [openIconTheme("Tango", baseDirs), openIconTheme("hicolor", baseDirs)]; + + string found; + + found = findLargestIcon("folder", iconThemes, baseDirs); + assert(found == buildPath("test", "Tango", "128x128", "places", "folder.png")); + + found = findLargestIcon("desktop", iconThemes, baseDirs); + assert(found == buildPath("test", "Tango", "32x32", "places", "desktop.png")); + + found = findLargestIcon("desktop", iconThemes, baseDirs, [".svg", ".png"]); + assert(found == buildPath("test", "Tango", "scalable", "places", "desktop.svg")); + + //lookup with fallback + found = findLargestIcon("pidgin", iconThemes, baseDirs); + assert(found == buildPath("test", "pidgin.png")); + + //lookup without fallback + found = findLargestIcon("pidgin", iconThemes, baseDirs, defaultIconExtensions, No.allowFallbackIcon); + assert(found.empty); +} + /** * ditto, but with predefined extensions and fallback allowed. * See_Also: defaultIconExtensions */ -string findLargestIcon(alias subdirFilter = (a => true), IconThemes, BaseDirs, Exts)(string iconName, IconThemes iconThemes, BaseDirs searchIconDirs) +string findLargestIcon(alias subdirFilter = (a => true), IconThemes, BaseDirs)(string iconName, IconThemes iconThemes, BaseDirs searchIconDirs) { return findLargestIcon!subdirFilter(iconName, iconThemes, searchIconDirs, defaultIconExtensions); } diff --git a/test/Tango/32x32/places/desktop.png b/test/Tango/32x32/places/desktop.png new file mode 100644 index 0000000..e69de29 diff --git a/test/Tango/scalable/places/desktop.svg b/test/Tango/scalable/places/desktop.svg new file mode 100644 index 0000000..e69de29