LCOV - code coverage report
Current view: top level - gio/tests - snapinfo-test.c (source / functions) Coverage Total Hit
Test: unnamed Lines: 100.0 % 21 21
Test Date: 2026-02-10 05:15:13 Functions: 100.0 % 1 1
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /**
       2                 :             :  * SPDX-License-Identifier: GPL-3.0-or-later
       3                 :             :  * SPDX-FileCopyrightText: 2025 Marco Trevisan (TreviƱo)
       4                 :             :  */
       5                 :             : 
       6                 :             : #include <stdlib.h>
       7                 :             : #include <gio/gio.h>
       8                 :             : 
       9                 :             : int
      10                 :           1 : main (int argc, char *argv[])
      11                 :             : {
      12                 :             :   const char *envvar;
      13                 :             :   const char *document_portal_mount;
      14                 :             :   char *expected;
      15                 :           1 :   char *expected_files[3] = {0};
      16                 :             :   gint pid_from_env;
      17                 :             : 
      18                 :           1 :   g_test_init (&argc, &argv, NULL);
      19                 :             : 
      20                 :           1 :   envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE");
      21                 :           1 :   g_assert_nonnull (envvar);
      22                 :             : 
      23                 :           1 :   expected = g_test_build_filename (G_TEST_BUILT, "snap-app_appinfo-test.desktop", NULL);
      24                 :           1 :   g_assert_cmpstr (envvar, ==, expected);
      25                 :           1 :   g_free (expected);
      26                 :             : 
      27                 :           1 :   envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
      28                 :           1 :   g_assert (envvar != NULL);
      29                 :           1 :   pid_from_env = atoi (envvar);
      30                 :           1 :   g_assert_cmpint (pid_from_env, ==, getpid ());
      31                 :             : 
      32                 :           1 :   document_portal_mount = g_getenv ("DOCUMENT_PORTAL_MOUNT_POINT");
      33                 :           1 :   g_assert_nonnull (document_portal_mount);
      34                 :             : 
      35                 :           1 :   expected_files[0] = g_build_filename (document_portal_mount,
      36                 :             :                                         "document-id-0", "snap-app_appinfo-test.desktop",
      37                 :             :                                         NULL);
      38                 :           1 :   expected_files[1] = g_build_filename (document_portal_mount,
      39                 :             :                                         "document-id-1", "appinfo-test.desktop",
      40                 :             :                                         NULL);
      41                 :             : 
      42                 :           1 :   g_assert_cmpint (argc, ==, 3);
      43                 :             : 
      44                 :           4 :   for (size_t i = 0; i < G_N_ELEMENTS (expected_files); ++i)
      45                 :             :     {
      46                 :           3 :       g_assert_cmpstr (argv[i+1], ==, expected_files[i]);
      47                 :           3 :       g_clear_pointer (&expected_files[i], g_free);
      48                 :             :     }
      49                 :             : 
      50                 :           1 :   return 0;
      51                 :             : }
        

Generated by: LCOV version 2.0-1