From c9cabb78f1577e4a1802748605b86ed90c3dbc76 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 19 Aug 2014 08:54:07 -0400 Subject: [PATCH] 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 --- lib/colmgr.cpp | 4 ++-- tests/lib/colmgr.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/colmgr.cpp b/lib/colmgr.cpp index fc5f0d63..5eb92377 100644 --- a/lib/colmgr.cpp +++ b/lib/colmgr.cpp @@ -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::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(); } diff --git a/tests/lib/colmgr.cpp b/tests/lib/colmgr.cpp index 041d9656..c206486b 100644 --- a/tests/lib/colmgr.cpp +++ b/tests/lib/colmgr.cpp @@ -2,6 +2,7 @@ * Copyright 2014 (c) Anna Schumaker. */ #include +#include #include #include #include @@ -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)