void eel_self_check_glib_extensions (void) { GList *compare_list_1; GList *compare_list_2; GList *compare_list_3; GList *compare_list_4; GList *compare_list_5; GList *list_to_partition; GList *expected_passed; GList *expected_failed; GList *actual_passed; GList *actual_failed; /* eel_g_str_list_equal */ /* We g_strdup because identical string constants can be shared. */ compare_list_1 = NULL; compare_list_1 = g_list_append (compare_list_1, g_strdup ("Apple")); compare_list_1 = g_list_append (compare_list_1, g_strdup ("zebra")); compare_list_1 = g_list_append (compare_list_1, g_strdup ("!@#!@$#@$!")); compare_list_2 = NULL; compare_list_2 = g_list_append (compare_list_2, g_strdup ("Apple")); compare_list_2 = g_list_append (compare_list_2, g_strdup ("zebra")); compare_list_2 = g_list_append (compare_list_2, g_strdup ("!@#!@$#@$!")); compare_list_3 = NULL; compare_list_3 = g_list_append (compare_list_3, g_strdup ("Apple")); compare_list_3 = g_list_append (compare_list_3, g_strdup ("zebra")); compare_list_4 = NULL; compare_list_4 = g_list_append (compare_list_4, g_strdup ("Apple")); compare_list_4 = g_list_append (compare_list_4, g_strdup ("zebra")); compare_list_4 = g_list_append (compare_list_4, g_strdup ("!@#!@$#@$!")); compare_list_4 = g_list_append (compare_list_4, g_strdup ("foobar")); compare_list_5 = NULL; compare_list_5 = g_list_append (compare_list_5, g_strdup ("Apple")); compare_list_5 = g_list_append (compare_list_5, g_strdup ("zzzzzebraaaaaa")); compare_list_5 = g_list_append (compare_list_5, g_strdup ("!@#!@$#@$!")); EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_2), TRUE); EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_3), FALSE); EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_4), FALSE); EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_5), FALSE); g_list_free_full (compare_list_1, g_free); g_list_free_full (compare_list_2, g_free); g_list_free_full (compare_list_3, g_free); g_list_free_full (compare_list_4, g_free); g_list_free_full (compare_list_5, g_free); /* eel_g_list_partition */ list_to_partition = NULL; list_to_partition = g_list_append (list_to_partition, "Cadillac"); list_to_partition = g_list_append (list_to_partition, "Pontiac"); list_to_partition = g_list_append (list_to_partition, "Ford"); list_to_partition = g_list_append (list_to_partition, "Range Rover"); expected_passed = NULL; expected_passed = g_list_append (expected_passed, "Cadillac"); expected_passed = g_list_append (expected_passed, "Ford"); expected_failed = NULL; expected_failed = g_list_append (expected_failed, "Pontiac"); expected_failed = g_list_append (expected_failed, "Range Rover"); actual_passed = eel_g_list_partition (list_to_partition, eel_test_predicate, "m", &actual_failed); EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (expected_passed, actual_passed), TRUE); EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (expected_failed, actual_failed), TRUE); /* Don't free "list_to_partition", since it is consumed * by eel_g_list_partition. */ g_list_free (expected_passed); g_list_free (actual_passed); g_list_free (expected_failed); g_list_free (actual_failed); }
void nautilus_self_check_directory (void) { NautilusDirectory *directory; NautilusFile *file; directory = nautilus_directory_get_by_uri ("file:///etc"); file = nautilus_file_get_by_uri ("file:///etc/passwd"); EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1); nautilus_directory_file_monitor_add (directory, &data_dummy, TRUE, 0, NULL, NULL); /* FIXME: these need to be updated to the new metadata infrastructure * as make check doesn't pass. nautilus_file_set_metadata (file, "test", "default", "value"); EEL_CHECK_STRING_RESULT (nautilus_file_get_metadata (file, "test", "default"), "value"); nautilus_file_set_boolean_metadata (file, "test_boolean", TRUE, TRUE); EEL_CHECK_BOOLEAN_RESULT (nautilus_file_get_boolean_metadata (file, "test_boolean", TRUE), TRUE); nautilus_file_set_boolean_metadata (file, "test_boolean", TRUE, FALSE); EEL_CHECK_BOOLEAN_RESULT (nautilus_file_get_boolean_metadata (file, "test_boolean", TRUE), FALSE); EEL_CHECK_BOOLEAN_RESULT (nautilus_file_get_boolean_metadata (NULL, "test_boolean", TRUE), TRUE); nautilus_file_set_integer_metadata (file, "test_integer", 0, 17); EEL_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "test_integer", 0), 17); nautilus_file_set_integer_metadata (file, "test_integer", 0, -1); EEL_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "test_integer", 0), -1); nautilus_file_set_integer_metadata (file, "test_integer", 42, 42); EEL_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "test_integer", 42), 42); EEL_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (NULL, "test_integer", 42), 42); EEL_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "nonexistent_key", 42), 42); */ EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get_by_uri ("file:///etc") == directory, TRUE); nautilus_directory_unref (directory); EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get_by_uri ("file:///etc/") == directory, TRUE); nautilus_directory_unref (directory); EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get_by_uri ("file:///etc////") == directory, TRUE); nautilus_directory_unref (directory); nautilus_file_unref (file); nautilus_directory_file_monitor_remove (directory, &data_dummy); nautilus_directory_unref (directory); while (g_hash_table_size (directories) != 0) { gtk_main_iteration (); } EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 0); directory = nautilus_directory_get_by_uri ("file:///etc"); got_files_flag = FALSE; nautilus_directory_call_when_ready (directory, NAUTILUS_FILE_ATTRIBUTE_INFO | NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS, TRUE, got_files_callback, &data_dummy); while (!got_files_flag) { gtk_main_iteration (); } EEL_CHECK_BOOLEAN_RESULT (directory->details->file_list == NULL, TRUE); EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1); file = nautilus_file_get_by_uri ("file:///etc/passwd"); /* EEL_CHECK_STRING_RESULT (nautilus_file_get_metadata (file, "test", "default"), "value"); */ nautilus_file_unref (file); nautilus_directory_unref (directory); EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 0); }
void eel_self_check_gdk_pixbuf_extensions (void) { GdkPixbuf *pixbuf; EelIRect clip_area; pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 100, 100); EEL_CHECK_BOOLEAN_RESULT (eel_gdk_pixbuf_is_valid (pixbuf), TRUE); EEL_CHECK_BOOLEAN_RESULT (eel_gdk_pixbuf_is_valid (NULL), FALSE); EEL_CHECK_DIMENSIONS_RESULT (eel_gdk_pixbuf_get_dimensions (pixbuf), 100, 100); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, eel_gdk_pixbuf_whole_pixbuf), 0, 0, 100, 100); clip_area = eel_irect_assign (0, 0, 0, 0); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 0, 0); clip_area = eel_irect_assign (0, 0, 0, 0); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 0, 0); clip_area = eel_irect_assign (0, 0, 100, 100); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 100, 100); clip_area = eel_irect_assign (-10, -10, 100, 100); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 90, 90); clip_area = eel_irect_assign (-10, -10, 110, 110); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 100, 100); clip_area = eel_irect_assign (0, 0, 99, 99); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 99, 99); clip_area = eel_irect_assign (0, 0, 1, 1); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 1, 1); clip_area = eel_irect_assign (-1, -1, 1, 1); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 0, 0); clip_area = eel_irect_assign (-1, -1, 2, 2); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 1, 1); clip_area = eel_irect_assign (100, 100, 1, 1); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 0, 0); clip_area = eel_irect_assign (101, 101, 1, 1); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 0, 0, 0, 0); clip_area = eel_irect_assign (80, 0, 100, 100); EEL_CHECK_RECTANGLE_RESULT (eel_gdk_pixbuf_intersect (pixbuf, 0, 0, clip_area), 80, 0, 100, 100); g_object_unref (pixbuf); /* No checks for empty pixbufs because GdkPixbuf doesn't seem to allow them. */ EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "00,00,00"), "00,00,00,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "00,00,00,00"), "00,00,00,00"); EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "00,00,00,FF"), "00,00,00,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "01,01,01"), "01,01,01,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "FE,FE,FE"), "FE,FE,FE,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "FF,FF,FF"), "FF,FF,FF,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "FF,FF,FF,00"), "00,00,00,00"); EEL_CHECK_STRING_RESULT (check_average_value (1, 1, "11,22,33"), "11,22,33,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "00,00,00"), "00,00,00,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "00,00,00,00"), "00,00,00,00"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "00,00,00,FF"), "00,00,00,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "01,01,01"), "01,01,01,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "FE,FE,FE"), "FE,FE,FE,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "FF,FF,FF"), "FF,FF,FF,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "FF,FF,FF,00"), "00,00,00,00"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "11,22,33"), "11,22,33,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "gray -1"), "7F,7F,7F,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "gray 0"), "80,80,80,FF"); EEL_CHECK_STRING_RESULT (check_average_value (1000, 1000, "gray 1"), "80,80,80,FF"); }