diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2017-11-24 17:08:02 +0000 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2017-11-24 17:08:02 +0000 |
commit | b8ba7e7491d65670b16f9bdfb038db39fa964999 (patch) | |
tree | d2f2eb83593bf10b148240351f4ae1eabbae9b0f | |
parent | fedd2057a22c767792be1d51d3eabac83824a5a0 (diff) | |
download | imv-b8ba7e7491d65670b16f9bdfb038db39fa964999.tar.gz |
Update loader unit test
-rw-r--r-- | test/loader.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/test/loader.c b/test/loader.c index e8791c0..6798c25 100644 --- a/test/loader.c +++ b/test/loader.c @@ -11,23 +11,30 @@ static void test_jpeg_rotation(void **state) { (void)state; struct imv_loader *ldr = imv_loader_create(); - void *retval; - char *error; - unsigned int width; + assert_false(SDL_Init(SDL_INIT_VIDEO)); + unsigned int NEW_IMAGE = SDL_RegisterEvents(1); + unsigned int BAD_IMAGE = SDL_RegisterEvents(1); + imv_loader_set_event_types(ldr, NEW_IMAGE, BAD_IMAGE); imv_loader_load(ldr, "test/orientation.jpg", NULL, 0); - pthread_join(ldr->bg_thread, &retval); - error = imv_loader_get_error(ldr); - assert_false(error); + FIBITMAP *bmp = NULL; + SDL_Event event; + while(SDL_WaitEvent(&event)) { + assert_false(event.type == BAD_IMAGE); - assert_false(retval == PTHREAD_CANCELED); - assert_false(ldr->out_bmp == NULL); + if(event.type == NEW_IMAGE) { + bmp = event.user.data1; + break; + } + } - width = FreeImage_GetWidth(ldr->out_bmp); + assert_false(bmp == NULL); + unsigned int width = FreeImage_GetWidth(bmp); assert_true(width == 1); + FreeImage_Unload(bmp); imv_loader_free(ldr); } |