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
24#ifdef _WIN32
25#include "win/main_wrapper.h"
26#endif
27
28static gboolean _store_contains(GtkTreeModel *model, const char *path)
29{
30 GtkTreeIter iter;
31 gboolean valid = gtk_tree_model_get_iter_first(model, &iter);
32 while(valid)
33 {
34 char *candidate = NULL;
35 gtk_tree_model_get(model, &iter, 0, &candidate, -1);
36 const gboolean found = !g_strcmp0(candidate, path);
37 g_free(candidate);
38 if(found) return TRUE;
39 valid = gtk_tree_model_iter_next(model, &iter);
40 }
41 return FALSE;
42}
43
45{
46 (void)state;
47 GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);
48 guint tagid = 0;
49
50 assert_true(dt_tag_new("subjects|animals", &tagid));
52 assert_true(_store_contains(GTK_TREE_MODEL(store), "subjects|animals"));
53
54 assert_true(dt_tag_new("subjects|animals|beetles", &tagid));
55 assert_false(_store_contains(GTK_TREE_MODEL(store), "subjects|animals|beetles"));
56
58 assert_true(_store_contains(GTK_TREE_MODEL(store), "subjects|animals|beetles"));
59 g_object_unref(store);
60}
61
62int main(int argc, char *argv[])
63{
64 const struct CMUnitTest tests[] = {
66 };
67 return cmocka_run_group_tests(tests, testdb_setup, testdb_teardown);
68}
#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
int main()
Definition prova.c:47
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