Skip to content

Commit

Permalink
Update .travis.yml. Tests for findLargestIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Jun 6, 2016
1 parent 81b9362 commit bc4aa0c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -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
Expand Down
34 changes: 30 additions & 4 deletions source/icontheme/lookup.d
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bc4aa0c

Please sign in to comment.