4 * Iterate over all pixel types, try to save pixmap but abort it from callback.
6 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz>
13 #include <core/GP_Pixmap.h>
14 #include <loaders/GP_Loaders.h>
18 typedef int (*Save)(const GP_Pixmap *src, const char *path, GP_ProgressCallback *callback);
20 static int progress_callback(GP_ProgressCallback *self)
26 static int test(Save Saver, GP_PixelType pixel_type)
29 GP_ProgressCallback callback ={.callback = progress_callback};
30 int ret = TST_SUCCESS;
32 src = GP_PixmapAlloc(100, 100, pixel_type);
35 tst_msg("Malloc failed");
39 if (Saver(src, "testfile", &callback)) {
40 if (errno == ENOSYS) {
41 tst_msg("Unimplemented pixel value");
46 if (errno == EINVAL) {
47 tst_msg("Invalid pixel value for the format");
52 if (errno == ECANCELED) {
53 if (access("testfile", F_OK) == 0) {
54 tst_msg("Operation canceled but file exists");
62 tst_msg("Saver failed with %s", strerror(errno));
66 tst_msg("Succedded unexpectedly");
76 @ for pt in pixeltypes:
77 @ if not pt.is_unknown():
78 static int test_{{ fmt }}_{{ pt.name }}(void)
80 return test(GP_Save{{ fmt }}, GP_PIXEL_{{ pt.name }});
85 const struct tst_suite tst_suite = {
86 .suite_name = "SaveAbort",
89 @ for pt in pixeltypes:
90 @ if not pt.is_unknown():
91 {.name = "{{ fmt }} {{ pt.name }}",
92 .tst_fn = test_{{ fmt }}_{{ pt.name }},
93 .flags = TST_TMPDIR | TST_CHECK_MALLOC},