49#define SEEDED_FLAGS 0x51
51#define SEEDED_VERSION 7
54static void _seed_every_table(
const int32_t imgid,
const char *tag_name,
const char *meta_value)
64 "\x03", 1, 9, 0,
"the instance"));
66 "\xAA\xBB", 2, 2,
"\x00", 1));
73 assert_true(tagid > 0);
89 g_list_free(survivors);
94static gboolean
_in_group(
const int32_t group_id,
const int32_t imgid)
97 const gboolean found = !
IS_NULL_PTR(g_list_find(members, GINT_TO_POINTER(imgid)));
104 GList *one = g_list_prepend(NULL, GINT_TO_POINTER(imgid));
106 const gboolean found = (g_list_length(flagged) == 1);
107 g_list_free(flagged);
116 assert_true(film > 0 && imgid > 0);
120 assert_true(snap >= 0);
148 assert_int_equal(order.
version, 2);
149 assert_string_equal(order.
iop_list,
"exposure,colorin");
156 assert_int_equal(g_list_length(labels), 1);
162 assert_int_equal(g_list_length(values), 1);
163 assert_string_equal((
const char *)values->data,
"a creator");
164 g_list_free_full(values, g_free);
173 assert_true(a > 0 && b > 0 && c > 0);
179 assert_true(snap >= 0);
198 assert_true(film > 0 && imgid > 0);
201 assert_true(snap >= 0);
215 GList *ids = g_list_prepend(NULL, GINT_TO_POINTER(imgid));
217 assert_int_equal(g_list_length(paths), 1);
218 assert_string_equal((
const char *)paths->data,
"/testdb/removal/film/only.raw");
219 g_list_free_full(paths, g_free);
235 assert_true(snap_b >= 0);
239 assert_true(snap_a >= 0);
261 assert_true(a > 0 && b > 0 && c > 0);
268 assert_true(snap_a >= 0);
271 assert_true(snap_b >= 0);
274 assert_true(snap_c >= 0);
300 assert_true(snap >= 0);
321 assert_true(first >= 0);
329 assert_true(second >= 0);
330 assert_int_not_equal(second, first);
340 const struct CMUnitTest tests[] = {
gboolean dt_colorlabel_repository_has(const int32_t imgid, const int color)
TRUE when colour color is set on imgid.
void dt_colorlabel_repository_set(const int32_t imgid, const int color)
Set colour color on imgid. Setting one that is already set does nothing.
GList * dt_colorlabel_repository_get_list(const int32_t imgid)
The colours set on imgid, as a list rather than a bitmask.
int32_t dt_film_repository_find_by_folder(const char *folder)
gboolean dt_film_repository_delete(const int32_t id)
gboolean dt_history_repository_get_module_order(const int32_t imgid, dt_module_order_row_t *row)
Read imgid's row. FALSE when there is none, and row is then left zeroed.
gboolean dt_history_repository_write_item(const int32_t imgid, const int num, const char *operation, const void *op_params, const int op_params_size, const int module_version, const gboolean enabled, const void *blendop_params, const int blendop_params_size, const int blendop_version, const int multi_priority, const char *multi_name)
gboolean dt_history_repository_write_mask_item(const int32_t imgid, const int num, const int formid, const int form, const char *name, const int version, const void *points, const int points_len, const int points_count, const void *source, const int source_len)
int dt_history_repository_count_mask_items(const int32_t imgid)
void dt_module_order_row_cleanup(dt_module_order_row_t *row)
Release what dt_history_repository_get_module_order() allocated.
gboolean dt_history_repository_set_module_order(const int32_t imgid, const int version, const char *iop_list)
Store imgid's order: version, and iop_list serialized or NULL.
int dt_history_repository_count_items(const int32_t imgid)
gboolean dt_history_repository_set_end(const int32_t imgid, const int32_t history_end)
int32_t dt_history_repository_get_end(const int32_t imgid)
int dt_image_repository_get_version(const int32_t imgid)
The duplicate version number of imgid, or 0.
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.
gboolean dt_image_repository_delete(const int32_t imgid)
Delete imgid from main.images and main.meta_data.
gboolean dt_image_repository_set_flags(const int32_t imgid, const int flags)
Replace imgid's whole flags word.
void dt_image_repository_reassign_group(const int32_t from_group_id, const int32_t to_group_id, const int32_t exclude_imgid)
Move every member of from_group_id into to_group_id, except exclude_imgid.
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.
gboolean dt_image_repository_set_version(const int32_t imgid, const int version)
Set both version and max_version of imgid to version.
GList * dt_image_repository_get_group_members(const int32_t group_id, const int32_t exclude_imgid)
Image ids in group group_id.
GList * dt_image_repository_get_full_paths(GList *imgids)
"<folder>/<filename>" for every image in imgids, distinct, in row order. Caller owns the strings.
static CameraMetaData * meta
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
dt_mipmap_buffer_dsc_flags flags
void dt_removed_image_repository_clear(const int snap_id, const int32_t imgid)
Drop snapshot snap_id of imgid, making the removal permanent.
gboolean dt_removed_image_repository_restore(const int snap_id, const int32_t imgid)
Copy snapshot snap_id of imgid back into main, film roll included.
int dt_removed_image_repository_create(const int32_t imgid)
Copy every row imgid owns out of main, so the removal about to happen can be undone.
memory.removed_*: the staging area behind "undo remove from library".
const float uint32_t state[4]
One main.module_order row.
gboolean dt_tag_repository_attach(const guint tagid, const int32_t imgid)
Attach tagid to imgid, at the end of the tag order.
gboolean dt_tag_repository_is_attached(const guint tagid, const int32_t imgid)
TRUE when tagid is attached to imgid.
guint dt_tag_repository_insert(const char *name)
Insert a tag named name and return its new id, or 0 on failure.
static void test_group_leader_restores_membership(void **state)
static void test_partial_undo_repoints_a_departed_leader(void **state)
static void test_whole_group_removed_and_fully_undone_keeps_one_group(void **state)
static void test_clear_drops_the_snapshot(void **state)
static gboolean _has_flags(const int32_t imgid, const int flags)
static gboolean _in_group(const int32_t group_id, const int32_t imgid)
static void test_film_roll_comes_back_with_its_last_image(void **state)
static void _remove(const int32_t imgid)
static void _seed_every_table(const int32_t imgid, const char *tag_name, const char *meta_value)
static void test_round_trip_restores_every_table(void **state)
static void test_successive_snapshots_do_not_collide(void **state)
Shared fixture for the src/database repository tests.
static int testdb_setup(void **state)
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)