[gnome-photos/wip/rishi/buffer-decoder: 19/19] tests: use cairo and simplify



commit ed831b4c35a961e146c2a17c8b9c73673123e439
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Dec 23 09:48:22 2018 +0100

    tests: use cairo and simplify

 tests/unit/photos-test-gegl-buffer.c | 193 +++++++++++++++++++++++++----------
 1 file changed, 141 insertions(+), 52 deletions(-)
---
diff --git a/tests/unit/photos-test-gegl-buffer.c b/tests/unit/photos-test-gegl-buffer.c
index f30e1911..dc3a4917 100644
--- a/tests/unit/photos-test-gegl-buffer.c
+++ b/tests/unit/photos-test-gegl-buffer.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2018 Red Hat, Inc.
+ * Copyright © 2018 – 2019 Red Hat, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -99,7 +99,6 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
   GeglColor *checkerboard_color2 = NULL; /* TODO: use g_autoptr */
   GeglNode *buffer_sink;
   GeglNode *checkerboard;
-  GeglNode *convert_format;
   GeglNode *crop;
   GeglNode *tail;
   g_autoptr (GeglNode) graph = NULL;
@@ -296,7 +295,20 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         "C268.601,307.601 274.601,292.801 273.001,288.801 "
         "C273.001,288.801 278.201,289.601 278.601,294.001 "
         "C278.601,294.001 282.601,270.801 277.801,264.801 "
-        "C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 
290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 
243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 
214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 
209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 
164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 
156.001C307.401 156.001 307.001 154.401 303.801 150.401 "
+        "C277.801,264.801 282.201,264.001 283.401,267.601 "
+        "L283.401,260.401 "
+        "C283.401,260.401 290.601,261.201 290.601,258.801 "
+        "C290.601,258.801 295.001,254.801 297.001,259.601 "
+        "C297.001,259.601 284.601,224.401 303.001,243.601 "
+        "C303.001,243.601 310.201,254.401 306.601,235.601 "
+        "C303.001,216.801 299.001,215.201 303.801,214.801 "
+        "C303.801,214.801 304.601,211.201 302.601,209.601 "
+        "C300.601,208.001 303.801,209.601 303.801,209.601 "
+        "C303.801,209.601 308.601,213.601 303.401,191.601 "
+        "C303.401,191.601 309.801,193.201 297.801,164.001 "
+        "C297.801,164.001 300.601,161.601 296.601,153.201 "
+        "C296.601,153.201 304.601,157.601 307.401,156.001 "
+        "C307.401,156.001 307.001,154.401 303.801,150.401 "
         "C303.801,150.401 282.201,95.6 302.601,117.601 "
         "C302.601,117.601 314.451,131.151 308.051,108.351 "
         "C308.051,108.351 298.94,84.341 299.717,80.045 "
@@ -307,8 +319,49 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         1
       },
       {
-        "M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 
75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 
301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 
-53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 
-119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 
-139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 
-129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 
-103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 
-51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 
-42 -69.4 -39.2C-69.4 -39.2 -77 -2
 5.2 -75.
 8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 
-6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 
-97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4 "
-        "C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 
102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245 "
+        "M299.717,80.245 "
+        "C300.345,80.426 302.551,81.55 303.801,83.2 "
+        "C303.801,83.2 310.601,94 305.401,75.6 "
+        "C305.401,75.6 296.201,46.8 305.001,58 "
+        "C305.001,58 311.001,65.2 307.801,51.6 "
+        "C303.936,35.173 301.401,28.8 301.401,28.8 "
+        "C301.401,28.8 313.001,33.6 286.201,-6 "
+        "L295.001,-2.4 "
+        "C295.001,-2.4 275.401,-42 253.801,-47.2 "
+        "L245.801,-53.2 "
+        "C245.801,-53.2 284.201,-91.2 271.401,-128 "
+        "C271.401,-128 264.601,-133.2 255.001,-124 "
+        "C255.001,-124 248.601,-119.2 242.601,-120.8 "
+        "C242.601,-120.8 211.801,-119.6 209.801,-119.6 "
+        "C207.801,-119.6 173.001,-156.8 107.401,-139.2 "
+        "C107.401,-139.2 102.201,-137.2 97.801,-138.4 "
+        "C97.801,-138.4 79.4,-154.4 30.6,-131.6 "
+        "C30.6,-131.6 20.6,-129.6 19,-129.6 "
+        "C17.4,-129.6 14.6,-129.6 6.6,-123.2 "
+        "C-1.4,-116.8 -1.8,-116 -3.8,-114.4 "
+        "C-3.8,-114.4 -20.2,-103.2 -25,-102.4 "
+        "C-25,-102.4 -36.6,-96 -41,-86 "
+        "L-44.6,-84.8 "
+        "C-44.6,-84.8 -46.2,-77.6 -46.6,-76.4 "
+        "C-46.6,-76.4 -51.4,-72.8 -52.2,-67.2 "
+        "C-52.2,-67.2 -61,-61.2 -60.6,-56.8 "
+        "C-60.6,-56.8 -62.2,-51.6 -63,-46.8 "
+        "C-63,-46.8 -70.2,-42 -69.4,-39.2 "
+        "C-69.4,-39.2 -77,-25.2 -75.8,-18.4 "
+        "C-75.8,-18.4 -82.2,-18.8 -85,-16.4 "
+        "C-85,-16.4 -85.8,-11.6 -87.4,-11.2 "
+        "C-87.4,-11.2 -90.2,-10 -87.8,-6 "
+        "C-87.8,-6 -89.4,-3.2 -89.8,-1.6 "
+        "C-89.8,-1.6 -89,1.2 -93.4,6.8 "
+        "C-93.4,6.8 -99.8,25.6 -97.8,30.8 "
+        "C-97.8,30.8 -97.4,35.6 -100.2,37.2 "
+        "C-100.2,37.2 -103.8,36.8 -95.4,48.8 "
+        "C-95.4,48.8 -94.6,50 -97.8,52.4 "
+        "C-97.8,52.4 -115,56 -117.4,72.4 "
+        "C-117.4,72.4 -131,87.2 -131,92.4 "
+        "C-131,94.705 -130.729,97.852 -130.03,102.465 "
+        "C-130.03,102.465 -130.6,110.801 -103,111.601 "
+        "C-75.4,112.401 299.717,80.245 299.717,80.245 "
         "z",
         "#cc7226",
         "#000000",
@@ -317,7 +370,10 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       {
         "M-115.6,102.6 "
         "C-140.6,63.2 -126.2,119.601 -126.2,119.601 "
-        "C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 
84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 
46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 
60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 
99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91 "
+        "C-117.4,154.001 12.2,116.401 12.2,116.401 "
+        "C12.2,116.401 181.001,86 192.201,82 "
+        "C203.401,78 298.601,84.4 298.601,84.4 "
+        "L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 
47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 
49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 
93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91 "
         "L-115.6,102.6 "
         "z",
         "#cc7226",
@@ -328,7 +384,9 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         "M133.51,25.346 "
         "C127.11,26.146 101.743,2.407 116.71,34.146 "
         "C133.31,69.346 58.31,73.346 41.51,62.146 "
-        "C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 
-25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 
-77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 
122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 
83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 
42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346 "
+        "C24.709,50.946 48.71,80.546 48.71,80.546 "
+        "C67.11,100.546 32.709,83.746 32.709,83.746 "
+        "C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 
88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 
64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 
87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 
196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346 "
         "z",
         "#e87f3a",
         "#00000000",
@@ -598,13 +656,13 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       },
       {
         "M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 
245.201 12.6 245.201",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
       {
         "M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 
238.001 47.6 233.801 52.6 230.801",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
@@ -618,14 +676,14 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       {
         "M47,244.801 "
         "C47,244.801 50.6,242.401 53,243.601",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
       {
         "M53.5,228.401 "
         "C53.5,228.401 56.4,223.501 61.2,222.701",
-        "#000000",
+        NULL,
         "#a5264c",
         2.0
       },
@@ -785,7 +843,9 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         1.0
       },
       {
-        "M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6 "
+        "M55.4,19.6 "
+        "C55.4,19.6 51,16.4 51,18.6 "
+        "C51,18.6 54.6,23 55.4,19.6 "
         "z",
         "#ffffff",
         "#00000000",
@@ -939,7 +999,10 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         1.0
       },
       {
-        "M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237 "
+        "M292.5,237 "
+        "C292.5,237 230,177.5 228.5,175 "
+        "C228.5,175 289,241 292,248.5 "
+        "C292,248.5 290,239.5 292.5,237 "
         "z",
         "#cccccc",
         "#00000000",
@@ -1047,7 +1110,9 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       },
       {
         "M22.2,63.4 "
-        "C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4",
+        "C22.2,63.4 6.8,52.4 5.8,51 "
+        "C5.8,51 -1.2,40 -14.2,39.6 "
+        "C-14.2,39.6 -35.6,40.4 -52.8,48.4",
         "#000000",
         "#4c0000",
         2.0
@@ -1888,14 +1953,21 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
         1.0
       },
       {
-        "M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 
281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401 "
+        "M-59.8,298.401 "
+        "C-59.8,298.401 -55,279.601 -52.4,279.801 "
+        "C-52.4,279.801 -44.2,270.801 -50.8,281.401 "
+        "C-50.8,281.401 -56.8,291.001 -56.2,300.801 "
+        "C-56.2,300.801 -56.8,291.201 -59.8,298.401 "
         "z",
         "#cccccc",
         "#00000000",
         1.0
       },
       {
-        "M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 
287 "
+        "M270.5,287 "
+        "C270.5,287 258.5,277 256,273.5 "
+        "C256,273.5 269.5,292 269.5,299 "
+        "C269.5,299 272,291.5 270.5,287 "
         "z",
         "#cccccc",
         "#00000000",
@@ -1934,28 +2006,28 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
       {
         "M-89.25,169 "
         "L-67.25,173.75",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       },
       {
         "M-39,331 "
         "C-39,331 -39.5,327.5 -48.5,338",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       },
       {
         "M-33.5,336 "
         "C-33.5,336 -31.5,329.5 -38,334",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       },
       {
         "M20.5,344.5 "
         "C20.5,344.5 22,333.5 10.5,346.5",
-        "#000000",
+        NULL,
         "#000000",
         1.0
       }
@@ -1990,16 +2062,16 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
                                       "operation", "gegl:checkerboard",
                                       "color1", checkerboard_color1,
                                       "color2", checkerboard_color2,
-                                      "x", 5,
-                                      "y", 5,
+                                      "x", 25,
+                                      "y", 25,
                                       NULL);
 
   crop = gegl_node_new_child (graph,
                               "operation", "gegl:crop",
-                              "height", 640.0,
-                              "width", 640.0,
-                              "x", -180.0,
-                              "y", -180.0,
+                              "height", 600.0,
+                              "width", 600.0,
+                              "x", -200.0,
+                              "y", -200.0,
                               NULL);
 
   gegl_node_link (checkerboard, crop);
@@ -2007,41 +2079,58 @@ photos_test_gegl_buffer_setup (PhotosTestGeglBufferFixture *fixture, gconstpoint
 
   for (i = 0; i < G_N_ELEMENTS (paths); i++)
     {
-      GeglColor *fill = NULL; /* TODO: use g_autoptr */
-      GeglColor *stroke = NULL; /* TODO: use g_autoptr */
-      GeglNode *over;
-      GeglNode *path;
       GeglPath *d = NULL; /* TODO: use g_autoptr */
 
-      over = gegl_node_new_child (graph, "operation", "svg:src-over", NULL);
-
       d = gegl_path_new_from_string (paths[i].d);
-      fill = gegl_color_new (paths[i].fill);
-      stroke = gegl_color_new (paths[i].stroke);
-      path = gegl_node_new_child (graph,
-                                  "operation", "gegl:path",
-                                  "d", d,
-                                  "fill", fill,
-                                  "stroke", stroke,
-                                  "stroke-hardness", 1.0,
-                                  "stroke-width", paths[i].stroke_width,
-                                  NULL);
-
-      gegl_node_connect_to (path, "output", over, "aux");
-      gegl_node_link (tail, over);
-      tail = over;
+
+      if (paths[i].fill != NULL)
+        {
+          GeglColor *color = NULL; /* TODO: use g_autoptr */
+          GeglNode *fill_path;
+
+          color = gegl_color_new (paths[i].fill);
+          fill_path = gegl_node_new_child (graph,
+                                           "operation", "gegl:fill-path",
+                                           "d", d,
+                                           "color", color,
+                                           NULL);
+
+          gegl_node_link (tail, fill_path);
+          tail = fill_path;
+
+          g_object_unref (color);
+        }
+
+      if (paths[i].stroke != NULL)
+        {
+          GeglColor *color = NULL; /* TODO: use g_autoptr */
+          GeglNode *vector_stroke;
+
+          color = gegl_color_new (paths[i].stroke);
+          vector_stroke = gegl_node_new_child (graph,
+                                               "operation", "gegl:vector-stroke",
+                                               "d", d,
+                                               "color", color,
+                                               "width", paths[i].stroke_width,
+                                               NULL);
+
+          gegl_node_link (tail, vector_stroke);
+          tail = vector_stroke;
+
+          g_object_unref (color);
+        }
 
       g_object_unref (d);
-      g_object_unref (fill);
-      g_object_unref (stroke);
     }
 
   format = babl_format ("R'G'B'A u8");
-  convert_format = gegl_node_new_child (graph, "operation", "gegl:convert-format", "format", format, NULL);
-
-  buffer_sink = gegl_node_new_child (graph, "operation", "gegl:buffer-sink", "buffer", &buffer, NULL);
+  buffer_sink = gegl_node_new_child (graph,
+                                     "operation", "gegl:buffer-sink",
+                                     "buffer", &buffer,
+                                     "format", format,
+                                     NULL);
 
-  gegl_node_link_many (tail, convert_format, buffer_sink, NULL);
+  gegl_node_link (tail, buffer_sink);
   gegl_node_process (buffer_sink);
 
   fixture->buffer = g_object_ref (buffer);


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