36#include <glib/gstdio.h>
54 _dir = g_dir_make_tmp(
"ansel_test_image_cache_unreadable_XXXXXX", NULL);
78 GDir *
d = g_dir_open(dir, 0, NULL);
80 const char *
name = NULL;
81 while((
name = g_dir_read_name(
d)))
83 gchar *path = g_build_filename(dir,
name, NULL);
86 if(g_file_test(path, G_FILE_TEST_IS_DIR))
115 sqlite3 *other = NULL;
116 assert_int_equal(sqlite3_open(
_library, &other), SQLITE_OK);
117 assert_int_equal(sqlite3_exec(other,
"BEGIN EXCLUSIVE", NULL, NULL, NULL), SQLITE_OK);
120 sqlite3_exec(other,
"ROLLBACK", NULL, NULL, NULL);
121 sqlite3_close(other);
127static gboolean
_group_is(
const int32_t group_id,
const int32_t *members,
const int count)
130 gboolean same = (g_list_length(got) == (guint)count);
131 for(
int k = 0;
k < count;
k++)
132 same = same && !
IS_NULL_PTR(g_list_find(got, GINT_TO_POINTER(members[
k])));
141 assert_true(film > 0);
145 assert_true(*a > 0 && *b > 0 && *c > 0);
163 assert_true(
_group_is(b, (int32_t[]){ a, b, c }, 3));
168 assert_true(
_group_is(b, (int32_t[]){ a, b, c }, 3));
182 assert_true(
_group_is(b, (int32_t[]){ b, c }, 2));
183 assert_true(
_group_is(a, (int32_t[]){ a }, 1));
190 assert_true(film > 0);
193 assert_true(a > 0 && c > 0);
199 assert_true(
_group_is(c, (int32_t[]){ c }, 1));
207 GList *one = g_list_prepend(NULL, GINT_TO_POINTER(c));
212 assert_null(flagged);
220 gchar *src = g_build_filename(
_dir,
"src", NULL);
221 gchar *dst = g_build_filename(
_dir,
"dst", NULL);
222 assert_int_equal(g_mkdir(src, 0700), 0);
223 assert_int_equal(g_mkdir(dst, 0700), 0);
224 gchar *file = g_build_filename(src,
"x.raw", NULL);
225 gchar *moved = g_build_filename(dst,
"x.raw", NULL);
226 assert_true(g_file_set_contents(file,
"raw", -1, NULL));
230 assert_true(from > 0 && to > 0);
235 assert_true(dup > 0);
240 assert_true(g_file_test(moved, G_FILE_TEST_EXISTS));
250int main(
int argc,
char *argv[])
252 const struct CMUnitTest tests[] = {
259 return cmocka_run_group_tests(tests, NULL, NULL);
void dt_conf_cleanup(dt_conf_t *cf)
Free everything cf owns. No dt_conf_*() call is valid afterwards.
void dt_conf_init(dt_conf_t *cf, const char *filename, GSList *override_entries)
Populate cf from filename and from the generated defaults.
void dt_conf_set_string(const char *name, const char *val)
int32_t dt_image_move(const int32_t imgid, const int32_t filmid)
void dt_image_set_location(const int32_t imgid, const dt_image_geoloc_t *geoloc, const gboolean undo_on, const gboolean group_on)
void dt_image_get_location(const int32_t imgid, dt_image_geoloc_t *geoloc)
void dt_image_set_datetime(const GList *imgs, const char *datetime, const gboolean undo_on)
void dt_image_set_monochrome_flag(const int32_t imgid, gboolean monochrome)
void dt_image_xmp_mode_refresh_from_conf(void)
dt_database_open_result_t dt_database_open(const dt_database_params_t *params)
GtkWidget * folder
destination folder chooser
int dt_grouping_change_representative(const int32_t image_id)
int dt_grouping_remove_from_group(const int32_t image_id)
void dt_grouping_add_to_group(const int32_t group_id, const int32_t image_id)
@ DT_IMAGE_MONOCHROME_PREVIEW
void dt_image_cache_init(const gboolean verbose)
Initialise the cache.
dt_image_t * dt_image_cache_get(const int32_t imgid, char mode)
void dt_image_cache_cleanup(void)
GList * dt_image_repository_get_ids_with_flag_among(GList *imgids, const int flag)
Of the images in imgids, those whose flags carry flag, in row order.
gboolean dt_image_repository_set_group(const int32_t imgid, const int32_t group_id)
Set imgid's group_id.
int32_t dt_image_repository_duplicate(const int32_t imgid, const int32_t newversion)
Duplicate imgid as a new version, returning the new image id (-1 on failure).
int32_t dt_image_repository_find_by_film_and_filename(const int32_t film_id, const char *filename)
The image id for filename inside film roll film_id, or -1.
GList * dt_image_repository_get_group_members(const int32_t group_id, const int32_t exclude_imgid)
Image ids in group group_id.
static const dt_iop_drawlayer_params_t * params
float *const restrict const size_t k
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
const float uint32_t state[4]
The whole configuration state. One instance lives at darktable.conf.
static void _make_unreadable(const int32_t imgid)
static void test_setters_leave_an_unreadable_image_alone(void **state __attribute__((unused)))
static int _teardown(void **state)
static void test_rename_leaves_an_unreadable_duplicate_behind(void **state __attribute__((unused)))
static void _remove_tree(const gchar *dir)
static int _setup(void **state __attribute__((unused)))
static void _group_of_three(const char *folder, int32_t *a, int32_t *b, int32_t *c)
static void test_change_representative_moves_an_unreadable_member(void **state __attribute__((unused)))
static void test_remove_from_group_names_the_group_after_a_readable_member(void **state __attribute__((unused)))
static gboolean _group_is(const int32_t group_id, const int32_t *members, const int count)
Shared fixture for the src/database repository tests.
static int32_t testdb_make_film(const char *folder)
static int testdb_teardown(void **state)
static int32_t testdb_make_image(const int32_t film_id, const char *filename)