LCOV - code coverage report
Current view: top level - glib/glib/tests - bookmarkfile.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 787 803 98.0 %
Date: 2024-04-16 05:15:53 Functions: 12 12 100.0 %
Branches: 64 104 61.5 %

           Branch data     Line data    Source code
       1                 :            : #include <glib.h>
       2                 :            : #include <glib/gstdio.h>
       3                 :            : 
       4                 :            : #define TEST_URI_0      "file:///abc/defgh/ijklmnopqrstuvwxyz"
       5                 :            : #define TEST_URI_1      "file:///test/uri/1"
       6                 :            : #define TEST_URI_2      "file:///test/uri/2"
       7                 :            : 
       8                 :            : #define TEST_MIME       "text/plain"
       9                 :            : 
      10                 :            : #define TEST_APP_NAME   "bookmarkfile-test"
      11                 :            : #define TEST_APP_EXEC   "bookmarkfile-test %f"
      12                 :            : 
      13                 :            : static void
      14                 :          1 : test_load_from_data_dirs (void)
      15                 :            : {
      16                 :            :   GBookmarkFile *bookmark;
      17                 :            :   gboolean res;
      18                 :          1 :   gchar *path = NULL;
      19                 :          1 :   GError *error = NULL;
      20                 :            : 
      21                 :          1 :   bookmark = g_bookmark_file_new ();
      22                 :            : 
      23                 :          1 :   res = g_bookmark_file_load_from_data_dirs (bookmark, "no-such-bookmark-file.xbel", &path, &error);
      24                 :            : 
      25                 :          1 :   g_assert_false (res);
      26                 :          1 :   g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
      27                 :          1 :   g_assert_null (path);
      28                 :          1 :   g_error_free (error);
      29                 :            : 
      30                 :          1 :   g_bookmark_file_free (bookmark);  
      31                 :          1 : }
      32                 :            : 
      33                 :            : static void
      34                 :          1 : test_to_file (void)
      35                 :            : {
      36                 :            :   GBookmarkFile *bookmark;
      37                 :            :   const gchar *filename;
      38                 :            :   gboolean res;
      39                 :          1 :   GError *error = NULL;
      40                 :            :   char *in, *out;
      41                 :          1 :   gchar *tmp_filename = NULL;
      42                 :            :   gint fd;
      43                 :            : 
      44                 :          1 :   fd = g_file_open_tmp ("bookmarkfile-test-XXXXXX.xbel", &tmp_filename, NULL);
      45                 :          1 :   g_assert_cmpint (fd, >, -1);
      46                 :          1 :   g_close (fd, NULL);
      47                 :            : 
      48                 :          1 :   bookmark = g_bookmark_file_new ();
      49                 :            : 
      50                 :          1 :   g_test_message ("Roundtrip from newly created bookmark file %s", tmp_filename);
      51                 :          1 :   g_bookmark_file_set_title (bookmark, "file:///tmp/schedule.ps", "schedule.ps");
      52                 :          1 :   g_bookmark_file_set_mime_type (bookmark, "file:///tmp/schedule.ps", "application/postscript");
      53                 :          1 :   g_bookmark_file_add_application (bookmark, "file:///tmp/schedule.ps", "ghostscript", "ghostscript %F");
      54                 :            : 
      55                 :          1 :   res = g_bookmark_file_to_file (bookmark, tmp_filename, &error);
      56                 :          1 :   g_assert_no_error (error);
      57                 :          1 :   g_assert_true (res);
      58                 :            : 
      59                 :          1 :   res = g_bookmark_file_load_from_file (bookmark, tmp_filename, &error);
      60                 :          1 :   g_assert_no_error (error);
      61                 :          1 :   g_assert_true (res);
      62                 :            : 
      63                 :          1 :   out = g_bookmark_file_get_title (bookmark, "file:///tmp/schedule.ps", &error);
      64                 :          1 :   g_assert_no_error (error);
      65                 :          1 :   g_assert_cmpstr (out, ==, "schedule.ps");
      66                 :          1 :   g_free (out);
      67                 :            : 
      68                 :          1 :   out = g_bookmark_file_get_mime_type (bookmark, "file:///tmp/schedule.ps", &error);
      69                 :          1 :   g_assert_no_error (error);
      70                 :          1 :   g_assert_cmpstr (out, ==, "application/postscript");
      71                 :          1 :   g_free (out);
      72                 :            : 
      73                 :          1 :   remove (tmp_filename);
      74                 :            : 
      75                 :          1 :   g_test_message ("Roundtrip from a valid bookmark file");
      76                 :          1 :   filename = g_test_get_filename (G_TEST_DIST, "bookmarks", "valid-01.xbel", NULL);
      77                 :          1 :   res = g_bookmark_file_load_from_file (bookmark, filename, &error);
      78                 :          1 :   g_assert_no_error (error);
      79                 :          1 :   g_assert_true (res);
      80                 :            : 
      81                 :          1 :   res = g_bookmark_file_to_file (bookmark, tmp_filename, &error);
      82                 :          1 :   g_assert_no_error (error);
      83                 :          1 :   g_assert_true (res);
      84                 :            : 
      85                 :          1 :   res = g_file_get_contents (filename, &in, NULL, &error);
      86                 :          1 :   g_assert_no_error (error);
      87                 :          1 :   g_assert_true (res);
      88                 :            : 
      89                 :          1 :   res = g_file_get_contents (tmp_filename, &out, NULL, &error);
      90                 :          1 :   g_assert_no_error (error);
      91                 :          1 :   g_assert_true (res);
      92                 :          1 :   remove (tmp_filename);
      93                 :            : 
      94                 :          1 :   g_assert_cmpstr (in, ==, out);
      95                 :          1 :   g_free (in);
      96                 :          1 :   g_free (out);
      97                 :            : 
      98                 :          1 :   g_bookmark_file_free (bookmark);
      99                 :          1 :   g_free (tmp_filename);
     100                 :          1 : }
     101                 :            : 
     102                 :            : static void
     103                 :          1 : test_move_item (void)
     104                 :            : {
     105                 :            :   GBookmarkFile *bookmark;
     106                 :            :   const gchar *filename;
     107                 :            :   gboolean res;
     108                 :          1 :   GError *error = NULL;
     109                 :            : 
     110                 :          1 :   bookmark = g_bookmark_file_new ();
     111                 :            : 
     112                 :          1 :   filename = g_test_get_filename (G_TEST_DIST, "bookmarks", "valid-01.xbel", NULL);
     113                 :          1 :   res = g_bookmark_file_load_from_file (bookmark, filename, &error);
     114                 :          1 :   g_assert_true (res);
     115                 :          1 :   g_assert_no_error (error);
     116                 :            : 
     117                 :          1 :   res = g_bookmark_file_move_item (bookmark,
     118                 :            :                                    "file:///home/zefram/Documents/milan-stuttgart.ps",
     119                 :            :                                    "file:///tmp/schedule.ps",
     120                 :            :                                    &error);
     121                 :          1 :   g_assert_true (res);
     122                 :          1 :   g_assert_no_error (error);
     123                 :            : 
     124                 :          1 :   res = g_bookmark_file_move_item (bookmark,
     125                 :            :                                    "file:///tmp/schedule.ps",
     126                 :            :                                    "file:///tmp/schedule.ps",
     127                 :            :                                    &error);
     128                 :          1 :   g_assert_true (res);
     129                 :          1 :   g_assert_no_error (error);
     130                 :            : 
     131                 :          1 :   res = g_bookmark_file_move_item (bookmark,
     132                 :            :                                    "file:///no-such-file.xbel",
     133                 :            :                                    "file:///tmp/schedule.ps",
     134                 :            :                                    &error);
     135                 :          1 :   g_assert_false (res);
     136                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     137                 :          1 :   g_clear_error (&error);
     138                 :            : 
     139                 :          1 :   res = g_bookmark_file_move_item (bookmark,
     140                 :            :                                    "file:///tmp/schedule.ps",
     141                 :            :                                    NULL,
     142                 :            :                                    &error);
     143                 :          1 :   g_assert_true (res);
     144                 :          1 :   g_assert_no_error (error);
     145                 :            : 
     146                 :          1 :   g_bookmark_file_free (bookmark);
     147                 :          1 : }
     148                 :            : 
     149                 :            : static void
     150                 :          1 : test_corner_cases (void)
     151                 :            : {
     152                 :            :   gsize size;
     153                 :            :   gchar *message, **messages;
     154                 :          1 :   GError *error = NULL;
     155                 :            :   GBookmarkFile *bookmark;
     156                 :            : 
     157                 :          1 :   bookmark = g_bookmark_file_new ();
     158                 :            : 
     159         [ +  - ]:          1 :   if (g_test_undefined ())
     160                 :            :     {
     161                 :            :       /* g_bookmark_file_load_from_data() */
     162                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     163                 :            :                              "*assertion*!= NULL*");
     164                 :          1 :       g_assert_false (g_bookmark_file_load_from_data (NULL, NULL, -1, NULL));
     165                 :          1 :       g_test_assert_expected_messages ();
     166                 :            : 
     167                 :            :       /* g_bookmark_file_load_from_file() */
     168                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     169                 :            :                              "*assertion*!= NULL*");
     170                 :          1 :       g_assert_false (g_bookmark_file_load_from_file (NULL, NULL, NULL));
     171                 :          1 :       g_test_assert_expected_messages ();
     172                 :            : 
     173                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     174                 :            :                              "*assertion*!= NULL*");
     175                 :          1 :       g_assert_false (g_bookmark_file_load_from_file (bookmark, NULL, NULL));
     176                 :          1 :       g_test_assert_expected_messages ();
     177                 :            : 
     178                 :            :       /* g_bookmark_file_load_from_data_dirs() */
     179                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     180                 :            :                              "*assertion*!= NULL*");
     181                 :          1 :       g_assert_false (g_bookmark_file_load_from_data_dirs (NULL, NULL, NULL, NULL));
     182                 :          1 :       g_test_assert_expected_messages ();
     183                 :            : 
     184                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     185                 :            :                              "*assertion*!= NULL*");
     186                 :          1 :       g_assert_false (g_bookmark_file_load_from_data_dirs (bookmark, NULL, NULL, NULL));
     187                 :          1 :       g_test_assert_expected_messages ();
     188                 :            : 
     189                 :            :       /* g_bookmark_file_to_data() */
     190                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     191                 :            :                              "*assertion*!= NULL*");
     192                 :          1 :       g_assert_null (g_bookmark_file_to_data (NULL, NULL, NULL));
     193                 :          1 :       g_test_assert_expected_messages ();
     194                 :            : 
     195                 :            :       /* g_bookmark_file_to_file() */
     196                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     197                 :            :                              "*assertion*!= NULL*");
     198                 :          1 :       g_assert_false (g_bookmark_file_to_file (NULL, NULL, NULL));
     199                 :          1 :       g_test_assert_expected_messages ();
     200                 :            : 
     201                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     202                 :            :                              "*assertion*!= NULL*");
     203                 :          1 :       g_assert_false (g_bookmark_file_to_file (bookmark, NULL, NULL));
     204                 :          1 :       g_test_assert_expected_messages ();
     205                 :            : 
     206                 :            :       /* g_bookmark_file_remove_item() */
     207                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     208                 :            :                              "*assertion*!= NULL*");
     209                 :          1 :       g_assert_false (g_bookmark_file_remove_item (NULL, NULL, NULL));
     210                 :          1 :       g_test_assert_expected_messages ();
     211                 :            : 
     212                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     213                 :            :                              "*assertion*!= NULL*");
     214                 :          1 :       g_assert_false (g_bookmark_file_remove_item (bookmark, NULL, NULL));
     215                 :          1 :       g_test_assert_expected_messages ();
     216                 :            : 
     217                 :            :       /* g_bookmark_file_has_item() */
     218                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     219                 :            :                              "*assertion*!= NULL*");
     220                 :          1 :       g_assert_false (g_bookmark_file_has_item (NULL, NULL));
     221                 :          1 :       g_test_assert_expected_messages ();
     222                 :            : 
     223                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     224                 :            :                              "*assertion*!= NULL*");
     225                 :          1 :       g_assert_false (g_bookmark_file_has_item (bookmark, NULL));
     226                 :          1 :       g_test_assert_expected_messages ();
     227                 :            : 
     228                 :            :       /* g_bookmark_file_get_uris() */
     229                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     230                 :            :                              "*assertion*!= NULL*");
     231                 :          1 :       g_assert_null (g_bookmark_file_get_uris (NULL, NULL));
     232                 :          1 :       g_test_assert_expected_messages ();
     233                 :            : 
     234                 :            :       /* g_bookmark_file_set_title() */
     235                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     236                 :            :                              "*assertion*!= NULL*");
     237                 :          1 :       g_bookmark_file_set_title (NULL, NULL, NULL);
     238                 :          1 :       g_test_assert_expected_messages ();
     239                 :            : 
     240                 :            :       /* g_bookmark_file_get_title() */
     241                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     242                 :            :                              "*assertion*!= NULL*");
     243                 :          1 :       g_assert_null (g_bookmark_file_get_title (NULL, NULL, NULL));
     244                 :          1 :       g_test_assert_expected_messages ();
     245                 :            : 
     246                 :            :       /* g_bookmark_file_set_description() */
     247                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     248                 :            :                              "*assertion*!= NULL*");
     249                 :          1 :       g_bookmark_file_set_description (NULL, NULL, NULL);
     250                 :          1 :       g_test_assert_expected_messages ();
     251                 :            : 
     252                 :            :       /* g_bookmark_file_get_description() */
     253                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     254                 :            :                              "*assertion*!= NULL*");
     255                 :          1 :       g_bookmark_file_get_description (NULL, NULL, NULL);
     256                 :          1 :       g_test_assert_expected_messages ();
     257                 :            : 
     258                 :            :       /* g_bookmark_file_set_mime_type() */
     259                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     260                 :            :                              "*assertion*!= NULL*");
     261                 :          1 :       g_bookmark_file_set_mime_type (NULL, NULL, NULL);
     262                 :          1 :       g_test_assert_expected_messages ();
     263                 :            : 
     264                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     265                 :            :                              "*assertion*!= NULL*");
     266                 :          1 :       g_bookmark_file_set_mime_type (bookmark, NULL, NULL);
     267                 :          1 :       g_test_assert_expected_messages ();
     268                 :            : 
     269                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     270                 :            :                              "*assertion*!= NULL*");
     271                 :          1 :       g_bookmark_file_set_mime_type (bookmark, "uri", NULL);
     272                 :          1 :       g_test_assert_expected_messages ();
     273                 :            : 
     274                 :            :       /* g_bookmark_file_get_mime_type() */
     275                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     276                 :            :                              "*assertion*!= NULL*");
     277                 :          1 :       g_assert_null (g_bookmark_file_get_mime_type (NULL, NULL, NULL));
     278                 :          1 :       g_test_assert_expected_messages ();
     279                 :            : 
     280                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     281                 :            :                              "*assertion*!= NULL*");
     282                 :          1 :       g_assert_null (g_bookmark_file_get_mime_type (bookmark, NULL, NULL));
     283                 :          1 :       g_test_assert_expected_messages ();
     284                 :            : 
     285                 :            :       /* g_bookmark_file_set_is_private() */
     286                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     287                 :            :                              "*assertion*!= NULL*");
     288                 :          1 :       g_bookmark_file_set_is_private (NULL, NULL, TRUE);
     289                 :          1 :       g_test_assert_expected_messages ();
     290                 :            : 
     291                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     292                 :            :                              "*assertion*!= NULL*");
     293                 :          1 :       g_bookmark_file_set_is_private (bookmark, NULL, TRUE);
     294                 :          1 :       g_test_assert_expected_messages ();
     295                 :            : 
     296                 :            :       /* g_bookmark_file_get_is_private() */
     297                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     298                 :            :                              "*assertion*!= NULL*");
     299                 :          1 :       g_assert_false (g_bookmark_file_get_is_private (NULL, NULL, NULL));
     300                 :          1 :       g_test_assert_expected_messages ();
     301                 :            : 
     302                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     303                 :            :                              "*assertion*!= NULL*");
     304                 :          1 :       g_assert_false (g_bookmark_file_get_is_private (bookmark, NULL, NULL));
     305                 :          1 :       g_test_assert_expected_messages ();
     306                 :            : 
     307                 :            :       /* g_bookmark_file_set_added_date_time() */
     308                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     309                 :            :                              "*assertion*!= NULL*");
     310                 :          1 :       g_bookmark_file_set_added_date_time (NULL, NULL, NULL);
     311                 :          1 :       g_test_assert_expected_messages ();
     312                 :            : 
     313                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     314                 :            :                              "*assertion*!= NULL*");
     315                 :          1 :       g_bookmark_file_set_added_date_time (bookmark, NULL, NULL);
     316                 :          1 :       g_test_assert_expected_messages ();
     317                 :            : 
     318                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     319                 :            :                              "*assertion*!= NULL*");
     320                 :          1 :       g_bookmark_file_set_added_date_time (bookmark, "a", NULL);
     321                 :          1 :       g_test_assert_expected_messages ();
     322                 :            : 
     323                 :            :       /* g_bookmark_file_get_added_date_time() */
     324                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     325                 :            :                              "*assertion*!= NULL*");
     326                 :          1 :       g_assert_null (g_bookmark_file_get_added_date_time (NULL, NULL, NULL));
     327                 :          1 :       g_test_assert_expected_messages ();
     328                 :            : 
     329                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     330                 :            :                              "*assertion*!= NULL*");
     331                 :          1 :       g_assert_null (g_bookmark_file_get_added_date_time (bookmark, NULL, NULL));
     332                 :          1 :       g_test_assert_expected_messages ();
     333                 :            : 
     334                 :            :       /* g_bookmark_file_set_modified_date_time() */
     335                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     336                 :            :                              "*assertion*!= NULL*");
     337                 :          1 :       g_bookmark_file_set_modified_date_time (NULL, NULL, NULL);
     338                 :          1 :       g_test_assert_expected_messages ();
     339                 :            : 
     340                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     341                 :            :                              "*assertion*!= NULL*");
     342                 :          1 :       g_bookmark_file_set_modified_date_time (bookmark, NULL, NULL);
     343                 :          1 :       g_test_assert_expected_messages ();
     344                 :            : 
     345                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     346                 :            :                              "*assertion*!= NULL*");
     347                 :          1 :       g_bookmark_file_set_modified_date_time (bookmark, "a", NULL);
     348                 :          1 :       g_test_assert_expected_messages ();
     349                 :            : 
     350                 :            :       /* g_bookmark_file_get_modified_date_time() */
     351                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     352                 :            :                              "*assertion*!= NULL*");
     353                 :          1 :       g_assert_null (g_bookmark_file_get_modified_date_time (NULL, NULL, NULL));
     354                 :          1 :       g_test_assert_expected_messages ();
     355                 :            : 
     356                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     357                 :            :                              "*assertion*!= NULL*");
     358                 :          1 :       g_assert_null (g_bookmark_file_get_modified_date_time (bookmark, NULL, NULL));
     359                 :          1 :       g_test_assert_expected_messages ();
     360                 :            : 
     361                 :            :       /* g_bookmark_file_set_visited_date_time() */
     362                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     363                 :            :                              "*assertion*!= NULL*");
     364                 :          1 :       g_bookmark_file_set_visited_date_time (NULL, NULL, NULL);
     365                 :          1 :       g_test_assert_expected_messages ();
     366                 :            : 
     367                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     368                 :            :                              "*assertion*!= NULL*");
     369                 :          1 :       g_bookmark_file_set_visited_date_time (bookmark, NULL, NULL);
     370                 :          1 :       g_test_assert_expected_messages ();
     371                 :            : 
     372                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     373                 :            :                              "*assertion*!= NULL*");
     374                 :          1 :       g_bookmark_file_set_visited_date_time (bookmark, "a", NULL);
     375                 :          1 :       g_test_assert_expected_messages ();
     376                 :            : 
     377                 :            :       /* g_bookmark_file_get_visited_date_time() */
     378                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     379                 :            :                              "*assertion*!= NULL*");
     380                 :          1 :       g_assert_null (g_bookmark_file_get_visited_date_time (NULL, NULL, NULL));
     381                 :          1 :       g_test_assert_expected_messages ();
     382                 :            : 
     383                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     384                 :            :                              "*assertion*!= NULL*");
     385                 :          1 :       g_assert_null (g_bookmark_file_get_visited_date_time (bookmark, NULL, NULL));
     386                 :          1 :       g_test_assert_expected_messages ();
     387                 :            : 
     388                 :            :       /* g_bookmark_file_load_from_data_dirs() */
     389                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     390                 :            :                              "*assertion*!= NULL*");
     391                 :          1 :       g_assert_false (g_bookmark_file_load_from_data_dirs (NULL, NULL, NULL, NULL));
     392                 :          1 :       g_test_assert_expected_messages ();
     393                 :            : 
     394                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     395                 :            :                              "*assertion*!= NULL*");
     396                 :          1 :       g_assert_false (g_bookmark_file_load_from_data_dirs (bookmark, NULL, NULL, NULL));
     397                 :          1 :       g_test_assert_expected_messages ();
     398                 :            : 
     399                 :            :       /* g_bookmark_file_has_group() */
     400                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     401                 :            :                              "*assertion*!= NULL*");
     402                 :          1 :       g_assert_false (g_bookmark_file_has_group (NULL, NULL, NULL, NULL));
     403                 :          1 :       g_test_assert_expected_messages ();
     404                 :            : 
     405                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     406                 :            :                              "*assertion*!= NULL*");
     407                 :          1 :       g_assert_false (g_bookmark_file_has_group (bookmark, NULL, NULL, NULL));
     408                 :          1 :       g_test_assert_expected_messages ();
     409                 :            : 
     410                 :            :       /* g_bookmark_file_add_group() */
     411                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     412                 :            :                              "*assertion*!= NULL*");
     413                 :          1 :       g_bookmark_file_add_group (NULL, NULL, NULL);
     414                 :          1 :       g_test_assert_expected_messages ();
     415                 :            : 
     416                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     417                 :            :                              "*assertion*!= NULL*");
     418                 :          1 :       g_bookmark_file_add_group (bookmark, NULL, NULL);
     419                 :          1 :       g_test_assert_expected_messages ();
     420                 :            : 
     421                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     422                 :            :                              "*assertion*!= NULL*");
     423                 :          1 :       g_bookmark_file_add_group (bookmark, "a", NULL);
     424                 :          1 :       g_test_assert_expected_messages ();
     425                 :            : 
     426                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     427                 :            :                              "*assertion*!= NULL*");
     428                 :          1 :       g_bookmark_file_add_group (bookmark, "a", "");
     429                 :          1 :       g_test_assert_expected_messages ();
     430                 :            : 
     431                 :            :       /* g_bookmark_file_remove_group() */
     432                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     433                 :            :                              "*assertion*!= NULL*");
     434                 :          1 :       g_assert_false (g_bookmark_file_remove_group (NULL, NULL, NULL, NULL));
     435                 :          1 :       g_test_assert_expected_messages ();
     436                 :            : 
     437                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     438                 :            :                              "*assertion*!= NULL*");
     439                 :          1 :       g_assert_false (g_bookmark_file_remove_group (bookmark, NULL, NULL, NULL));
     440                 :          1 :       g_test_assert_expected_messages ();
     441                 :            : 
     442                 :            :       /* g_bookmark_file_set_group() */
     443                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     444                 :            :                              "*assertion*!= NULL*");
     445                 :          1 :       g_bookmark_file_set_groups (NULL, NULL, NULL, 0);
     446                 :          1 :       g_test_assert_expected_messages ();
     447                 :            : 
     448                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     449                 :            :                              "*assertion*!= NULL*");
     450                 :          1 :       g_bookmark_file_set_groups (bookmark, NULL, NULL, 0);
     451                 :          1 :       g_test_assert_expected_messages ();
     452                 :            : 
     453                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     454                 :            :                              "*assertion*!= NULL*");
     455                 :          1 :       g_bookmark_file_set_groups (bookmark, "a", NULL, 0);
     456                 :          1 :       g_test_assert_expected_messages ();
     457                 :            : 
     458                 :            :       /* g_bookmark_file_get_group() */
     459                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     460                 :            :                              "*assertion*!= NULL*");
     461                 :          1 :       g_assert_null (g_bookmark_file_get_groups (NULL, NULL, NULL, NULL));
     462                 :          1 :       g_test_assert_expected_messages ();
     463                 :            : 
     464                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     465                 :            :                              "*assertion*!= NULL*");
     466                 :          1 :       g_assert_null (g_bookmark_file_get_groups (bookmark, NULL, NULL, NULL));
     467                 :          1 :       g_test_assert_expected_messages ();
     468                 :            : 
     469                 :            :       /* g_bookmark_file_to_file() */
     470                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     471                 :            :                              "*assertion*!= NULL*");
     472                 :          1 :       g_assert_false (g_bookmark_file_to_file (NULL, NULL, NULL));
     473                 :          1 :       g_test_assert_expected_messages ();
     474                 :            : 
     475                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     476                 :            :                              "*assertion*!= NULL*");
     477                 :          1 :       g_assert_false (g_bookmark_file_to_file (bookmark, NULL, NULL));
     478                 :          1 :       g_test_assert_expected_messages ();
     479                 :            : 
     480                 :            :       /* g_bookmark_file_add_application() */
     481                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     482                 :            :                              "*assertion*!= NULL*");
     483                 :          1 :       g_bookmark_file_add_application (NULL, NULL, NULL, NULL);
     484                 :          1 :       g_test_assert_expected_messages ();
     485                 :            : 
     486                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     487                 :            :                              "*assertion*!= NULL*");
     488                 :          1 :       g_bookmark_file_add_application (bookmark, NULL, NULL, NULL);
     489                 :          1 :       g_test_assert_expected_messages ();
     490                 :            : 
     491                 :            :       /* g_bookmark_file_remove_application() */
     492                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     493                 :            :                              "*assertion*!= NULL*");
     494                 :          1 :       g_assert_false (g_bookmark_file_remove_application (NULL, NULL, NULL, NULL));
     495                 :          1 :       g_test_assert_expected_messages ();
     496                 :            : 
     497                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     498                 :            :                              "*assertion*!= NULL*");
     499                 :          1 :       g_assert_false (g_bookmark_file_remove_application (bookmark, NULL, NULL, NULL));
     500                 :          1 :       g_test_assert_expected_messages ();
     501                 :            : 
     502                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     503                 :            :                              "*assertion*!= NULL*");
     504                 :          1 :       g_assert_false (g_bookmark_file_remove_application (bookmark, "a", NULL, NULL));
     505                 :          1 :       g_test_assert_expected_messages ();
     506                 :            : 
     507                 :            :       /* g_bookmark_file_has_application() */
     508                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     509                 :            :                              "*assertion*!= NULL*");
     510                 :          1 :       g_assert_false (g_bookmark_file_has_application (NULL, NULL, NULL, NULL));
     511                 :          1 :       g_test_assert_expected_messages ();
     512                 :            : 
     513                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     514                 :            :                              "*assertion*!= NULL*");
     515                 :          1 :       g_assert_false (g_bookmark_file_has_application (bookmark, NULL, NULL, NULL));
     516                 :          1 :       g_test_assert_expected_messages ();
     517                 :            : 
     518                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     519                 :            :                              "*assertion*!= NULL*");
     520                 :          1 :       g_assert_false (g_bookmark_file_has_application (bookmark, "a", NULL, NULL));
     521                 :          1 :       g_test_assert_expected_messages ();
     522                 :            : 
     523                 :            :       /* g_bookmark_file_set_application_info() */
     524                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     525                 :            :                              "*assertion*!= NULL*");
     526                 :          1 :       g_assert_false (g_bookmark_file_set_application_info (NULL, NULL, NULL, NULL, 0, NULL, NULL));
     527                 :          1 :       g_test_assert_expected_messages ();
     528                 :            : 
     529                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     530                 :            :                              "*assertion*!= NULL*");
     531                 :          1 :       g_assert_false (g_bookmark_file_set_application_info (bookmark, NULL, NULL, NULL, 0, NULL, NULL));
     532                 :          1 :       g_test_assert_expected_messages ();
     533                 :            : 
     534                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     535                 :            :                              "*assertion*!= NULL*");
     536                 :          1 :       g_assert_false (g_bookmark_file_set_application_info (bookmark, "a", NULL, NULL, 0, NULL, NULL));
     537                 :          1 :       g_test_assert_expected_messages ();
     538                 :            : 
     539                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     540                 :            :                              "*assertion*!= NULL*");
     541                 :          1 :       g_assert_false (g_bookmark_file_set_application_info (bookmark, "a", "b", NULL, 0, NULL, NULL));
     542                 :          1 :       g_test_assert_expected_messages ();
     543                 :            : 
     544                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     545                 :            :                              "*assertion*!= NULL*");
     546                 :          1 :       g_assert_false (g_bookmark_file_set_application_info (bookmark, "a", "b", "c", 5, NULL, NULL));
     547                 :          1 :       g_test_assert_expected_messages ();
     548                 :            : 
     549                 :            :       /* g_bookmark_file_get_application_info() */
     550                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     551                 :            :                              "*assertion*!= NULL*");
     552                 :          1 :       g_assert_false (g_bookmark_file_get_application_info (NULL, NULL, NULL, NULL, NULL, NULL, NULL));
     553                 :          1 :       g_test_assert_expected_messages ();
     554                 :            : 
     555                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     556                 :            :                              "*assertion*!= NULL*");
     557                 :          1 :       g_assert_false (g_bookmark_file_get_application_info (bookmark, NULL, NULL, NULL, NULL, NULL, NULL));
     558                 :          1 :       g_test_assert_expected_messages ();
     559                 :            : 
     560                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     561                 :            :                              "*assertion*!= NULL*");
     562                 :          1 :       g_assert_false (g_bookmark_file_get_application_info (bookmark, "a", NULL, NULL, NULL, NULL, NULL));
     563                 :          1 :       g_test_assert_expected_messages ();
     564                 :            : 
     565                 :            :       /* g_bookmark_file_get_applications() */
     566                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     567                 :            :                              "*assertion*!= NULL*");
     568                 :          1 :       g_assert_null (g_bookmark_file_get_applications (NULL, NULL, NULL, NULL));
     569                 :          1 :       g_test_assert_expected_messages ();
     570                 :            : 
     571                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     572                 :            :                              "*assertion*!= NULL*");
     573                 :          1 :       g_assert_null (g_bookmark_file_get_applications (bookmark, NULL, NULL, NULL));
     574                 :          1 :       g_test_assert_expected_messages ();
     575                 :            : 
     576                 :            :       /* g_bookmark_file_get_size() */
     577                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     578                 :            :                              "*assertion*!= NULL*");
     579                 :          1 :       g_assert_cmpint (g_bookmark_file_get_size (NULL), ==, 0);
     580                 :          1 :       g_test_assert_expected_messages ();
     581                 :            : 
     582                 :            :       /* g_bookmark_file_move_item() */
     583                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     584                 :            :                              "*assertion*!= NULL*");
     585                 :          1 :       g_assert_false (g_bookmark_file_move_item (NULL, NULL, NULL, NULL));
     586                 :          1 :       g_test_assert_expected_messages ();
     587                 :            : 
     588                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     589                 :            :                              "*assertion*!= NULL*");
     590                 :          1 :       g_assert_false (g_bookmark_file_move_item (bookmark, NULL, NULL, NULL));
     591                 :          1 :       g_test_assert_expected_messages ();
     592                 :            : 
     593                 :            :       /* g_bookmark_file_set_icon() */
     594                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     595                 :            :                              "*assertion*!= NULL*");
     596                 :          1 :       g_bookmark_file_set_icon (NULL, NULL, NULL, NULL);
     597                 :          1 :       g_test_assert_expected_messages ();
     598                 :            : 
     599                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     600                 :            :                              "*assertion*!= NULL*");
     601                 :          1 :       g_bookmark_file_set_icon (bookmark, NULL, NULL, NULL);
     602                 :          1 :       g_test_assert_expected_messages ();
     603                 :            : 
     604                 :            :       /* g_bookmark_file_get_icon() */
     605                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     606                 :            :                              "*assertion*!= NULL*");
     607                 :          1 :       g_assert_false (g_bookmark_file_get_icon (NULL, NULL, NULL, NULL, NULL));
     608                 :          1 :       g_test_assert_expected_messages ();
     609                 :            : 
     610                 :          1 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
     611                 :            :                              "*assertion*!= NULL*");
     612                 :          1 :       g_assert_false (g_bookmark_file_get_icon (bookmark, NULL, NULL, NULL, NULL));
     613                 :          1 :       g_test_assert_expected_messages ();
     614                 :            :     }
     615                 :            : 
     616                 :            :   /* g_file_bookmark_free() */
     617                 :          1 :   g_bookmark_file_free (NULL);
     618                 :            : 
     619                 :            :   /* g_bookmark_file_load_from_data() */
     620                 :          1 :   g_assert_false (g_bookmark_file_load_from_data (bookmark, "data", -1, &error));
     621                 :          1 :   g_assert_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE);
     622                 :          1 :   g_clear_error (&error);
     623                 :            : 
     624                 :            :   /* g_bookmark_file_load_from_data_dirs() */
     625                 :          1 :   g_assert_false (g_bookmark_file_load_from_data_dirs (bookmark, "a", NULL, NULL));
     626                 :          1 :   g_assert_false (g_bookmark_file_load_from_data_dirs (bookmark, "a", NULL, &error));
     627                 :          1 :   g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
     628                 :          1 :   g_clear_error (&error);
     629                 :            : 
     630                 :            :   /* g_bookmark_file_to_data() */
     631                 :          1 :   message = g_bookmark_file_to_data (bookmark, &size, &error);
     632                 :          1 :   g_assert_nonnull (message);
     633                 :          1 :   g_assert_cmpstr (message, ==,
     634                 :            :                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
     635                 :            :                    "<xbel version=\"1.0\"\n"
     636                 :            :                    "      xmlns:bookmark=\"http://www.freedesktop.org/standards/desktop-bookmarks\"\n"
     637                 :            :                    "      xmlns:mime=\"http://www.freedesktop.org/standards/shared-mime-info\"\n"
     638                 :            :                    "></xbel>");
     639                 :          1 :   g_free (message);
     640                 :            : 
     641                 :            :   /* g_bookmark_file_get_uris() */
     642                 :          1 :   size = 10;
     643                 :          1 :   messages = g_bookmark_file_get_uris (bookmark, &size);
     644                 :          1 :   g_assert_nonnull (messages);
     645                 :          1 :   g_assert_null (messages[0]);
     646                 :          1 :   g_free (messages);
     647                 :            : 
     648                 :            :   /* g_bookmark_file_get_added_date_time() */
     649                 :          1 :   g_assert_null (g_bookmark_file_get_added_date_time (bookmark, "a", NULL));
     650                 :          1 :   g_assert_null (g_bookmark_file_get_added_date_time (bookmark, "a", &error));
     651                 :          1 :   g_clear_error (&error);
     652                 :            : 
     653                 :            :   /* g_bookmark_file_get_modified_date_time() */
     654                 :          1 :   g_assert_null (g_bookmark_file_get_modified_date_time (bookmark, "a", NULL));
     655                 :          1 :   g_assert_null (g_bookmark_file_get_modified_date_time (bookmark, "a", &error));
     656                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     657                 :          1 :   g_clear_error (&error);
     658                 :            : 
     659                 :            :   /* g_bookmark_file_get_visited_date_time() */
     660                 :          1 :   g_assert_null (g_bookmark_file_get_visited_date_time (bookmark, "a", NULL));
     661                 :          1 :   g_assert_null (g_bookmark_file_get_visited_date_time (bookmark, "a", &error));
     662                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     663                 :          1 :   g_clear_error (&error);
     664                 :            : 
     665                 :            :   /* g_bookmark_file_get_groups() */
     666                 :          1 :   g_assert_null (g_bookmark_file_get_groups (bookmark, "a", &size, NULL));
     667                 :          1 :   g_assert_null (g_bookmark_file_get_groups (bookmark, "a", &size, &error));
     668                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     669                 :          1 :   g_clear_error (&error);
     670                 :            : 
     671                 :            :   /* g_bookmark_file_to_file() */
     672                 :          1 :   g_assert_true (g_bookmark_file_to_file (bookmark, "a", &error));
     673                 :          1 :   g_assert_no_error (error);
     674                 :            : 
     675                 :            :   /* g_bookmark_file_remove_group() */
     676                 :          1 :   g_assert_false (g_bookmark_file_remove_group (bookmark, "a", NULL, NULL));
     677                 :          1 :   g_assert_false (g_bookmark_file_remove_group (bookmark, "a", NULL, &error));
     678                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     679                 :          1 :   g_clear_error (&error);
     680                 :            : 
     681                 :            :   /* g_bookmark_file_get_title() */
     682                 :          1 :   g_assert_null (g_bookmark_file_get_title (bookmark, "a", &error));
     683                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     684                 :          1 :   g_clear_error (&error);
     685                 :            : 
     686                 :            :   /* g_bookmark_file_add_application() */
     687                 :          1 :   g_bookmark_file_add_application (bookmark, "a", NULL, NULL);
     688                 :          1 :   g_bookmark_file_add_application (bookmark, "a", "b", NULL);
     689                 :          1 :   g_bookmark_file_add_application (bookmark, "a", "b", "c");
     690                 :            : 
     691                 :            :   /* g_bookmark_file_remove_application() */
     692                 :          1 :   g_assert_true (g_bookmark_file_remove_application (bookmark, "a", "b", NULL));
     693                 :          1 :   g_assert_false (g_bookmark_file_remove_application (bookmark, "a", "b", &error));
     694                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED);
     695                 :          1 :   g_clear_error (&error);
     696                 :            : 
     697                 :            :   /* g_bookmark_file_get_application_info() */
     698                 :          1 :   g_assert_false (g_bookmark_file_get_application_info (bookmark, "a", "b", NULL, NULL, NULL, NULL));
     699                 :          1 :   g_assert_false (g_bookmark_file_get_application_info (bookmark, "a", "b", NULL, NULL, NULL, &error));
     700                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED);
     701                 :          1 :   g_clear_error (&error);
     702                 :            : 
     703                 :            :   /* g_bookmark_file_move_item() */
     704                 :          1 :   g_assert_true (g_bookmark_file_move_item (bookmark, "a", NULL, NULL));
     705                 :          1 :   g_assert_false (g_bookmark_file_move_item (bookmark, "a", NULL, &error));
     706                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     707                 :          1 :   g_clear_error (&error);
     708                 :          1 :   g_assert_false (g_bookmark_file_move_item (bookmark, "a", "b", &error));
     709                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     710                 :          1 :   g_clear_error (&error);
     711                 :            : 
     712                 :          1 :   g_bookmark_file_free (bookmark);
     713                 :          1 :   g_unlink ("a");
     714                 :          1 : }
     715                 :            : 
     716                 :            : static void
     717                 :          1 : test_misc (void)
     718                 :            : {
     719                 :            :   GBookmarkFile *bookmark;
     720                 :            :   const gchar *filename;
     721                 :            :   gboolean res;
     722                 :          1 :   GError *error = NULL;
     723                 :            :   gchar *s;
     724                 :            :   GDateTime *before, *after, *t;
     725                 :            :   gchar *cmd, *exec;
     726                 :            :   guint count;
     727                 :            : 
     728                 :          1 :   bookmark = g_bookmark_file_new ();
     729                 :            : 
     730                 :          1 :   filename = g_test_get_filename (G_TEST_DIST, "bookmarks", "valid-01.xbel", NULL);
     731                 :          1 :   res = g_bookmark_file_load_from_file (bookmark, filename, &error);
     732                 :          1 :   g_assert_true (res);
     733                 :          1 :   g_assert_no_error (error);
     734                 :            : 
     735                 :          1 :   res = g_bookmark_file_get_icon (bookmark,
     736                 :            :                                    "file:///home/zefram/Documents/milan-stuttgart.ps",
     737                 :            :                                   NULL,
     738                 :            :                                   NULL,
     739                 :            :                                   &error);
     740                 :          1 :   g_assert_false (res);
     741                 :          1 :   g_assert_no_error (error);
     742                 :            : 
     743                 :          1 :   res = g_bookmark_file_get_icon (bookmark,
     744                 :            :                                   "file:///tmp/schedule.ps",
     745                 :            :                                   NULL,
     746                 :            :                                   NULL,
     747                 :            :                                   &error);
     748                 :          1 :   g_assert_false (res);
     749                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     750                 :          1 :   g_clear_error (&error);
     751                 :            : 
     752                 :          1 :   g_bookmark_file_set_description (bookmark,
     753                 :            :                                    "file:///tmp/schedule0.ps",
     754                 :            :                                    "imaginary schedule");
     755                 :          1 :   s = g_bookmark_file_get_description (bookmark,
     756                 :            :                                        "file:///tmp/schedule0.ps",
     757                 :            :                                        &error);
     758                 :          1 :   g_assert_no_error (error);
     759                 :          1 :   g_assert_cmpstr (s, ==, "imaginary schedule");
     760                 :          1 :   g_free (s);
     761                 :          1 :   s = g_bookmark_file_get_mime_type (bookmark,
     762                 :            :                                      "file:///tmp/schedule0.ps",
     763                 :            :                                      &error);
     764                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_INVALID_VALUE);
     765                 :          1 :   g_assert_null (s);
     766                 :          1 :   g_clear_error (&error);
     767                 :          1 :   res = g_bookmark_file_get_is_private (bookmark,
     768                 :            :                                         "file:///tmp/schedule0.ps",
     769                 :            :                                         &error);
     770                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_INVALID_VALUE);
     771                 :          1 :   g_clear_error (&error);
     772                 :          1 :   g_assert_false (res);
     773                 :            : 
     774                 :          1 :   g_bookmark_file_set_mime_type (bookmark, 
     775                 :            :                                  "file:///tmp/schedule1.ps",
     776                 :            :                                  "image/png");
     777                 :          1 :   s = g_bookmark_file_get_mime_type (bookmark,
     778                 :            :                                      "file:///tmp/schedule1.ps",
     779                 :            :                                      &error);
     780                 :          1 :   g_assert_no_error (error);
     781                 :          1 :   g_assert_cmpstr (s, ==, "image/png");
     782                 :          1 :   g_free (s);
     783                 :            :   
     784                 :          1 :   g_bookmark_file_set_is_private (bookmark,
     785                 :            :                                   "file:///tmp/schedule2.ps",
     786                 :            :                                   TRUE);
     787                 :          1 :   res = g_bookmark_file_get_is_private (bookmark,
     788                 :            :                                         "file:///tmp/schedule2.ps",
     789                 :            :                                         &error);
     790                 :          1 :   g_assert_no_error (error);
     791                 :          1 :   g_assert_true (res);
     792                 :            : 
     793                 :          1 :   before = g_date_time_new_now_utc ();
     794                 :            : 
     795                 :          1 :   g_bookmark_file_set_added_date_time (bookmark,
     796                 :            :                                        "file:///tmp/schedule3.ps",
     797                 :            :                                        before);
     798                 :          1 :   t = g_bookmark_file_get_added_date_time (bookmark,
     799                 :            :                                            "file:///tmp/schedule3.ps",
     800                 :            :                                            &error);
     801                 :          1 :   g_assert_no_error (error);
     802                 :            : 
     803                 :          1 :   after = g_date_time_new_now_utc ();
     804                 :          1 :   g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
     805                 :          1 :   g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
     806                 :            : 
     807                 :          1 :   g_date_time_unref (after);
     808                 :          1 :   g_date_time_unref (before);
     809                 :            : 
     810                 :          1 :   before = g_date_time_new_now_utc ();
     811                 :            : 
     812                 :          1 :   g_bookmark_file_set_modified_date_time (bookmark,
     813                 :            :                                           "file:///tmp/schedule4.ps",
     814                 :            :                                           before);
     815                 :          1 :   t = g_bookmark_file_get_modified_date_time (bookmark,
     816                 :            :                                               "file:///tmp/schedule4.ps",
     817                 :            :                                               &error);
     818                 :          1 :   g_assert_no_error (error);
     819                 :            : 
     820                 :          1 :   after = g_date_time_new_now_utc ();
     821                 :          1 :   g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
     822                 :          1 :   g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
     823                 :            : 
     824                 :          1 :   g_date_time_unref (after);
     825                 :          1 :   g_date_time_unref (before);
     826                 :            : 
     827                 :          1 :   before = g_date_time_new_now_utc ();
     828                 :            : 
     829                 :          1 :   g_bookmark_file_set_visited_date_time (bookmark,
     830                 :            :                                          "file:///tmp/schedule5.ps",
     831                 :            :                                          before);
     832                 :          1 :   t = g_bookmark_file_get_visited_date_time (bookmark,
     833                 :            :                                              "file:///tmp/schedule5.ps",
     834                 :            :                                              &error);
     835                 :          1 :   g_assert_no_error (error);
     836                 :            : 
     837                 :          1 :   after = g_date_time_new_now_utc ();
     838                 :          1 :   g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
     839                 :          1 :   g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
     840                 :          1 :   g_date_time_unref (after);
     841                 :          1 :   g_date_time_unref (before);
     842                 :            : 
     843                 :          1 :   g_bookmark_file_set_icon (bookmark,
     844                 :            :                             "file:///tmp/schedule6.ps",
     845                 :            :                             "application-x-postscript",
     846                 :            :                             "image/png");
     847                 :          1 :   res = g_bookmark_file_get_icon (bookmark,
     848                 :            :                                   "file:///tmp/schedule6.ps",
     849                 :            :                                   &s,
     850                 :            :                                   NULL, 
     851                 :            :                                   &error);
     852                 :          1 :   g_assert_no_error (error);
     853                 :          1 :   g_assert_true (res);
     854                 :          1 :   g_assert_cmpstr (s, ==, "application-x-postscript");
     855                 :          1 :   g_free (s);
     856                 :            : 
     857                 :          1 :   g_bookmark_file_set_icon (bookmark,
     858                 :            :                             "file:///tmp/schedule6.ps",
     859                 :            :                             NULL, NULL);
     860                 :          1 :   res = g_bookmark_file_get_icon (bookmark,
     861                 :            :                                   "file:///tmp/schedule6.ps",
     862                 :            :                                   &s,
     863                 :            :                                   NULL, 
     864                 :            :                                   &error);
     865                 :          1 :   g_assert_no_error (error);
     866                 :          1 :   g_assert_false (res);
     867                 :            : 
     868                 :          1 :   res = g_bookmark_file_has_application (bookmark,
     869                 :            :                                          "file:///tmp/schedule7.ps",
     870                 :            :                                          "foo",
     871                 :            :                                          &error);
     872                 :          1 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     873                 :          1 :   g_assert_false (res);
     874                 :          1 :   g_clear_error (&error);
     875                 :            : 
     876                 :          1 :   before = g_date_time_new_now_utc ();
     877                 :            : 
     878                 :          1 :   g_bookmark_file_add_application (bookmark,
     879                 :            :                                    "file:///tmp/schedule7.ps",
     880                 :            :                                    NULL, NULL);
     881                 :          1 :   res = g_bookmark_file_get_application_info (bookmark,
     882                 :            :                                               "file:///tmp/schedule7.ps",
     883                 :          1 :                                               g_get_application_name (),
     884                 :            :                                               &exec, &count, &t,
     885                 :            :                                               &error);
     886                 :          1 :   g_assert_no_error (error);
     887                 :          1 :   g_assert_true (res);
     888                 :          1 :   cmd = g_strconcat (g_get_prgname (), " file:///tmp/schedule7.ps", NULL);
     889                 :          1 :   g_assert_cmpstr (exec, ==, cmd);
     890                 :          1 :   g_free (cmd);
     891                 :          1 :   g_free (exec);
     892                 :          1 :   g_assert_cmpuint (count, ==, 1);
     893                 :            : 
     894                 :          1 :   after = g_date_time_new_now_utc ();
     895                 :          1 :   g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
     896                 :          1 :   g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
     897                 :            : 
     898                 :          1 :   g_date_time_unref (after);
     899                 :          1 :   g_date_time_unref (before);
     900                 :            : 
     901                 :          1 :   g_bookmark_file_free (bookmark);
     902                 :          1 : }
     903                 :            : 
     904                 :            : static void
     905                 :          1 : test_deprecated (void)
     906                 :            : {
     907                 :          1 :   GBookmarkFile *file = NULL;
     908                 :          1 :   GError *local_error = NULL;
     909                 :            :   time_t t, now;
     910                 :            :   gboolean retval;
     911                 :            : 
     912                 :            : G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     913                 :            : 
     914                 :          1 :   now = g_get_real_time () / G_USEC_PER_SEC;
     915                 :          1 :   file = g_bookmark_file_new ();
     916                 :            : 
     917                 :            :   /* added */
     918                 :          1 :   g_bookmark_file_set_added (file, "file://test", -1);
     919                 :          1 :   t = g_bookmark_file_get_added (file, "file://test", &local_error);
     920                 :          1 :   g_assert_no_error (local_error);
     921                 :          1 :   g_assert_cmpint (t, >=, now);
     922                 :            : 
     923                 :          1 :   g_bookmark_file_set_added (file, "file://test", 1234);
     924                 :          1 :   t = g_bookmark_file_get_added (file, "file://test", &local_error);
     925                 :          1 :   g_assert_no_error (local_error);
     926                 :          1 :   g_assert_cmpint (t, ==, 1234);
     927                 :            : 
     928                 :          1 :   t = g_bookmark_file_get_added (file, "file://not-exist", &local_error);
     929                 :          1 :   g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     930                 :          1 :   g_assert_cmpint (t, ==, (time_t) -1);
     931                 :          1 :   g_clear_error (&local_error);
     932                 :            : 
     933                 :            :   /* modified */
     934                 :          1 :   g_bookmark_file_set_modified (file, "file://test", -1);
     935                 :          1 :   t = g_bookmark_file_get_modified (file, "file://test", &local_error);
     936                 :          1 :   g_assert_no_error (local_error);
     937                 :          1 :   g_assert_cmpint (t, >=, now);
     938                 :            : 
     939                 :          1 :   g_bookmark_file_set_modified (file, "file://test", 1234);
     940                 :          1 :   t = g_bookmark_file_get_modified (file, "file://test", &local_error);
     941                 :          1 :   g_assert_no_error (local_error);
     942                 :          1 :   g_assert_cmpint (t, ==, 1234);
     943                 :            : 
     944                 :          1 :   t = g_bookmark_file_get_modified (file, "file://not-exist", &local_error);
     945                 :          1 :   g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     946                 :          1 :   g_assert_cmpint (t, ==, (time_t) -1);
     947                 :          1 :   g_clear_error (&local_error);
     948                 :            : 
     949                 :            :   /* visited */
     950                 :          1 :   g_bookmark_file_set_visited (file, "file://test", -1);
     951                 :          1 :   t = g_bookmark_file_get_visited (file, "file://test", &local_error);
     952                 :          1 :   g_assert_no_error (local_error);
     953                 :          1 :   g_assert_cmpint (t, >=, now);
     954                 :            : 
     955                 :          1 :   g_bookmark_file_set_visited (file, "file://test", 1234);
     956                 :          1 :   t = g_bookmark_file_get_visited (file, "file://test", &local_error);
     957                 :          1 :   g_assert_no_error (local_error);
     958                 :          1 :   g_assert_cmpint (t, ==, 1234);
     959                 :            : 
     960                 :          1 :   t = g_bookmark_file_get_visited (file, "file://not-exist", &local_error);
     961                 :          1 :   g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     962                 :          1 :   g_assert_cmpint (t, ==, (time_t) -1);
     963                 :          1 :   g_clear_error (&local_error);
     964                 :            : 
     965                 :            :   /* set app info */
     966                 :          1 :   retval = g_bookmark_file_set_app_info (file, "file://test", "app", "/path/to/app", 1, -1, &local_error);
     967                 :          1 :   g_assert_no_error (local_error);
     968                 :          1 :   g_assert_true (retval);
     969                 :            : 
     970                 :          1 :   retval = g_bookmark_file_get_app_info (file, "file://test", "app", NULL, NULL, &t, &local_error);
     971                 :          1 :   g_assert_no_error (local_error);
     972                 :          1 :   g_assert_true (retval);
     973                 :          1 :   g_assert_cmpint (t, >=, now);
     974                 :            : 
     975                 :          1 :   retval = g_bookmark_file_set_app_info (file, "file://test", "app", "/path/to/app", 1, 1234, &local_error);
     976                 :          1 :   g_assert_no_error (local_error);
     977                 :          1 :   g_assert_true (retval);
     978                 :            : 
     979                 :          1 :   retval = g_bookmark_file_get_app_info (file, "file://test", "app", NULL, NULL, &t, &local_error);
     980                 :          1 :   g_assert_no_error (local_error);
     981                 :          1 :   g_assert_true (retval);
     982                 :          1 :   g_assert_cmpint (t, ==, 1234);
     983                 :            : 
     984                 :          1 :   retval = g_bookmark_file_get_app_info (file, "file://test", "app", NULL, NULL, NULL, &local_error);
     985                 :          1 :   g_assert_no_error (local_error);
     986                 :          1 :   g_assert_true (retval);
     987                 :            : 
     988                 :          1 :   retval = g_bookmark_file_get_app_info (file, "file://not-exist", "app", NULL, NULL, &t, &local_error);
     989                 :          1 :   g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
     990                 :          1 :   g_assert_false (retval);
     991                 :          1 :   g_clear_error (&local_error);
     992                 :            : 
     993                 :          1 :   g_bookmark_file_free (file);
     994                 :            : 
     995                 :            : G_GNUC_END_IGNORE_DEPRECATIONS
     996                 :          1 : }
     997                 :            : 
     998                 :            : static gboolean
     999                 :         90 : test_load (GBookmarkFile *bookmark,
    1000                 :            :            const gchar   *filename)
    1001                 :            : {
    1002                 :         90 :   GError *error = NULL;
    1003                 :            :   gboolean res;
    1004                 :            :   
    1005                 :         90 :   res = g_bookmark_file_load_from_file (bookmark, filename, &error);
    1006   [ +  +  -  + ]:         90 :   if (error && g_test_verbose ())
    1007                 :          0 :     g_printerr ("Load error: %s\n", error->message);
    1008                 :            : 
    1009                 :         90 :   g_clear_error (&error);
    1010                 :         90 :   return res;
    1011                 :            : }
    1012                 :            : 
    1013                 :            : static void
    1014                 :          3 : test_query (GBookmarkFile *bookmark)
    1015                 :            : {
    1016                 :            :   gint size;
    1017                 :            :   gchar **uris;
    1018                 :            :   gsize uris_len, i;
    1019                 :            :   gchar *mime;
    1020                 :            :   GError *error;
    1021                 :            : 
    1022                 :          3 :   size = g_bookmark_file_get_size (bookmark);
    1023                 :          3 :   uris = g_bookmark_file_get_uris (bookmark, &uris_len);
    1024                 :            : 
    1025                 :          3 :   g_assert_cmpint (uris_len, ==, size);
    1026                 :            : 
    1027         [ +  + ]:          6 :   for (i = 0; i < uris_len; i++)
    1028                 :            :     {
    1029                 :          3 :       g_assert_true (g_bookmark_file_has_item (bookmark, uris[i]));
    1030                 :          3 :       error = NULL;
    1031                 :          3 :       mime = g_bookmark_file_get_mime_type (bookmark, uris[i], &error);
    1032                 :          3 :       g_assert_nonnull (mime);
    1033                 :          3 :       g_assert_no_error (error);
    1034                 :          3 :       g_free (mime);
    1035                 :            :     }
    1036                 :          3 :   g_strfreev (uris);
    1037                 :            : 
    1038                 :          3 :   g_assert_false (g_bookmark_file_has_item (bookmark, "file:///no/such/uri"));
    1039                 :          3 :   error = NULL;
    1040                 :          3 :   mime = g_bookmark_file_get_mime_type (bookmark, "file:///no/such/uri", &error);
    1041                 :          3 :   g_assert_null (mime);
    1042                 :          3 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
    1043                 :          3 :   g_error_free (error);
    1044                 :          3 :   g_free (mime);
    1045                 :          3 : }
    1046                 :            : 
    1047                 :            : static gboolean
    1048                 :          9 : test_modify (GBookmarkFile *bookmark)
    1049                 :            : {
    1050                 :            :   gchar *text;
    1051                 :            :   guint count;
    1052                 :            :   GDateTime *stamp;
    1053                 :          9 :   GDateTime *now = NULL;
    1054                 :          9 :   GError *error = NULL;
    1055                 :            :   gchar **groups;
    1056                 :            :   gsize length;
    1057                 :            :   gchar **apps;
    1058                 :            :   gchar *icon;
    1059                 :            :   gchar *mime;
    1060                 :            : 
    1061         [ -  + ]:          9 :   if (g_test_verbose ())
    1062                 :          0 :     g_printerr ("\t=> check global title/description...");
    1063                 :          9 :   g_bookmark_file_set_title (bookmark, NULL, "a file");
    1064                 :          9 :   g_bookmark_file_set_description (bookmark, NULL, "a bookmark file");
    1065                 :            : 
    1066                 :          9 :   text = g_bookmark_file_get_title (bookmark, NULL, &error);
    1067                 :          9 :   g_assert_no_error (error);
    1068                 :          9 :   g_assert_cmpstr (text, ==, "a file");
    1069                 :          9 :   g_free (text);
    1070                 :            : 
    1071                 :          9 :   text = g_bookmark_file_get_description (bookmark, NULL, &error);
    1072                 :          9 :   g_assert_no_error (error);
    1073                 :          9 :   g_assert_cmpstr (text, ==, "a bookmark file");
    1074                 :          9 :   g_free (text);
    1075         [ -  + ]:          9 :   if (g_test_verbose ())
    1076                 :          0 :     g_printerr ("ok\n");
    1077                 :            : 
    1078         [ -  + ]:          9 :   if (g_test_verbose ())
    1079                 :          0 :     g_printerr ("\t=> check bookmark title/description...");
    1080                 :          9 :   g_bookmark_file_set_title (bookmark, TEST_URI_0, "a title");
    1081                 :          9 :   g_bookmark_file_set_description (bookmark, TEST_URI_0, "a description");
    1082                 :          9 :   g_bookmark_file_set_is_private (bookmark, TEST_URI_0, TRUE);
    1083                 :          9 :   now = g_date_time_new_now_utc ();
    1084                 :          9 :   g_bookmark_file_set_added_date_time (bookmark, TEST_URI_0, now);
    1085                 :          9 :   g_bookmark_file_set_visited_date_time (bookmark, TEST_URI_0, now);
    1086                 :          9 :   g_bookmark_file_set_icon (bookmark, TEST_URI_0, "testicon", "image/png");
    1087                 :            : 
    1088                 :            :   /* Check the modification date by itself, as it’s updated whenever we modify
    1089                 :            :    * other properties. */
    1090                 :          9 :   g_bookmark_file_set_modified_date_time (bookmark, TEST_URI_0, now);
    1091                 :          9 :   stamp = g_bookmark_file_get_modified_date_time (bookmark, TEST_URI_0, &error);
    1092                 :          9 :   g_assert_no_error (error);
    1093                 :          9 :   g_assert_cmpint (g_date_time_compare (stamp, now), ==, 0);
    1094                 :            : 
    1095                 :          9 :   text = g_bookmark_file_get_title (bookmark, TEST_URI_0, &error);
    1096                 :          9 :   g_assert_no_error (error);
    1097                 :          9 :   g_assert_cmpstr (text, ==, "a title");
    1098                 :          9 :   g_free (text);
    1099                 :          9 :   text = g_bookmark_file_get_description (bookmark, TEST_URI_0, &error);
    1100                 :          9 :   g_assert_no_error (error);
    1101                 :          9 :   g_assert_cmpstr (text, ==, "a description");
    1102                 :          9 :   g_free (text);
    1103                 :          9 :   g_assert_true (g_bookmark_file_get_is_private (bookmark, TEST_URI_0, &error));
    1104                 :          9 :   g_assert_no_error (error);
    1105                 :          9 :   stamp = g_bookmark_file_get_added_date_time (bookmark, TEST_URI_0, &error);
    1106                 :          9 :   g_assert_no_error (error);
    1107                 :          9 :   g_assert_cmpint (g_date_time_compare (stamp, now), ==, 0);
    1108                 :          9 :   stamp = g_bookmark_file_get_visited_date_time (bookmark, TEST_URI_0, &error);
    1109                 :          9 :   g_assert_no_error (error);
    1110                 :          9 :   g_assert_cmpint (g_date_time_compare (stamp, now), ==, 0);
    1111                 :          9 :   g_assert_true (g_bookmark_file_get_icon (bookmark, TEST_URI_0, &icon, &mime, &error));
    1112                 :          9 :   g_assert_no_error (error);
    1113                 :          9 :   g_assert_cmpstr (icon, ==, "testicon");
    1114                 :          9 :   g_assert_cmpstr (mime, ==, "image/png");
    1115                 :          9 :   g_free (icon);
    1116                 :          9 :   g_free (mime);
    1117         [ -  + ]:          9 :   if (g_test_verbose ())
    1118                 :          0 :     g_printerr ("ok\n");
    1119                 :            : 
    1120         [ -  + ]:          9 :   if (g_test_verbose ())
    1121                 :          0 :     g_printerr ("\t=> check non existing bookmark...");
    1122                 :          9 :   g_bookmark_file_get_description (bookmark, TEST_URI_1, &error);
    1123                 :          9 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
    1124                 :          9 :   g_clear_error (&error);
    1125                 :          9 :   g_bookmark_file_get_is_private (bookmark, TEST_URI_1, &error);
    1126                 :          9 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
    1127                 :          9 :   g_clear_error (&error);
    1128                 :          9 :   g_bookmark_file_get_added_date_time (bookmark, TEST_URI_1, &error);
    1129                 :          9 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
    1130                 :          9 :   g_clear_error (&error);
    1131                 :          9 :   g_bookmark_file_get_modified_date_time (bookmark, TEST_URI_1, &error);
    1132                 :          9 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
    1133                 :          9 :   g_clear_error (&error);
    1134                 :          9 :   g_bookmark_file_get_visited_date_time (bookmark, TEST_URI_1, &error);
    1135                 :          9 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
    1136                 :          9 :   g_clear_error (&error);
    1137         [ -  + ]:          9 :   if (g_test_verbose ())
    1138                 :          0 :     g_printerr ("ok\n");
    1139                 :            : 
    1140         [ -  + ]:          9 :   if (g_test_verbose ())
    1141                 :          0 :     g_printerr ("\t=> check application...");
    1142                 :          9 :   g_bookmark_file_set_mime_type (bookmark, TEST_URI_0, TEST_MIME);
    1143                 :          9 :   g_assert_false (g_bookmark_file_has_application (bookmark, TEST_URI_0, TEST_APP_NAME, NULL));
    1144                 :          9 :   g_bookmark_file_add_application (bookmark, TEST_URI_0,
    1145                 :            :                                    TEST_APP_NAME,
    1146                 :            :                                    TEST_APP_EXEC);
    1147                 :          9 :   g_assert_true (g_bookmark_file_has_application (bookmark, TEST_URI_0, TEST_APP_NAME, NULL));
    1148                 :          9 :   g_bookmark_file_get_application_info (bookmark, TEST_URI_0, TEST_APP_NAME,
    1149                 :            :                                         &text,
    1150                 :            :                                         &count,
    1151                 :            :                                         &stamp,
    1152                 :            :                                         &error);
    1153                 :          9 :   g_assert_no_error (error);
    1154                 :          9 :   g_assert_cmpuint (count, ==, 1);
    1155                 :          9 :   g_assert_cmpint (g_date_time_compare (stamp, g_bookmark_file_get_modified_date_time (bookmark, TEST_URI_0, NULL)), <=, 0);
    1156                 :          9 :   g_free (text);
    1157                 :          9 :   g_assert_true (g_bookmark_file_remove_application (bookmark, TEST_URI_0, TEST_APP_NAME, &error));
    1158                 :          9 :   g_assert_no_error (error);
    1159                 :          9 :   g_bookmark_file_add_application (bookmark, TEST_URI_0, TEST_APP_NAME, TEST_APP_EXEC);
    1160                 :          9 :   apps = g_bookmark_file_get_applications (bookmark, TEST_URI_0, &length, &error);
    1161                 :          9 :   g_assert_no_error (error);
    1162                 :          9 :   g_assert_cmpint (length, ==, 1);
    1163                 :          9 :   g_assert_cmpstr (apps[0], ==, TEST_APP_NAME);
    1164                 :          9 :   g_strfreev (apps);
    1165                 :            : 
    1166                 :          9 :   g_bookmark_file_get_application_info (bookmark, TEST_URI_0, "fail",
    1167                 :            :                                         &text,
    1168                 :            :                                         &count,
    1169                 :            :                                         &stamp,
    1170                 :            :                                         &error);
    1171                 :          9 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED);
    1172                 :          9 :   g_clear_error (&error);
    1173                 :            : 
    1174         [ -  + ]:          9 :   if (g_test_verbose ())
    1175                 :          0 :     g_printerr ("ok\n");
    1176                 :            : 
    1177         [ -  + ]:          9 :   if (g_test_verbose ())
    1178                 :          0 :     g_printerr ("\t=> check groups...");
    1179                 :          9 :   g_assert_false (g_bookmark_file_has_group (bookmark, TEST_URI_1, "Test", NULL));
    1180                 :          9 :   g_bookmark_file_add_group (bookmark, TEST_URI_1, "Test");
    1181                 :          9 :   g_assert_true (g_bookmark_file_has_group (bookmark, TEST_URI_1, "Test", NULL));
    1182                 :          9 :   g_assert_false (g_bookmark_file_has_group (bookmark, TEST_URI_1, "Fail", NULL));
    1183                 :          9 :   g_assert_true (g_bookmark_file_remove_group (bookmark, TEST_URI_1, "Test", &error));
    1184                 :          9 :   g_assert_no_error (error);
    1185                 :          9 :   groups = g_bookmark_file_get_groups (bookmark, TEST_URI_1, NULL, &error);
    1186                 :          9 :   g_assert_cmpint (g_strv_length (groups), ==, 0);
    1187                 :          9 :   g_strfreev (groups);
    1188                 :          9 :   groups = g_new0 (gchar *, 3);
    1189                 :          9 :   groups[0] = "Group1";
    1190                 :          9 :   groups[1] = "Group2";
    1191                 :          9 :   groups[2] = NULL;
    1192                 :          9 :   g_bookmark_file_set_groups (bookmark, TEST_URI_1, (const gchar **)groups, 2);
    1193                 :          9 :   g_free (groups);
    1194                 :          9 :   groups = g_bookmark_file_get_groups (bookmark, TEST_URI_1, &length, &error);
    1195                 :          9 :   g_assert_cmpint (length, ==, 2);
    1196                 :          9 :   g_strfreev (groups);
    1197                 :          9 :   g_assert_no_error (error);
    1198                 :            : 
    1199         [ -  + ]:          9 :   if (g_test_verbose ())
    1200                 :          0 :     g_printerr ("ok\n");
    1201                 :            : 
    1202         [ -  + ]:          9 :   if (g_test_verbose ())
    1203                 :          0 :     g_printerr ("\t=> check remove...");
    1204                 :          9 :   g_assert_true (g_bookmark_file_remove_item (bookmark, TEST_URI_1, &error));
    1205                 :          9 :   g_assert_no_error (error);
    1206                 :          9 :   g_assert_false (g_bookmark_file_remove_item (bookmark, TEST_URI_1, &error));
    1207                 :          9 :   g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
    1208                 :          9 :   g_clear_error (&error);
    1209         [ -  + ]:          9 :   if (g_test_verbose ())
    1210                 :          0 :     g_printerr ("ok\n");
    1211                 :            : 
    1212                 :          9 :   g_date_time_unref (now);
    1213                 :            : 
    1214                 :          9 :   return TRUE;
    1215                 :            : }
    1216                 :            : 
    1217                 :            : static void
    1218                 :         45 : test_file (gconstpointer d)
    1219                 :            : {
    1220                 :         45 :   const gchar *filename = d;
    1221                 :            :   GBookmarkFile *bookmark_file;
    1222                 :            :   gboolean success;
    1223                 :            :   gchar *data;
    1224                 :            :   GError *error;
    1225                 :            : 
    1226                 :         45 :   bookmark_file = g_bookmark_file_new ();
    1227                 :         45 :   g_assert_nonnull (bookmark_file);
    1228                 :            : 
    1229                 :         45 :   success = test_load (bookmark_file, filename);
    1230                 :            : 
    1231         [ +  + ]:         45 :   if (success)
    1232                 :            :     {
    1233                 :          3 :       test_query (bookmark_file);
    1234                 :          3 :       test_modify (bookmark_file);
    1235                 :            : 
    1236                 :          3 :       error = NULL;
    1237                 :          3 :       data = g_bookmark_file_to_data (bookmark_file, NULL, &error);
    1238                 :          3 :       g_assert_no_error (error);
    1239                 :            :       /* FIXME do some checks on data */
    1240                 :          3 :       g_free (data);
    1241                 :            :     }
    1242                 :            : 
    1243                 :         45 :   g_bookmark_file_free (bookmark_file);
    1244                 :            : 
    1245                 :         45 :   g_assert_true (success == (strstr (filename, "fail") == NULL));
    1246                 :         45 : }
    1247                 :            : 
    1248                 :            : static void
    1249                 :         45 : test_file_copy (gconstpointer d)
    1250                 :            : {
    1251                 :         45 :   const gchar *filename = d;
    1252                 :            :   GBookmarkFile *bookmark_file;
    1253                 :            :   GBookmarkFile *copy;
    1254                 :            :   gboolean success;
    1255                 :            :   gchar *data;
    1256                 :            :   gchar *copy_data;
    1257                 :            :   gsize length;
    1258                 :            :   gsize copy_length;
    1259                 :         45 :   GError *error = NULL;
    1260                 :            : 
    1261                 :         45 :   bookmark_file = g_bookmark_file_new ();
    1262                 :         45 :   g_assert_nonnull (bookmark_file);
    1263                 :            : 
    1264                 :         45 :   success = test_load (bookmark_file, filename);
    1265                 :         45 :   g_assert_true (success == (strstr (filename, "fail") == NULL));
    1266                 :            : 
    1267                 :         45 :   copy = g_bookmark_file_copy (bookmark_file);
    1268                 :         45 :   g_assert_nonnull (copy);
    1269                 :            : 
    1270   [ +  -  -  +  :         45 :   if (g_str_has_suffix (filename, "fail-08.xbel") ||
             +  -  +  + ]
    1271   [ +  -  -  +  :         44 :       g_str_has_suffix (filename, "fail-06.xbel") ||
             +  -  +  + ]
    1272   [ +  -  -  +  :         43 :       g_str_has_suffix (filename, "fail-07.xbel") ||
             +  -  +  + ]
    1273   [ +  -  -  +  :         42 :       g_str_has_suffix (filename, "fail-09.xbel") ||
             +  -  +  + ]
    1274   [ +  -  -  +  :         41 :       g_str_has_suffix (filename, "fail-10.xbel") ||
             +  -  +  + ]
    1275   [ +  -  -  +  :         40 :       g_str_has_suffix (filename, "fail-11.xbel") ||
             +  -  +  + ]
    1276   [ +  -  -  +  :         39 :       g_str_has_suffix (filename, "fail-39.xbel"))
             +  -  +  + ]
    1277                 :            :     {
    1278                 :          7 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
    1279                 :            :                              "*no registered applications*skipping*");
    1280                 :          7 :       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
    1281                 :            :                              "*no registered applications*skipping*");
    1282                 :            :     }
    1283                 :            : 
    1284                 :         45 :   data = g_bookmark_file_to_data (bookmark_file, &length, &error);
    1285                 :         45 :   g_assert_no_error (error);
    1286                 :            : 
    1287                 :         45 :   copy_data = g_bookmark_file_to_data (copy, &copy_length, &error);
    1288                 :         45 :   g_assert_no_error (error);
    1289                 :            : 
    1290                 :         45 :   g_test_assert_expected_messages ();
    1291                 :            : 
    1292                 :         45 :   g_assert_cmpuint (length, ==, copy_length);
    1293                 :         45 :   g_assert_cmpstr (data, ==, copy_data);
    1294                 :            : 
    1295         [ +  + ]:         45 :   if (success)
    1296                 :            :     {
    1297                 :            :       GBookmarkFile *modified_copy;
    1298                 :            :       gchar *modified_data;
    1299                 :            :       gchar *modified_copy_data;
    1300                 :            :       gsize modified_length;
    1301                 :            :       gsize modified_copy_length;
    1302                 :            : 
    1303                 :          3 :       test_modify (bookmark_file);
    1304                 :          3 :       test_modify (copy);
    1305                 :            : 
    1306                 :          3 :       modified_data = g_bookmark_file_to_data (bookmark_file,
    1307                 :            :                                                &modified_length,
    1308                 :            :                                                &error);
    1309                 :          3 :       g_assert_no_error (error);
    1310                 :            : 
    1311                 :          3 :       modified_copy_data = g_bookmark_file_to_data (copy,
    1312                 :            :                                                     &modified_copy_length,
    1313                 :            :                                                     &error);
    1314                 :          3 :       g_assert_no_error (error);
    1315                 :            : 
    1316                 :          3 :       g_assert_cmpstr (data, !=, modified_data);
    1317                 :          3 :       g_assert_cmpstr (copy_data, !=, modified_copy_data);
    1318                 :            : 
    1319                 :          3 :       g_free (modified_copy_data);
    1320                 :          3 :       modified_copy = g_bookmark_file_copy (bookmark_file);
    1321                 :          3 :       modified_copy_data = g_bookmark_file_to_data (modified_copy,
    1322                 :            :                                                     &modified_copy_length,
    1323                 :            :                                                     &error);
    1324                 :          3 :       g_assert_no_error (error);
    1325                 :            : 
    1326                 :          3 :       g_assert_cmpuint (modified_length, ==, modified_copy_length);
    1327                 :          3 :       g_assert_cmpstr (modified_data, ==, modified_copy_data);
    1328                 :            : 
    1329                 :          3 :       g_free (modified_data);
    1330                 :          3 :       g_free (modified_copy_data);
    1331                 :          3 :       g_bookmark_file_free (modified_copy);
    1332                 :            :     }
    1333                 :            : 
    1334                 :         45 :   g_bookmark_file_free (bookmark_file);
    1335                 :         45 :   g_bookmark_file_free (copy);
    1336                 :            : 
    1337                 :         45 :   g_free (data);
    1338                 :         45 :   g_free (copy_data);
    1339                 :         45 : }
    1340                 :            : 
    1341                 :            : int
    1342                 :          1 : main (int argc, char *argv[])
    1343                 :            : {
    1344                 :            :   GDir *dir;
    1345                 :            :   GError *error;
    1346                 :            :   const gchar *name;
    1347                 :            :   gchar *path;
    1348                 :            : 
    1349                 :          1 :   g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
    1350                 :            : 
    1351         [ -  + ]:          1 :   if (argc > 1)
    1352                 :            :     {
    1353                 :          0 :       test_file (argv[1]);
    1354                 :          0 :       return 0;
    1355                 :            :     }
    1356                 :            : 
    1357                 :          1 :   g_test_add_func ("/bookmarks/load-from-data-dirs", test_load_from_data_dirs);
    1358                 :          1 :   g_test_add_func ("/bookmarks/to-file", test_to_file);
    1359                 :          1 :   g_test_add_func ("/bookmarks/move-item", test_move_item);
    1360                 :          1 :   g_test_add_func ("/bookmarks/corner-cases", test_corner_cases);
    1361                 :          1 :   g_test_add_func ("/bookmarks/misc", test_misc);
    1362                 :          1 :   g_test_add_func ("/bookmarks/deprecated", test_deprecated);
    1363                 :            : 
    1364                 :          1 :   error = NULL;
    1365                 :          1 :   path = g_test_build_filename (G_TEST_DIST, "bookmarks", NULL);
    1366                 :          1 :   dir = g_dir_open (path, 0, &error);
    1367                 :          1 :   g_free (path);
    1368                 :          1 :   g_assert_no_error (error);
    1369         [ +  + ]:         46 :   while ((name = g_dir_read_name (dir)) != NULL)
    1370                 :            :     {
    1371                 :            :       gchar *filename;
    1372   [ +  -  -  +  :         45 :       if (!g_str_has_suffix (name, ".xbel"))
             +  -  -  + ]
    1373                 :          0 :         continue;
    1374                 :            : 
    1375                 :         45 :       filename = g_test_build_filename (G_TEST_DIST, "bookmarks", name, NULL);
    1376                 :            : 
    1377                 :         45 :       path = g_strdup_printf ("/bookmarks/parse/%s", name);
    1378                 :         45 :       g_test_add_data_func_full (path, filename, test_file, g_free);
    1379                 :         45 :       g_free (path);
    1380                 :         45 :       path = g_strdup_printf ("/bookmarks/copy/%s", name);
    1381                 :         45 :       g_test_add_data_func_full (path, g_strdup (filename), test_file_copy, g_free);
    1382                 :         45 :       g_free (path);
    1383                 :            :     }
    1384                 :          1 :   g_dir_close (dir);
    1385                 :            : 
    1386                 :          1 :   return g_test_run ();
    1387                 :            : }

Generated by: LCOV version 1.14