colmgr: Make sure banned tracks are removed when reenabling a library

This issue was solved in Ocarina 6.1.3, but I didn't add a unit test for
it.  This patch adds a test.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-08-19 08:54:07 -04:00
parent 412dc67e1f
commit c9cabb78f1
2 changed files with 26 additions and 2 deletions

View File

@ -49,7 +49,7 @@ static void list_path(Library *lib)
row[c_cols.c_path] = lib->root_path;
}
static void library_remove_banned()
static void remove_banned_tracks()
{
std::set<unsigned int>::iterator it;
IndexEntry *ent = playlist :: get_tracks("Banned");
@ -118,5 +118,5 @@ void colmgr :: toggle_path_enabled(const Gtk::TreePath &path)
library :: set_enabled(lib, row[c_cols.c_enabled]);
if (row[c_cols.c_enabled])
library_remove_banned();
remove_banned_tracks();
}

View File

@ -2,6 +2,7 @@
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/idle.h>
#include <core/library.h>
#include <core/tags.h>
#include <lib/colmgr.h>
#include <lib/lib.h>
@ -29,6 +30,10 @@ void test_colmgr()
while (idle :: run_task())
colmgr :: update_paths();
/*
* Test using the newly added library path
*/
row = *list->children().end();
row--;
@ -48,6 +53,25 @@ void test_colmgr()
colmgr :: del_path(path);
test_equal((size_t)list->children().size(), (size_t)1);
/*
* Test using the original path
*/
row = *list->children().begin();
path = Gtk::TreePath(row);
library = tagdb :: lookup_library(0);
test_equal(library->enabled, true);
test_equal(library :: get_queue()->size(), (unsigned)20);
colmgr :: toggle_path_enabled(path);
test_equal(library->enabled, false);
test_equal(library :: get_queue()->size(), (unsigned)0);
colmgr :: toggle_path_enabled(path);
test_equal(library->enabled, true);
test_equal(library :: get_queue()->size(), (unsigned)20);
}
int main(int argc, char **argv)