[gegl] tests: don't perform image diff in test-image-compare



commit 5a79e755ebf5d29e631e9b1e86c2404b2c081b4d
Author: Téo Mazars <teo mazars ensimag fr>
Date:   Thu Oct 24 08:22:33 2013 +0200

    tests: don't perform image diff in test-image-compare
    
    will be in composition instead

 tests/simple/test-image-compare.c |  219 ++-----------------------------------
 1 files changed, 11 insertions(+), 208 deletions(-)
---
diff --git a/tests/simple/test-image-compare.c b/tests/simple/test-image-compare.c
index 0a749d9..167f0b9 100644
--- a/tests/simple/test-image-compare.c
+++ b/tests/simple/test-image-compare.c
@@ -38,175 +38,21 @@ typedef struct
   gdouble max_diff;
   gdouble avg_diff_wrong;
   gdouble avg_diff_total;
-  const guchar  *output;
 } CompareResult;
 
-static gboolean compare_images  (GeglBuffer          *output_buffer,
-                                 const CompareResult *expected_result);
 static gboolean compare_values  (GeglNode            *comparison,
                                  const CompareResult *expected_result);
 static gboolean test_comparison (const gfloat        *reference,
                                  const gfloat        *test_case,
                                  const CompareResult *expected_result);
 
-const guchar alpha_ref[NUM_PIXELS * 3] =
-  {232, 232, 232, 132, 132, 132, 116, 116, 116, 115, 115, 115, 117, 117,
-   117, 119, 119, 119, 120, 120, 120, 122, 122, 122, 123, 123, 123, 124,
-   124, 124, 125, 125, 125, 126, 126, 126, 126, 126, 126, 127, 127, 127,
-   128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129,
-   129, 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
-   130, 130, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131,
-   131, 131, 131, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 62, 2, 0, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 62, 255, 0, 134, 134, 134,
-   134, 134, 134, 134, 134, 134};
-
-const guchar rgba_r_ref[NUM_PIXELS * 3] =
-  {232, 232, 232, 132, 132, 132, 116, 116, 116, 115, 115, 115, 117, 117,
-   117, 119, 119, 119, 120, 120, 120, 122, 122, 122, 123, 123, 123, 124,
-   124, 124, 125, 125, 125, 126, 126, 126, 126, 126, 126, 127, 127, 127,
-   128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129,
-   129, 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
-   130, 130, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131,
-   131, 131, 131, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 62, 2, 0,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   62, 255, 0, 134, 134, 134};
-
-const guchar rgba_g_ref[NUM_PIXELS * 3] =
-  {232, 232, 232, 132, 132, 132, 116, 116, 116, 115, 115, 115, 117, 117,
-   117, 119, 119, 119, 120, 120, 120, 122, 122, 122, 123, 123, 123, 124,
-   124, 124, 125, 125, 125, 126, 126, 126, 126, 126, 126, 127, 127, 127,
-   128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129,
-   129, 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
-   130, 130, 131, 131, 131, 63, 27, 0, 131, 131, 131, 131, 131, 131,
-   131, 131, 131, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 62, 255, 0, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134};
-
-const guchar rgba_b_ref[NUM_PIXELS * 3] =
-  {232, 232, 232, 132, 132, 132, 116, 116, 116, 115, 115, 115, 117, 117,
-   117, 119, 119, 119, 120, 120, 120, 122, 122, 122, 123, 123, 123, 124,
-   124, 124, 125, 125, 125, 126, 126, 126, 126, 126, 126, 127, 127, 127,
-   128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129,
-   129, 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
-   130, 130, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131,
-   131, 131, 131, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 62, 4, 0, 133,
-   133, 133, 133, 133, 133, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 62, 255, 0,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134};
-
-const guchar ok_ref[NUM_PIXELS * 3] =
-  {232, 232, 232, 132, 132, 132, 116, 116, 116, 115, 115, 115, 117, 117,
-   117, 119, 119, 119, 120, 120, 120, 122, 122, 122, 123, 123, 123, 124,
-   124, 124, 125, 125, 125, 126, 126, 126, 126, 126, 126, 127, 127, 127,
-   128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129,
-   129, 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
-   130, 130, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131,
-   131, 131, 131, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
-   132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-   133, 133, 133, 133, 133, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
-   134, 134, 134, 134, 134, 134};
-
 const CompareResult
 alpha_case =
   {
     2,           /* wrong pixels   */
     88.406395,   /* max diff       */
     44.703197,   /* avg_diff_wrong */
-    0.698487,    /* avg_diff_total */
-    alpha_ref    /* ref image      */
+    0.698487     /* avg_diff_total */
   };
 
 const CompareResult
@@ -215,8 +61,7 @@ rgba_r_case =
     2,
     108.086754,
     54.521946,
-    0.851905,
-    rgba_r_ref
+    0.851905
   };
 
 const CompareResult
@@ -225,8 +70,7 @@ rgba_g_case =
     2,
     1.945577,
     1.076242,
-    0.016816,
-    rgba_g_ref
+    0.016816
   };
 
 const CompareResult
@@ -235,8 +79,7 @@ rgba_b_case =
     2,
     33.873798,
     17.264227,
-    0.269754,
-    rgba_b_ref
+    0.269754
   };
 
 const CompareResult
@@ -245,37 +88,9 @@ ok_case =
     0,
     0.0,
     0.0,
-    0.0,
-    ok_ref
+    0.0
   };
 
-static gboolean
-compare_images (GeglBuffer          *output_buffer,
-                const CompareResult *expected_result)
-{
-  const Babl   *output_format = babl_format ("R'G'B' u8");
-  GeglRectangle extent;
-  guchar        output [NUM_PIXELS * 3];
-
-  extent = *GEGL_RECTANGLE (0, 0, NUM_COLS, NUM_ROWS);
-
-  if (! gegl_rectangle_equal (gegl_buffer_get_extent (output_buffer), &extent))
-    {
-      g_printerr ("Unexpected extent. ");
-      return FAILURE;
-    }
-
-  gegl_buffer_get (output_buffer, &extent, 1.0, output_format,
-                   output, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
-
-  if (memcmp (output, expected_result->output, NUM_PIXELS * 3) != 0)
-    {
-      g_printerr ("Output image differs. ");
-      return FAILURE;
-    }
-
-  return SUCCESS;
-}
 
 static gboolean
 compare_values (GeglNode            *comparison,
@@ -336,11 +151,10 @@ test_comparison (const gfloat        *reference,
 {
   GeglBuffer    *src_ref_buffer;
   GeglBuffer    *src_aux_buffer;
-  GeglBuffer    *sink_buffer = NULL;
   GeglRectangle  extent;
   const Babl    *input_format = babl_format ("R'G'B'A float");
-  GeglNode      *graph, *source_ref, *source_aux, *comparison, *sink;
-  gint           diff_result, values_result;
+  GeglNode      *graph, *source_ref, *source_aux, *comparison;
+  gint           test_result;
 
   /* Set up all buffers */
   extent = *GEGL_RECTANGLE (0, 0, NUM_COLS, NUM_ROWS);
@@ -366,32 +180,21 @@ test_comparison (const gfloat        *reference,
   comparison = gegl_node_new_child (graph,
                                     "operation", "gegl:image-compare",
                                     NULL);
-  sink       = gegl_node_new_child (graph,
-                                    "operation", "gegl:buffer-sink",
-                                    "buffer", &sink_buffer,
-                                    NULL);
 
-  gegl_node_link_many (source_ref, comparison, sink, NULL);
+  gegl_node_link_many (source_ref, comparison, NULL);
   gegl_node_connect_to (source_aux, "output",  comparison, "aux");
 
-  gegl_node_process (sink);
+  gegl_node_process (comparison);
 
   /* Compare with reference */
-  values_result = compare_values (comparison, expected_result);
-
-  /* Compare output images */
-  diff_result = compare_images (sink_buffer, expected_result);
+  test_result = compare_values (comparison, expected_result);
 
   /* We are done, clean and quit */
   g_object_unref (graph);
   g_object_unref (src_aux_buffer);
   g_object_unref (src_ref_buffer);
-  g_object_unref (sink_buffer);
 
-  if (diff_result != SUCCESS || values_result != SUCCESS)
-    return FAILURE;
-
-  return SUCCESS;
+  return test_result;
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]