diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2020-03-01 09:23:16 +0000 |
---|---|---|
committer | Frediano Ziglio <freddy77@gmail.com> | 2020-05-06 12:22:09 +0100 |
commit | 8d969b66ed0d14bd57856764c21b0ee43c33148e (patch) | |
tree | 853d41dac87c27adfadcd403b5ad1829e977362c | |
parent | 5b93090e60620638d8bdd8d1a45cf6645a25c396 (diff) |
test-quic: Test fixed images
QUIC uses different methods to reduce image size.
One uses RLE on pixels. Using fixed images allows to better
test these paths increase code coverage.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
-rw-r--r-- | tests/test-quic.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/test-quic.c b/tests/test-quic.c index 6a5e3cf..5c04974 100644 --- a/tests/test-quic.c +++ b/tests/test-quic.c @@ -341,7 +341,7 @@ static void pixbuf_compare(GdkPixbuf *pixbuf_a, GdkPixbuf *pixbuf_b) } } -static GdkPixbuf *pixbuf_new_random(int alpha) +static GdkPixbuf *pixbuf_new_random(int alpha, bool fixed) { gboolean has_alpha = alpha >= 0 ? alpha : g_random_boolean(); gint width = g_random_int_range(100, 2000); @@ -354,7 +354,7 @@ static GdkPixbuf *pixbuf_new_random(int alpha) pixels = gdk_pixbuf_get_pixels(random_pixbuf); size = gdk_pixbuf_get_byte_length(random_pixbuf); for (i = 0; i < size; i++) { - pixels[i] = g_random_int_range(0, 256); + pixels[i] = fixed ? (gint)((i%(has_alpha?4:3))) << 5 : g_random_int_range(0, 256); } return random_pixbuf; @@ -394,14 +394,17 @@ int main(int argc, char **argv) g_object_unref(source_pixbuf); } } else if (argc == 1) { - int alpha; - for (alpha = 0; alpha < 2; alpha++) { + int test; + for (test = 0; test < 4; test++) { + int alpha = test % 2; + bool fixed = (test / 2) % 2; + for (color_mode = COLOR_MODE_RGB; color_mode < COLOR_MODE_END; color_mode++) { /* alpha affects only COLOR_MODE_RGB more, reduce number of tests */ if (color_mode != COLOR_MODE_RGB && alpha) { continue; } - GdkPixbuf *pixbuf = pixbuf_new_random(alpha); + GdkPixbuf *pixbuf = pixbuf_new_random(alpha, fixed); test_pixbuf(pixbuf); g_object_unref(pixbuf); } |