* otherwise) arising in any way out of the use of this software, even
* if advised of the possibility of such damage.
*/
-#include <glib/gtestutils.h>
+
#include <glib/glib.h>
#include <gio/gio.h>
#include <stdlib.h>
GFileInfo *info_dup;
GFileInfo *info_copy;
char **attr_list;
+ GFileAttributeMatcher *matcher;
info = g_file_info_new ();
attr_list = g_file_info_list_attributes (info, NULL);
g_assert (attr_list != NULL);
g_assert (*attr_list == NULL);
-
+ g_strfreev (attr_list);
+
g_file_info_set_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_NAME, TEST_NAME);
g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, TEST_DISPLAY_NAME);
g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE, TEST_SIZE);
attr_list = g_file_info_list_attributes (info, NULL);
g_assert (attr_list != NULL);
g_assert (*attr_list != NULL);
-
+ g_strfreev (attr_list);
+
test_assigned_values (info);
/* Test dups */
g_file_info_copy_into (info_dup, info_copy);
g_assert (info_copy != NULL);
test_assigned_values (info_copy);
-
+
/* Test remove attribute */
g_assert (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) == FALSE);
g_file_info_set_attribute_int32 (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER, 10);
g_assert (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) == TRUE);
-
+
+ g_assert (g_file_info_get_attribute_type (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) == G_FILE_ATTRIBUTE_TYPE_INT32);
+ g_assert (g_file_info_get_attribute_status (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) != G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING);
+
g_file_info_remove_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER);
g_assert (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) == FALSE);
-
+ g_assert (g_file_info_get_attribute_type (info, G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) == G_FILE_ATTRIBUTE_TYPE_INVALID);
+
+ matcher = g_file_attribute_matcher_new (G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+
+ g_assert (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_STANDARD_NAME) == TRUE);
+ g_assert (g_file_attribute_matcher_matches_only (matcher, G_FILE_ATTRIBUTE_STANDARD_NAME) == FALSE);
+ g_assert (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_STANDARD_SIZE) == FALSE);
+
+ g_file_info_set_attribute_mask (info, matcher);
+ g_file_attribute_matcher_unref (matcher);
+
+ g_assert (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE) == FALSE);
+ g_assert (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_NAME) == TRUE);
+
g_object_unref (info);
g_object_unref (info_dup);
g_object_unref (info_copy);
main (int argc,
char *argv[])
{
- g_type_init ();
- g_thread_init (0);
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/g-file-info/test_g_file_info", test_g_file_info);