Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_tagging_completion_model.c
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Paolo SANTUCCI.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "testdb.h"
20
22#include "metadata/tags.h"
23
24static gboolean _store_contains(GtkTreeModel *model, const char *path)
25{
26 GtkTreeIter iter;
27 gboolean valid = gtk_tree_model_get_iter_first(model, &iter);
28 while(valid)
29 {
30 char *candidate = NULL;
31 gtk_tree_model_get(model, &iter, 0, &candidate, -1);
32 const gboolean found = !g_strcmp0(candidate, path);
33 g_free(candidate);
34 if(found) return TRUE;
35 valid = gtk_tree_model_iter_next(model, &iter);
36 }
37 return FALSE;
38}
39
41{
42 (void)state;
43 GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);
44 guint tagid = 0;
45
46 assert_true(dt_tag_new("subjects|animals", &tagid));
48 assert_true(_store_contains(GTK_TREE_MODEL(store), "subjects|animals"));
49
50 assert_true(dt_tag_new("subjects|animals|beetles", &tagid));
51 assert_false(_store_contains(GTK_TREE_MODEL(store), "subjects|animals|beetles"));
52
54 assert_true(_store_contains(GTK_TREE_MODEL(store), "subjects|animals|beetles"));
55 g_object_unref(store);
56}
57
58int main(void)
59{
60 const struct CMUnitTest tests[] = {
62 };
63 return cmocka_run_group_tests(tests, testdb_setup, testdb_teardown);
64}
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
GtkTreeStore * store
its model, owned by the view
const char * model
const float uint32_t state[4]
void dt_tagging_completion_refresh(GtkListStore *store)
gboolean dt_tag_new(const char *name, guint *tagid)
Definition tags.c:164
static gboolean _store_contains(GtkTreeModel *model, const char *path)
static void test_refresh_exposes_new_hierarchical_tag(void **state)
Shared fixture for the src/database repository tests.
static int testdb_setup(void **state)
Definition testdb.h:55
static int testdb_teardown(void **state)
Definition testdb.h:66