[Spice-commits] tests/test-quic.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 23 09:32:36 UTC 2020


 tests/test-quic.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 8d969b66ed0d14bd57856764c21b0ee43c33148e
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Mar 1 09:23:16 2020 +0000

    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 at gmail.com>

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);
             }


More information about the Spice-commits mailing list