aboutsummaryrefslogtreecommitdiff
path: root/test/core.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-01-03 22:55:14 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-01-03 22:55:14 +0100
commitc0c710b15ab22f9ccb6b8b4ee4a92dbd38e7578f (patch)
tree1f705c9b42ce79f7030ce4d3ca76c2c2db478462 /test/core.c
parent69a98d15cb7390034ed06f183b97fd61718ddf2b (diff)
downloadd2tk-c0c710b15ab22f9ccb6b8b4ee4a92dbd38e7578f.tar.xz
test: create mock sprites.
Diffstat (limited to 'test/core.c')
-rw-r--r--test/core.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/test/core.c b/test/core.c
index 6fbefd4..6425f13 100644
--- a/test/core.c
+++ b/test/core.c
@@ -40,6 +40,7 @@ _d2tk_mock_pre(void *data, d2tk_core_t *core, d2tk_coord_t w, d2tk_coord_t h,
unsigned pass)
{
d2tk_mock_ctx_t *ctx = data;
+ assert(ctx);
ctx->pre.core = core;
ctx->pre.w = w;
@@ -52,6 +53,7 @@ _d2tk_mock_post(void *data, d2tk_core_t *core, d2tk_coord_t w, d2tk_coord_t h,
unsigned pass)
{
d2tk_mock_ctx_t *ctx = data;
+ assert(ctx);
ctx->post.core = core;
ctx->post.w = w;
@@ -62,12 +64,16 @@ _d2tk_mock_post(void *data, d2tk_core_t *core, d2tk_coord_t w, d2tk_coord_t h,
}
static inline void
-_d2tk_mock_sprite_free(void *data, uint8_t type __attribute__((unused)),
- uintptr_t body __attribute__((unused)))
+_d2tk_mock_sprite_free(void *data, uint8_t type, uintptr_t body)
{
d2tk_mock_ctx_t *ctx = data;
- (void)ctx;
- //FIXME
+ assert(ctx);
+
+ assert(type == 1);
+
+ uint32_t *dummy = (uint32_t *)body;
+ assert(*dummy == 1234);
+ free(dummy);
}
static inline void
@@ -75,6 +81,7 @@ _d2tk_mock_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
d2tk_coord_t xo, d2tk_coord_t yo, const d2tk_clip_t *clip, unsigned pass)
{
d2tk_mock_ctx_t *ctx = data;
+ assert(ctx);
ctx->process.core = core;
ctx->process.com = com;
@@ -90,6 +97,21 @@ _d2tk_mock_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
assert(body->cached == true);
assert(body->hash != 0x0); //FIXME
+ uintptr_t *sprite = d2tk_core_get_sprite(core, body->hash, 1);
+ assert(sprite);
+ assert(*sprite == 0);
+
+ uint32_t *dummy = calloc(1, sizeof(uint32_t));
+ assert(dummy);
+ *dummy = 1234;
+
+ *sprite = (uintptr_t)dummy;
+
+ assert(sprite == d2tk_core_get_sprite(core, body->hash, 1));
+ assert(sprite != d2tk_core_get_sprite(core, body->hash, 0));
+ assert(sprite != d2tk_core_get_sprite(core, ~body->hash, 1));
+ assert(sprite != d2tk_core_get_sprite(core, ~body->hash, 0));
+
unsigned num = 0;
D2TK_COM_FOREACH(com, bbox)
{