ocarina/tests/lib/colmgr.cpp

63 lines
1.4 KiB
C++

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/idle.h>
#include <core/tags.h>
#include <lib/colmgr.h>
#include <lib/lib.h>
#include <tests/test.h>
#include <gtkmm.h>
#include <string>
void test_colmgr()
{
Library *library;
unsigned int count;
Gtk::TreePath path;
Gtk::TreeModel::Row row;
Glib::RefPtr<Gtk::ListStore> list;
list = lib :: get_object<Gtk::ListStore>("colmgr_list");
test_equal((size_t)list->children().size(), (size_t)0);
colmgr :: init();
test_equal((size_t)list->children().size(), (size_t)1);
colmgr :: add_path("/tmp/ocarina/");
test_equal((size_t)list->children().size(), (size_t)2);
while (idle :: run_task())
colmgr :: update_paths();
row = *list->children().end();
row--;
row->get_value(2, count);
test_equal(count, (unsigned)28);
path = Gtk::TreePath(row);
test_equal(colmgr :: get_path(path), Glib::ustring("/tmp/ocarina/"));
library = tagdb :: lookup_library(1);
test_equal(library->enabled, true);
colmgr :: toggle_path_enabled(path);
test_equal(library->enabled, false);
colmgr :: update_path(path);
test_equal(idle :: run_task(), true);
colmgr :: del_path(path);
test_equal((size_t)list->children().size(), (size_t)1);
}
int main(int argc, char **argv)
{
Gtk::Main ocarina(&argc, &argv);
test :: cp_data_dir();
test :: gen_library();
lib :: init(&argc, &argv, "ocarina6.glade");
run_test("Collection Manager Test", test_colmgr);
return 0;
}