LCOV - code coverage report
Current view: top level - gio/tests - mount-operation.c (source / functions) Coverage Total Hit
Test: unnamed Lines: 100.0 % 53 53
Test Date: 2024-11-26 05:23:01 Functions: 100.0 % 3 3
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* GLib testing framework examples and tests
       2                 :             :  *
       3                 :             :  * Copyright © 2018 Endless Mobile, Inc.
       4                 :             :  *
       5                 :             :  * SPDX-License-Identifier: LGPL-2.1-or-later
       6                 :             :  *
       7                 :             :  * This library is free software; you can redistribute it and/or
       8                 :             :  * modify it under the terms of the GNU Lesser General Public
       9                 :             :  * License as published by the Free Software Foundation; either
      10                 :             :  * version 2.1 of the License, or (at your option) any later version.
      11                 :             :  *
      12                 :             :  * This library is distributed in the hope that it will be useful,
      13                 :             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15                 :             :  * Lesser General Public License for more details.
      16                 :             :  *
      17                 :             :  * You should have received a copy of the GNU Lesser General
      18                 :             :  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
      19                 :             :  *
      20                 :             :  * Author: Philip Withnall <withnall@endlessm.com>
      21                 :             :  */
      22                 :             : 
      23                 :             : #include <gio/gio.h>
      24                 :             : #include <locale.h>
      25                 :             : 
      26                 :             : 
      27                 :             : /* Smoketest for construction of a #GMountOperation. */
      28                 :             : static void
      29                 :           1 : test_construction (void)
      30                 :             : {
      31                 :           1 :   GMountOperation *op = NULL;
      32                 :             : 
      33                 :           1 :   op = g_mount_operation_new ();
      34                 :           1 :   g_assert_nonnull (op);
      35                 :           1 :   g_assert_true (G_IS_MOUNT_OPERATION (op));
      36                 :           1 :   g_object_unref (op);
      37                 :           1 : }
      38                 :             : 
      39                 :             : /* Test the property getters and setters on #GMountOperation work correctly. */
      40                 :             : static void
      41                 :           1 : test_properties (void)
      42                 :             : {
      43                 :           1 :   GMountOperation *op = NULL;
      44                 :           1 :   gchar *username = NULL;
      45                 :           1 :   gchar *password = NULL;
      46                 :             :   gboolean anonymous;
      47                 :           1 :   gchar *domain = NULL;
      48                 :             :   GPasswordSave password_save;
      49                 :             :   int choice;
      50                 :             :   gboolean hidden_volume;
      51                 :             :   gboolean system_volume;
      52                 :             :   guint pim;
      53                 :             : 
      54                 :           1 :   op = g_mount_operation_new ();
      55                 :             : 
      56                 :           1 :   g_object_get (op,
      57                 :             :                 "username", &username,
      58                 :             :                 "password", &password,
      59                 :             :                 "anonymous", &anonymous,
      60                 :             :                 "domain", &domain,
      61                 :             :                 "password-save", &password_save,
      62                 :             :                 "choice", &choice,
      63                 :             :                 "is-tcrypt-hidden-volume", &hidden_volume,
      64                 :             :                 "is-tcrypt-system-volume", &system_volume,
      65                 :             :                 "pim", &pim,
      66                 :             :                 NULL);
      67                 :             : 
      68                 :           1 :   g_assert_cmpstr (username, ==, g_mount_operation_get_username (op));
      69                 :           1 :   g_assert_cmpstr (password, ==, g_mount_operation_get_password (op));
      70                 :           1 :   g_assert_cmpint (anonymous, ==, g_mount_operation_get_anonymous (op));
      71                 :           1 :   g_assert_cmpstr (domain, ==, g_mount_operation_get_domain (op));
      72                 :           1 :   g_assert_cmpint (password_save, ==, g_mount_operation_get_password_save (op));
      73                 :           1 :   g_assert_cmpint (choice, ==, g_mount_operation_get_choice (op));
      74                 :           1 :   g_assert_cmpint (hidden_volume, ==, g_mount_operation_get_is_tcrypt_hidden_volume (op));
      75                 :           1 :   g_assert_cmpint (system_volume, ==, g_mount_operation_get_is_tcrypt_system_volume (op));
      76                 :           1 :   g_assert_cmpuint (pim, ==, g_mount_operation_get_pim (op));
      77                 :             : 
      78                 :           1 :   g_mount_operation_set_username (op, "username");
      79                 :           1 :   g_assert_cmpstr (g_mount_operation_get_username (op), ==, "username");
      80                 :             : 
      81                 :           1 :   g_mount_operation_set_password (op, "password");
      82                 :           1 :   g_assert_cmpstr (g_mount_operation_get_password (op), ==, "password");
      83                 :             : 
      84                 :           1 :   g_mount_operation_set_anonymous (op, !anonymous);
      85                 :           1 :   g_assert_cmpint (g_mount_operation_get_anonymous (op), ==, !anonymous);
      86                 :             : 
      87                 :           1 :   g_mount_operation_set_domain (op, "domain");
      88                 :           1 :   g_assert_cmpstr (g_mount_operation_get_domain (op), ==, "domain");
      89                 :             : 
      90                 :           1 :   g_mount_operation_set_password_save (op, G_PASSWORD_SAVE_NEVER);
      91                 :           1 :   g_assert_cmpint (g_mount_operation_get_password_save (op), ==, G_PASSWORD_SAVE_NEVER);
      92                 :             : 
      93                 :           1 :   g_mount_operation_set_choice (op, 5);
      94                 :           1 :   g_assert_cmpint (g_mount_operation_get_choice (op), ==, 5);
      95                 :             : 
      96                 :           1 :   g_mount_operation_set_is_tcrypt_hidden_volume (op, !hidden_volume);
      97                 :           1 :   g_assert_cmpint (g_mount_operation_get_is_tcrypt_hidden_volume (op), ==, !hidden_volume);
      98                 :             : 
      99                 :           1 :   g_mount_operation_set_is_tcrypt_system_volume (op, !system_volume);
     100                 :           1 :   g_assert_cmpint (g_mount_operation_get_is_tcrypt_system_volume (op), ==, !system_volume);
     101                 :             : 
     102                 :           1 :   g_mount_operation_set_pim (op, 5);
     103                 :           1 :   g_assert_cmpuint (g_mount_operation_get_pim (op), ==, 5);
     104                 :             : 
     105                 :           1 :   g_object_set (op,
     106                 :             :                 "username", "other-username",
     107                 :             :                 "password", "other-password",
     108                 :             :                 "anonymous", FALSE,
     109                 :             :                 "domain", "other-domain",
     110                 :             :                 "password-save", G_PASSWORD_SAVE_PERMANENTLY,
     111                 :             :                 "choice", 4,
     112                 :             :                 "is-tcrypt-hidden-volume", FALSE,
     113                 :             :                 "is-tcrypt-system-volume", FALSE,
     114                 :             :                 "pim", 4,
     115                 :             :                 NULL);
     116                 :             : 
     117                 :           1 :   g_free (domain);
     118                 :           1 :   g_free (password);
     119                 :           1 :   g_free (username);
     120                 :           1 :   g_object_unref (op);
     121                 :           1 : }
     122                 :             : 
     123                 :             : int
     124                 :           1 : main (int   argc,
     125                 :             :       char *argv[])
     126                 :             : {
     127                 :           1 :   setlocale (LC_ALL, "");
     128                 :           1 :   g_test_init (&argc, &argv, NULL);
     129                 :             : 
     130                 :           1 :   g_test_add_func ("/mount-operation/construction", test_construction);
     131                 :           1 :   g_test_add_func ("/mount-operation/properties", test_properties);
     132                 :             : 
     133                 :           1 :   return g_test_run ();
     134                 :             : }
        

Generated by: LCOV version 2.0-1