1 /* GTK - The GIMP Toolkit
2 * autotestfilechooser.c: Automated unit tests for the GtkFileChooser widget
3 * Copyright (C) 2005, Novell, Inc.
6 * Federico Mena-Quintero <federico@novell.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
24 * - In test_reload_sequence(), test that the selection is preserved properly
30 #define SLEEP_DURATION 100
34 #include <glib/gprintf.h>
36 #include "gtk/gtkfilechooserprivate.h"
37 #include "gtk/gtkfilechooserdefault.h"
38 #include "gtk/gtkfilechooserentry.h"
42 get_action_name (GtkFileChooserAction action)
46 case GTK_FILE_CHOOSER_ACTION_OPEN: return "OPEN";
47 case GTK_FILE_CHOOSER_ACTION_SAVE: return "SAVE";
48 case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: return "SELECT_FOLDER";
49 case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: return "CREATE_FOLDER";
52 g_assert_not_reached ();
60 log_test (gboolean passed, const char *test_name, ...)
65 va_start (args, test_name);
66 str = g_strdup_vprintf (test_name, args);
70 g_printf ("%s: %s\n", passed ? "PASSED" : "FAILED", str);
74 typedef void (* SetFilenameFn) (GtkFileChooser *chooser, gpointer data);
75 typedef void (* CompareFilenameFn) (GtkFileChooser *chooser, gpointer data);
77 struct test_set_filename_closure {
79 GtkWidget *accept_button;
80 gboolean focus_button;
84 set_filename_timeout_cb (gpointer data)
86 struct test_set_filename_closure *closure;
90 if (closure->focus_button)
91 gtk_widget_grab_focus (closure->accept_button);
93 gtk_button_clicked (GTK_BUTTON (closure->accept_button));
100 static guint wait_for_idle_id = 0;
103 wait_for_idle_idle (gpointer data)
105 wait_for_idle_id = 0;
107 return G_SOURCE_REMOVE;
113 wait_for_idle_id = g_idle_add_full (G_PRIORITY_LOW + 100,
117 while (wait_for_idle_id)
118 gtk_main_iteration ();
123 test_set_filename (GtkFileChooserAction action,
124 gboolean focus_button,
125 SetFilenameFn set_filename_fn,const
126 CompareFilenameFn compare_filename_fn,
130 struct test_set_filename_closure closure;
132 chooser = gtk_file_chooser_dialog_new ("hello", NULL, action,
133 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
136 closure.chooser = chooser;
137 closure.accept_button = gtk_dialog_add_button (GTK_DIALOG (chooser), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
138 closure.focus_button = focus_button;
140 gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
142 (* set_filename_fn) (GTK_FILE_CHOOSER (chooser), data);
144 gdk_threads_add_timeout_full (G_MAXINT, SLEEP_DURATION, set_filename_timeout_cb, &closure, NULL);
145 gtk_dialog_run (GTK_DIALOG (chooser));
147 (* compare_filename_fn) (GTK_FILE_CHOOSER (chooser), data);
149 gtk_widget_destroy (chooser);
153 set_filename_cb (GtkFileChooser *chooser, gpointer data)
155 const char *filename;
158 gtk_file_chooser_set_filename (chooser, filename);
162 compare_filename_cb (GtkFileChooser *chooser, gpointer data)
164 const char *filename;
168 out_filename = gtk_file_chooser_get_filename (chooser);
170 g_assert_cmpstr (out_filename, ==, filename);
173 g_free (out_filename);
178 const char *test_name;
179 GtkFileChooserAction action;
180 const char *filename;
181 gboolean focus_button;
182 } TestSetFilenameSetup;
185 test_black_box_set_filename (gconstpointer data)
187 const TestSetFilenameSetup *setup = data;
189 test_set_filename (setup->action, setup->focus_button, set_filename_cb, compare_filename_cb, (char *) setup->filename);
192 struct current_name_closure {
194 const char *current_name;
198 set_current_name_cb (GtkFileChooser *chooser, gpointer data)
200 struct current_name_closure *closure;
204 gtk_file_chooser_set_current_folder (chooser, closure->path);
205 gtk_file_chooser_set_current_name (chooser, closure->current_name);
209 compare_current_name_cb (GtkFileChooser *chooser, gpointer data)
211 struct current_name_closure *closure;
217 out_filename = gtk_file_chooser_get_filename (chooser);
219 g_assert (out_filename != NULL);
221 filename = g_build_filename (closure->path, closure->current_name, NULL);
222 g_assert_cmpstr (filename, ==, out_filename);
225 g_free (out_filename);
230 const char *test_name;
231 GtkFileChooserAction action;
232 const char *current_name;
233 gboolean focus_button;
234 } TestSetCurrentNameSetup;
237 test_black_box_set_current_name (gconstpointer data)
239 const TestSetCurrentNameSetup *setup = data;
240 struct current_name_closure closure;
243 cwd = g_get_current_dir ();
246 closure.current_name = setup->current_name;
248 test_set_filename (setup->action, setup->focus_button, set_current_name_cb, compare_current_name_cb, &closure);
254 /* FIXME: fails in CREATE_FOLDER mode when FOLDER_NAME == "/" */
257 #define FILE_NAME "/nonexistent"
258 #define FILE_NAME_2 "/nonexistent2"
259 #define FOLDER_NAME "/etc"
260 #define FOLDER_NAME_2 "/usr"
262 #define FILE_NAME "/etc/passwd"
263 #define FILE_NAME_2 "/etc/group"
264 #define FOLDER_NAME "/etc"
265 #define FOLDER_NAME_2 "/usr"
268 #define CURRENT_NAME "parangaricutirimicuaro.txt"
269 #define CURRENT_NAME_FOLDER "parangaricutirimicuaro"
271 /* https://bugzilla.novell.com/show_bug.cgi?id=184875
272 * http://bugzilla.gnome.org/show_bug.cgi?id=347066
273 * http://bugzilla.gnome.org/show_bug.cgi?id=346058
278 setup_set_filename_tests (void)
280 static TestSetFilenameSetup tests[] =
282 { "/GtkFileChooser/black_box/set_filename/open/no_focus", GTK_FILE_CHOOSER_ACTION_OPEN, FILE_NAME, FALSE },
283 { "/GtkFileChooser/black_box/set_filename/open/focus", GTK_FILE_CHOOSER_ACTION_OPEN, FILE_NAME, TRUE },
284 { "/GtkFileChooser/black_box/set_filename/save/no_focus", GTK_FILE_CHOOSER_ACTION_SAVE, FILE_NAME, FALSE },
285 { "/GtkFileChooser/black_box/set_filename/save/focus", GTK_FILE_CHOOSER_ACTION_SAVE, FILE_NAME, TRUE },
286 { "/GtkFileChooser/black_box/set_filename/select_folder/no_focus", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, FOLDER_NAME,FALSE },
287 { "/GtkFileChooser/black_box/set_filename/select_folder/focus", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, FOLDER_NAME,TRUE },
288 { "/GtkFileChooser/black_box/set_filename/create_folder/no_focus", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, FOLDER_NAME,FALSE },
289 { "/GtkFileChooser/black_box/set_filename/create_folder/focus", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, FOLDER_NAME,TRUE },
293 for (i = 0; i < G_N_ELEMENTS (tests); i++)
294 g_test_add_data_func (tests[i].test_name, &tests[i], test_black_box_set_filename);
298 setup_set_current_name_tests (void)
300 static TestSetCurrentNameSetup tests[] =
302 { "/GtkFileChooser/black_box/set_current_name/save/no_focus", GTK_FILE_CHOOSER_ACTION_SAVE, CURRENT_NAME, FALSE },
303 { "/GtkFileChooser/black_box/set_current_name/save/focus", GTK_FILE_CHOOSER_ACTION_SAVE, CURRENT_NAME, TRUE },
304 { "/GtkFileChooser/black_box/set_current_name/create_folder/no_focus", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, CURRENT_NAME_FOLDER, FALSE },
305 { "/GtkFileChooser/black_box/set_current_name/create_folder/focus", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, CURRENT_NAME_FOLDER, TRUE },
309 for (i = 0; i < G_N_ELEMENTS (tests); i++)
310 g_test_add_data_func (tests[i].test_name, &tests[i], test_black_box_set_current_name);
316 const char *shortname;
317 GtkFileChooserAction action;
318 const char *initial_current_folder;
319 const char *initial_filename;
320 gboolean open_dialog;
321 const char *tweak_current_folder;
322 const char *tweak_filename;
323 gint dialog_response;
324 gboolean unselect_all;
325 const char *final_current_folder;
326 const char *final_filename;
327 } FileChooserButtonTest;
330 make_button_test_name (FileChooserButtonTest *t)
332 return g_strdup_printf ("/GtkFileChooserButton/%s", t->shortname);
334 GString *s = g_string_new ("/GtkFileChooserButton");
336 g_string_append_printf (s, "/%s/%s/%s/%s",
337 get_action_name (t->action),
338 t->initial_current_folder ? "set_initial_folder" : "no_default_folder",
339 t->initial_filename ? "set_initial_filename" : "no_initial_filename",
340 t->open_dialog ? "open_dialog" : "no_dialog");
342 if (t->tweak_current_folder)
343 g_string_append (s, "/tweak_current_folder");
345 if (t->tweak_filename)
346 g_string_append (s, "/tweak_filename");
349 g_string_append_printf (s, "/%s",
350 t->dialog_response == GTK_RESPONSE_ACCEPT ? "accept" : "cancel");
352 if (t->final_current_folder)
353 g_string_append (s, "/final_current_folder");
355 if (t->final_filename)
356 g_string_append (s, "/final_filename");
358 return g_string_free (s, FALSE);
363 sleep_timeout_cb (gpointer data)
370 sleep_in_main_loop (void)
372 /* process all pending idles and events */
373 while (g_main_context_pending (NULL))
374 g_main_context_iteration (NULL, FALSE);
375 /* sleeping probably isn't strictly necessary here */
376 gdk_threads_add_timeout_full (G_MAXINT, 250, sleep_timeout_cb, NULL, NULL);
378 /* process any pending idles or events that arrived during sleep */
379 while (g_main_context_pending (NULL))
380 g_main_context_iteration (NULL, FALSE);
384 build_children_list (GtkWidget *widget, gpointer data)
389 *list = g_list_prepend (*list, widget);
393 find_child_widget_with_atk_role (GtkWidget *widget, AtkRole role)
395 AtkObject *accessible;
398 accessible = gtk_widget_get_accessible (widget);
399 a_role = atk_object_get_role (accessible);
405 GtkWidget *found_child;
409 if (GTK_IS_CONTAINER (widget))
415 gtk_container_forall (GTK_CONTAINER (widget), build_children_list, &children);
419 while (l && !found_child)
423 child = GTK_WIDGET (l->data);
425 found_child = find_child_widget_with_atk_role (child, role);
430 g_list_free (children);
438 get_atk_name_for_filechooser_button (GtkFileChooserButton *button)
440 GtkFileChooserAction action;
442 AtkObject *accessible;
444 action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (button));
445 g_assert (action == GTK_FILE_CHOOSER_ACTION_OPEN || action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
447 if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
448 widget = find_child_widget_with_atk_role (GTK_WIDGET (button), ATK_ROLE_PUSH_BUTTON);
450 widget = find_child_widget_with_atk_role (GTK_WIDGET (button), ATK_ROLE_COMBO_BOX);
452 accessible = gtk_widget_get_accessible (widget);
453 return atk_object_get_name (accessible);
457 check_that_basename_is_shown (GtkFileChooserButton *button, const char *expected_filename)
459 GtkFileChooserAction action;
460 const char *name_on_button;
461 char *expected_basename;
463 name_on_button = get_atk_name_for_filechooser_button (button);
465 action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (button));
466 g_assert (action == GTK_FILE_CHOOSER_ACTION_OPEN || action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
468 if (expected_filename)
469 expected_basename = g_path_get_basename (expected_filename);
471 expected_basename = NULL;
473 if (expected_basename)
474 g_assert_cmpstr (expected_basename, ==, name_on_button);
476 g_assert_cmpstr (name_on_button, ==, "(None)"); /* see gtkfilechooserbutton.c:FALLBACK_DISPLAY_NAME */ /* FIXME: how do we translate this? */
478 g_free (expected_basename);
482 get_expected_shown_filename (GtkFileChooserAction action, const char *folder_name, const char *filename)
484 if (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
496 get_file_chooser_dialog_from_button (GtkFileChooserButton *button)
498 GtkWidget *fc_dialog;
500 /* Give me the internal dialog, damnit */
501 fc_dialog = g_object_get_qdata (G_OBJECT (button), g_quark_from_static_string ("gtk-file-chooser-delegate"));
502 g_assert (GTK_IS_FILE_CHOOSER (fc_dialog));
503 g_assert (GTK_IS_DIALOG (fc_dialog));
510 GtkWidget *fc_button;
513 static WindowAndButton
514 create_window_and_file_chooser_button (GtkFileChooserAction action)
518 w.window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
520 w.fc_button = gtk_file_chooser_button_new (action == GTK_FILE_CHOOSER_ACTION_OPEN ? "Select a file" : "Select a folder",
522 gtk_container_add (GTK_CONTAINER (w.window), w.fc_button);
528 test_file_chooser_button (gconstpointer data)
530 const FileChooserButtonTest *setup = data;
532 GtkWidget *fc_dialog;
536 w = create_window_and_file_chooser_button (setup->action);
538 if (setup->initial_current_folder)
539 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (w.fc_button), setup->initial_current_folder);
541 if (setup->initial_filename)
542 gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (w.fc_button), setup->initial_filename);
544 gtk_widget_show_all (w.window);
545 sleep_in_main_loop ();
547 check_that_basename_is_shown (GTK_FILE_CHOOSER_BUTTON (w.fc_button),
548 get_expected_shown_filename (setup->action, setup->initial_current_folder, setup->initial_filename));
550 /* If there is a dialog to be opened, we actually test going through it a
551 * couple of times. This ensures that any state that the button frobs for
552 * each appearance of the dialog will make sense.
554 if (setup->open_dialog)
559 for (i = 0; i < iterations; i++)
561 if (setup->open_dialog)
565 /* Hack our way into the file chooser button; get its GtkButton child and click it */
566 children = gtk_container_get_children (GTK_CONTAINER (w.fc_button));
567 g_assert (children && GTK_IS_BUTTON (children->data));
568 gtk_button_clicked (GTK_BUTTON (children->data));
569 g_list_free (children);
571 sleep_in_main_loop ();
573 fc_dialog = get_file_chooser_dialog_from_button (GTK_FILE_CHOOSER_BUTTON (w.fc_button));
576 /* Okay, now frob the button and its optional dialog */
578 if (setup->tweak_current_folder)
579 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (w.fc_button), setup->tweak_current_folder);
581 if (setup->tweak_filename)
582 gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (w.fc_button), setup->tweak_filename);
584 if (setup->unselect_all)
585 gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (w.fc_button));
587 sleep_in_main_loop ();
589 if (setup->open_dialog)
591 gtk_dialog_response (GTK_DIALOG (fc_dialog), setup->dialog_response);
594 gtk_window_resize (GTK_WINDOW (fc_dialog), 500, 500);
597 if (setup->final_current_folder)
599 char *folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (w.fc_button));
601 g_assert_cmpstr (folder, ==, setup->final_current_folder);
605 if (setup->final_filename)
607 char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w.fc_button));
609 g_assert_cmpstr (filename, ==, setup->final_filename);
613 check_that_basename_is_shown (GTK_FILE_CHOOSER_BUTTON (w.fc_button),
614 get_expected_shown_filename (setup->action, setup->final_current_folder, setup->final_filename));
617 gtk_widget_destroy (w.window);
621 find_accessible_action_num (AtkObject *object, const char *action_name)
627 action_a = ATK_ACTION (object);
629 num_actions = atk_action_get_n_actions (action_a);
631 for (i = 0; i < num_actions; i++)
632 if (strcmp (atk_action_get_name (action_a, i), action_name) == 0)
639 do_accessible_action (AtkObject *object, const char *action_name)
643 action_num = find_accessible_action_num (object, action_name);
644 g_assert (action_num != -1);
646 atk_action_do_action (ATK_ACTION (object), action_num);
650 test_file_chooser_button_combo_box_1 (void)
653 GtkWidget *combo_box;
654 AtkObject *combo_box_a;
659 GtkWidget *fc_dialog;
661 w = create_window_and_file_chooser_button (GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
663 gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (w.fc_button), FOLDER_NAME);
665 gtk_widget_show_all (w.window);
667 /* Get the accessible for the combo box */
669 combo_box = find_child_widget_with_atk_role (GTK_WIDGET (w.fc_button), ATK_ROLE_COMBO_BOX);
670 combo_box_a = gtk_widget_get_accessible (combo_box);
672 /* Press the combo box to bring up the menu */
674 do_accessible_action (combo_box_a, "press");
675 sleep_in_main_loop (); /* have to wait because bringing up the menu is asynchronous... */
677 /* Get the menu from the combo box; it's the first child */
679 menu_a = atk_object_ref_accessible_child (combo_box_a, 0);
680 g_assert (atk_object_get_role (menu_a) == ATK_ROLE_MENU);
682 /* Check that the last item in the menu is the "Other…" one */
684 num_items = atk_object_get_n_accessible_children (menu_a);
685 g_assert (num_items > 0);
687 other_index = num_items - 1;
689 item_a = atk_object_ref_accessible_child (menu_a, other_index);
690 g_assert_cmpstr (atk_object_get_name (item_a), ==, "Other…"); /* FIXME: how do we translate this? */
692 /* Activate the item */
694 do_accessible_action (item_a, "click");
696 /* Cancel the dialog */
698 sleep_in_main_loop ();
699 fc_dialog = get_file_chooser_dialog_from_button (GTK_FILE_CHOOSER_BUTTON (w.fc_button));
701 gtk_dialog_response (GTK_DIALOG (fc_dialog), GTK_RESPONSE_CANCEL);
703 /* Now check the selection in the combo box */
704 check_that_basename_is_shown (GTK_FILE_CHOOSER_BUTTON (w.fc_button), FOLDER_NAME);
706 gtk_widget_destroy (w.window);
710 setup_file_chooser_button_combo_box_tests (void)
712 g_test_add_func ("/GtkFileChooserButton/combo_box-1", test_file_chooser_button_combo_box_1);
715 static FileChooserButtonTest button_tests[] =
717 /* OPEN tests without dialog */
721 GTK_FILE_CHOOSER_ACTION_OPEN,
722 NULL, /* initial_current_folder */
723 NULL, /* initial_filename */
724 FALSE, /* open_dialog */
725 NULL, /* tweak_current_folder */
726 NULL, /* tweak_filename */
727 0, /* dialog_response */
728 FALSE, /* unselect_all */
729 NULL, /* final_current_folder */
730 NULL /* final_filename */
734 GTK_FILE_CHOOSER_ACTION_OPEN,
735 NULL, /* initial_current_folder */
736 FILE_NAME, /* initial_filename */
737 FALSE, /* open_dialog */
738 NULL, /* tweak_current_folder */
739 NULL, /* tweak_filename */
740 0, /* dialog_response */
741 FALSE, /* unselect_all */
742 NULL, /* final_current_folder */
743 FILE_NAME /* final_filename */
747 GTK_FILE_CHOOSER_ACTION_OPEN,
748 NULL, /* initial_current_folder */
749 NULL, /* initial_filename */
750 FALSE, /* open_dialog */
751 NULL, /* tweak_current_folder */
752 FILE_NAME, /* tweak_filename */
753 0, /* dialog_response */
754 FALSE, /* unselect_all */
755 NULL, /* final_current_folder */
756 FILE_NAME /* final_filename */
760 GTK_FILE_CHOOSER_ACTION_OPEN,
761 NULL, /* initial_current_folder */
762 FILE_NAME, /* initial_filename */
763 FALSE, /* open_dialog */
764 NULL, /* tweak_current_folder */
765 FILE_NAME_2, /* tweak_filename */
766 0, /* dialog_response */
767 FALSE, /* unselect_all */
768 NULL, /* final_current_folder */
769 FILE_NAME_2 /* final_filename */
773 GTK_FILE_CHOOSER_ACTION_OPEN,
774 FOLDER_NAME, /* initial_current_folder */
775 NULL, /* initial_filename */
776 FALSE, /* open_dialog */
777 NULL, /* tweak_current_folder */
778 NULL, /* tweak_filename */
779 0, /* dialog_response */
780 FALSE, /* unselect_all */
781 FOLDER_NAME, /* final_current_folder */
782 NULL /* final_filename */
786 GTK_FILE_CHOOSER_ACTION_OPEN,
787 FOLDER_NAME, /* initial_current_folder */
788 NULL, /* initial_filename */
789 FALSE, /* open_dialog */
790 FOLDER_NAME_2, /* tweak_current_folder */
791 NULL, /* tweak_filename */
792 0, /* dialog_response */
793 FALSE, /* unselect_all */
794 FOLDER_NAME_2, /* final_current_folder */
795 NULL /* final_filename */
798 /* SELECT_FOLDER tests without dialog */
802 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
803 NULL, /* initial_current_folder */
804 NULL, /* initial_filename */
805 FALSE, /* open_dialog */
806 NULL, /* tweak_current_folder */
807 NULL, /* tweak_filename */
808 0, /* dialog_response */
809 FALSE, /* unselect_all */
810 NULL, /* final_current_folder */
811 NULL /* final_filename */
815 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
816 NULL, /* initial_current_folder */
817 FOLDER_NAME, /* initial_filename */
818 FALSE, /* open_dialog */
819 NULL, /* tweak_current_folder */
820 NULL, /* tweak_filename */
821 0, /* dialog_response */
822 FALSE, /* unselect_all */
823 NULL, /* final_current_folder */
824 FOLDER_NAME /* final_filename */
828 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
829 NULL, /* initial_current_folder */
830 FOLDER_NAME, /* initial_filename */
831 FALSE, /* open_dialog */
832 NULL, /* tweak_current_folder */
833 FOLDER_NAME_2, /* tweak_filename */
834 0, /* dialog_response */
835 FALSE, /* unselect_all */
836 NULL, /* final_current_folder */
837 FOLDER_NAME_2 /* final_filename */
841 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
842 FOLDER_NAME, /* initial_current_folder */
843 NULL, /* initial_filename */
844 FALSE, /* open_dialog */
845 NULL, /* tweak_current_folder */
846 NULL, /* tweak_filename */
847 0, /* dialog_response */
848 FALSE, /* unselect_all */
849 NULL, /* final_current_folder */
850 FOLDER_NAME /* final_filename */
854 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
855 FOLDER_NAME, /* initial_current_folder */
856 NULL, /* initial_filename */
857 FALSE, /* open_dialog */
858 NULL, /* tweak_current_folder */
859 NULL, /* tweak_filename */
860 0, /* dialog_response */
861 FALSE, /* unselect_all */
862 FOLDER_NAME, /* final_current_folder */
863 NULL /* final_filename */
867 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
868 FOLDER_NAME, /* initial_current_folder */
869 NULL, /* initial_filename */
870 FALSE, /* open_dialog */
871 FOLDER_NAME_2, /* tweak_current_folder */
872 NULL, /* tweak_filename */
873 0, /* dialog_response */
874 FALSE, /* unselect_all */
875 NULL, /* final_current_folder */
876 FOLDER_NAME_2 /* final_filename */
880 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
881 FOLDER_NAME, /* initial_current_folder */
882 NULL, /* initial_filename */
883 FALSE, /* open_dialog */
884 FOLDER_NAME_2, /* tweak_current_folder */
885 NULL, /* tweak_filename */
886 0, /* dialog_response */
887 FALSE, /* unselect_all */
888 FOLDER_NAME_2, /* final_current_folder */
889 NULL /* final_filename */
893 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
894 FOLDER_NAME, /* initial_current_folder */
895 NULL, /* initial_filename */
896 FALSE, /* open_dialog */
897 NULL, /* tweak_current_folder */
898 FOLDER_NAME_2, /* tweak_filename */
899 0, /* dialog_response */
900 FALSE, /* unselect_all */
901 NULL, /* final_current_folder */
902 FOLDER_NAME_2 /* final_filename */
905 /* OPEN tests with dialog, cancelled */
908 "open-dialog-cancel-1",
909 GTK_FILE_CHOOSER_ACTION_OPEN,
910 NULL, /* initial_current_folder */
911 NULL, /* initial_filename */
912 TRUE, /* open_dialog */
913 NULL, /* tweak_current_folder */
914 NULL, /* tweak_filename */
915 GTK_RESPONSE_CANCEL, /* dialog_response */
916 FALSE, /* unselect_all */
917 NULL, /* final_current_folder */
918 NULL /* final_filename */
921 "open-dialog-cancel-2",
922 GTK_FILE_CHOOSER_ACTION_OPEN,
923 NULL, /* initial_current_folder */
924 FILE_NAME, /* initial_filename */
925 TRUE, /* open_dialog */
926 NULL, /* tweak_current_folder */
927 NULL, /* tweak_filename */
928 GTK_RESPONSE_CANCEL, /* dialog_response */
929 FALSE, /* unselect_all */
930 NULL, /* final_current_folder */
931 FILE_NAME /* final_filename */
934 "open-dialog-cancel-3",
935 GTK_FILE_CHOOSER_ACTION_OPEN,
936 FOLDER_NAME, /* initial_current_folder */
937 NULL, /* initial_filename */
938 TRUE, /* open_dialog */
939 NULL, /* tweak_current_folder */
940 NULL, /* tweak_filename */
941 GTK_RESPONSE_CANCEL, /* dialog_response */
942 FALSE, /* unselect_all */
943 FOLDER_NAME, /* final_current_folder */
944 NULL /* final_filename */
947 "open-dialog-cancel-4",
948 GTK_FILE_CHOOSER_ACTION_OPEN,
949 NULL, /* initial_current_folder */
950 NULL, /* initial_filename */
951 TRUE, /* open_dialog */
952 NULL, /* tweak_current_folder */
953 FILE_NAME, /* tweak_filename */
954 GTK_RESPONSE_CANCEL, /* dialog_response */
955 FALSE, /* unselect_all */
956 NULL, /* final_current_folder */
957 NULL /* final_filename */
960 "open-dialog-cancel-5",
961 GTK_FILE_CHOOSER_ACTION_OPEN,
962 NULL, /* initial_current_folder */
963 FILE_NAME, /* initial_filename */
964 TRUE, /* open_dialog */
965 NULL, /* tweak_current_folder */
966 FILE_NAME_2, /* tweak_filename */
967 GTK_RESPONSE_CANCEL, /* dialog_response */
968 FALSE, /* unselect_all */
969 NULL, /* final_current_folder */
970 FILE_NAME /* final_filename */
973 "open-dialog-cancel-6",
974 GTK_FILE_CHOOSER_ACTION_OPEN,
975 FOLDER_NAME, /* initial_current_folder */
976 NULL, /* initial_filename */
977 TRUE, /* open_dialog */
978 NULL, /* tweak_current_folder */
979 FILE_NAME_2, /* tweak_filename */
980 GTK_RESPONSE_CANCEL, /* dialog_response */
981 FALSE, /* unselect_all */
982 FOLDER_NAME, /* final_current_folder */
983 NULL /* final_filename */
986 /* OPEN tests with dialog, cancelled via closing the dialog (not by selecting the Cancel button) */
989 "open-dialog-close-1",
990 GTK_FILE_CHOOSER_ACTION_OPEN,
991 NULL, /* initial_current_folder */
992 NULL, /* initial_filename */
993 TRUE, /* open_dialog */
994 NULL, /* tweak_current_folder */
995 NULL, /* tweak_filename */
996 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
997 FALSE, /* unselect_all */
998 NULL, /* final_current_folder */
999 NULL /* final_filename */
1002 "open-dialog-close-2",
1003 GTK_FILE_CHOOSER_ACTION_OPEN,
1004 NULL, /* initial_current_folder */
1005 FILE_NAME, /* initial_filename */
1006 TRUE, /* open_dialog */
1007 NULL, /* tweak_current_folder */
1008 NULL, /* tweak_filename */
1009 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1010 FALSE, /* unselect_all */
1011 NULL, /* final_current_folder */
1012 FILE_NAME /* final_filename */
1015 "open-dialog-close-3",
1016 GTK_FILE_CHOOSER_ACTION_OPEN,
1017 FOLDER_NAME, /* initial_current_folder */
1018 NULL, /* initial_filename */
1019 TRUE, /* open_dialog */
1020 NULL, /* tweak_current_folder */
1021 NULL, /* tweak_filename */
1022 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1023 FALSE, /* unselect_all */
1024 FOLDER_NAME, /* final_current_folder */
1025 NULL /* final_filename */
1028 "open-dialog-close-4",
1029 GTK_FILE_CHOOSER_ACTION_OPEN,
1030 NULL, /* initial_current_folder */
1031 NULL, /* initial_filename */
1032 TRUE, /* open_dialog */
1033 NULL, /* tweak_current_folder */
1034 FILE_NAME, /* tweak_filename */
1035 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1036 FALSE, /* unselect_all */
1037 NULL, /* final_current_folder */
1038 NULL /* final_filename */
1041 "open-dialog-close-5",
1042 GTK_FILE_CHOOSER_ACTION_OPEN,
1043 NULL, /* initial_current_folder */
1044 FILE_NAME, /* initial_filename */
1045 TRUE, /* open_dialog */
1046 NULL, /* tweak_current_folder */
1047 FILE_NAME_2, /* tweak_filename */
1048 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1049 FALSE, /* unselect_all */
1050 NULL, /* final_current_folder */
1051 FILE_NAME /* final_filename */
1054 "open-dialog-close-6",
1055 GTK_FILE_CHOOSER_ACTION_OPEN,
1056 FOLDER_NAME, /* initial_current_folder */
1057 NULL, /* initial_filename */
1058 TRUE, /* open_dialog */
1059 NULL, /* tweak_current_folder */
1060 FILE_NAME_2, /* tweak_filename */
1061 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1062 FALSE, /* unselect_all */
1063 FOLDER_NAME, /* final_current_folder */
1064 NULL /* final_filename */
1067 /* SELECT_FOLDER tests with dialog, cancelled */
1070 "select-folder-dialog-cancel-1",
1071 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1072 NULL, /* initial_current_folder */
1073 NULL, /* initial_filename */
1074 TRUE, /* open_dialog */
1075 NULL, /* tweak_current_folder */
1076 NULL, /* tweak_filename */
1077 GTK_RESPONSE_CANCEL, /* dialog_response */
1078 FALSE, /* unselect_all */
1079 NULL, /* final_current_folder */
1080 NULL /* final_filename */
1083 "select-folder-dialog-cancel-2",
1084 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1085 NULL, /* initial_current_folder */
1086 FOLDER_NAME, /* initial_filename */
1087 TRUE, /* open_dialog */
1088 NULL, /* tweak_current_folder */
1089 NULL, /* tweak_filename */
1090 GTK_RESPONSE_CANCEL, /* dialog_response */
1091 FALSE, /* unselect_all */
1092 NULL, /* final_current_folder */
1093 FOLDER_NAME /* final_filename */
1096 "select-folder-dialog-cancel-3",
1097 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1098 FOLDER_NAME, /* initial_current_folder */
1099 NULL, /* initial_filename */
1100 TRUE, /* open_dialog */
1101 NULL, /* tweak_current_folder */
1102 NULL, /* tweak_filename */
1103 GTK_RESPONSE_CANCEL, /* dialog_response */
1104 FALSE, /* unselect_all */
1105 FOLDER_NAME, /* final_current_folder */
1106 NULL /* final_filename */
1109 "select-folder-dialog-cancel-4",
1110 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1111 FOLDER_NAME, /* initial_current_folder */
1112 NULL, /* initial_filename */
1113 TRUE, /* open_dialog */
1114 NULL, /* tweak_current_folder */
1115 NULL, /* tweak_filename */
1116 GTK_RESPONSE_CANCEL, /* dialog_response */
1117 FALSE, /* unselect_all */
1118 NULL, /* final_current_folder */
1119 FOLDER_NAME /* final_filename */
1122 "select-folder-dialog-cancel-5",
1123 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1124 NULL, /* initial_current_folder */
1125 NULL, /* initial_filename */
1126 TRUE, /* open_dialog */
1127 NULL, /* tweak_current_folder */
1128 FOLDER_NAME, /* tweak_filename */
1129 GTK_RESPONSE_CANCEL, /* dialog_response */
1130 FALSE, /* unselect_all */
1131 NULL, /* final_current_folder */
1132 NULL /* final_filename */
1135 "select-folder-dialog-cancel-6",
1136 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1137 NULL, /* initial_current_folder */
1138 FOLDER_NAME, /* initial_filename */
1139 TRUE, /* open_dialog */
1140 NULL, /* tweak_current_folder */
1141 FOLDER_NAME_2, /* tweak_filename */
1142 GTK_RESPONSE_CANCEL, /* dialog_response */
1143 FALSE, /* unselect_all */
1144 NULL, /* final_current_folder */
1145 FOLDER_NAME /* final_filename */
1148 "select-folder-dialog-cancel-7",
1149 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1150 FOLDER_NAME, /* initial_current_folder */
1151 NULL, /* initial_filename */
1152 TRUE, /* open_dialog */
1153 NULL, /* tweak_current_folder */
1154 FOLDER_NAME_2, /* tweak_filename */
1155 GTK_RESPONSE_CANCEL, /* dialog_response */
1156 FALSE, /* unselect_all */
1157 FOLDER_NAME, /* final_current_folder */
1158 NULL /* final_filename */
1161 "select-folder-dialog-cancel-8",
1162 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1163 FOLDER_NAME, /* initial_current_folder */
1164 NULL, /* initial_filename */
1165 TRUE, /* open_dialog */
1166 NULL, /* tweak_current_folder */
1167 FOLDER_NAME_2, /* tweak_filename */
1168 GTK_RESPONSE_CANCEL, /* dialog_response */
1169 FALSE, /* unselect_all */
1170 NULL, /* final_current_folder */
1171 FOLDER_NAME /* final_filename */
1174 /* SELECT_FOLDER tests with dialog, cancelled via closing the dialog (not selecting the Cancel button) */
1177 "select-folder-dialog-close-1",
1178 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1179 NULL, /* initial_current_folder */
1180 NULL, /* initial_filename */
1181 TRUE, /* open_dialog */
1182 NULL, /* tweak_current_folder */
1183 NULL, /* tweak_filename */
1184 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1185 FALSE, /* unselect_all */
1186 NULL, /* final_current_folder */
1187 NULL /* final_filename */
1190 "select-folder-dialog-close-2",
1191 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1192 NULL, /* initial_current_folder */
1193 FOLDER_NAME, /* initial_filename */
1194 TRUE, /* open_dialog */
1195 NULL, /* tweak_current_folder */
1196 NULL, /* tweak_filename */
1197 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1198 FALSE, /* unselect_all */
1199 NULL, /* final_current_folder */
1200 FOLDER_NAME /* final_filename */
1203 "select-folder-dialog-close-3",
1204 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1205 FOLDER_NAME, /* initial_current_folder */
1206 NULL, /* initial_filename */
1207 TRUE, /* open_dialog */
1208 NULL, /* tweak_current_folder */
1209 NULL, /* tweak_filename */
1210 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1211 FALSE, /* unselect_all */
1212 FOLDER_NAME, /* final_current_folder */
1213 NULL /* final_filename */
1216 "select-folder-dialog-close-4",
1217 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1218 FOLDER_NAME, /* initial_current_folder */
1219 NULL, /* initial_filename */
1220 TRUE, /* open_dialog */
1221 NULL, /* tweak_current_folder */
1222 NULL, /* tweak_filename */
1223 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1224 FALSE, /* unselect_all */
1225 NULL, /* final_current_folder */
1226 FOLDER_NAME /* final_filename */
1229 "select-folder-dialog-close-5",
1230 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1231 NULL, /* initial_current_folder */
1232 NULL, /* initial_filename */
1233 TRUE, /* open_dialog */
1234 NULL, /* tweak_current_folder */
1235 FOLDER_NAME, /* tweak_filename */
1236 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1237 FALSE, /* unselect_all */
1238 NULL, /* final_current_folder */
1239 NULL /* final_filename */
1242 "select-folder-dialog-close-6",
1243 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1244 NULL, /* initial_current_folder */
1245 FOLDER_NAME, /* initial_filename */
1246 TRUE, /* open_dialog */
1247 NULL, /* tweak_current_folder */
1248 FOLDER_NAME_2, /* tweak_filename */
1249 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1250 FALSE, /* unselect_all */
1251 NULL, /* final_current_folder */
1252 FOLDER_NAME /* final_filename */
1255 "select-folder-dialog-close-7",
1256 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1257 FOLDER_NAME, /* initial_current_folder */
1258 NULL, /* initial_filename */
1259 TRUE, /* open_dialog */
1260 NULL, /* tweak_current_folder */
1261 FOLDER_NAME_2, /* tweak_filename */
1262 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1263 FALSE, /* unselect_all */
1264 FOLDER_NAME, /* final_current_folder */
1265 NULL /* final_filename */
1268 "select-folder-dialog-close-8",
1269 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1270 FOLDER_NAME, /* initial_current_folder */
1271 NULL, /* initial_filename */
1272 TRUE, /* open_dialog */
1273 NULL, /* tweak_current_folder */
1274 FOLDER_NAME_2, /* tweak_filename */
1275 GTK_RESPONSE_DELETE_EVENT,/* dialog_response */
1276 FALSE, /* unselect_all */
1277 NULL, /* final_current_folder */
1278 FOLDER_NAME /* final_filename */
1281 /* OPEN tests with dialog */
1285 GTK_FILE_CHOOSER_ACTION_OPEN,
1286 NULL, /* initial_current_folder */
1287 NULL, /* initial_filename */
1288 TRUE, /* open_dialog */
1289 NULL, /* tweak_current_folder */
1290 FILE_NAME, /* tweak_filename */
1291 GTK_RESPONSE_ACCEPT, /* dialog_response */
1292 FALSE, /* unselect_all */
1293 NULL, /* final_current_folder */
1294 FILE_NAME /* final_filename */
1298 GTK_FILE_CHOOSER_ACTION_OPEN,
1299 NULL, /* initial_current_folder */
1300 FILE_NAME, /* initial_filename */
1301 TRUE, /* open_dialog */
1302 NULL, /* tweak_current_folder */
1303 NULL, /* tweak_filename */
1304 GTK_RESPONSE_ACCEPT, /* dialog_response */
1305 FALSE, /* unselect_all */
1306 NULL, /* final_current_folder */
1307 FILE_NAME /* final_filename */
1311 GTK_FILE_CHOOSER_ACTION_OPEN,
1312 NULL, /* initial_current_folder */
1313 FILE_NAME, /* initial_filename */
1314 TRUE, /* open_dialog */
1315 NULL, /* tweak_current_folder */
1316 FILE_NAME_2, /* tweak_filename */
1317 GTK_RESPONSE_ACCEPT, /* dialog_response */
1318 FALSE, /* unselect_all */
1319 NULL, /* final_current_folder */
1320 FILE_NAME_2 /* final_filename */
1324 GTK_FILE_CHOOSER_ACTION_OPEN,
1325 FOLDER_NAME, /* initial_current_folder */
1326 NULL, /* initial_filename */
1327 TRUE, /* open_dialog */
1328 NULL, /* tweak_current_folder */
1329 FILE_NAME, /* tweak_filename */
1330 GTK_RESPONSE_ACCEPT, /* dialog_response */
1331 FALSE, /* unselect_all */
1332 NULL, /* final_current_folder */
1333 FILE_NAME /* final_filename */
1336 /* SELECT_FOLDER tests with dialog */
1339 "select-folder-dialog-1",
1340 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1341 NULL, /* initial_current_folder */
1342 FOLDER_NAME, /* initial_filename */
1343 TRUE, /* open_dialog */
1344 NULL, /* tweak_current_folder */
1345 NULL, /* tweak_filename */
1346 GTK_RESPONSE_ACCEPT, /* dialog_response */
1347 FALSE, /* unselect_all */
1348 NULL, /* final_current_folder */
1349 FOLDER_NAME /* final_filename */
1352 "select-folder-dialog-2",
1353 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1354 FOLDER_NAME, /* initial_current_folder */
1355 NULL, /* initial_filename */
1356 TRUE, /* open_dialog */
1357 NULL, /* tweak_current_folder */
1358 NULL, /* tweak_filename */
1359 GTK_RESPONSE_ACCEPT, /* dialog_response */
1360 FALSE, /* unselect_all */
1361 NULL, /* final_current_folder */
1362 FOLDER_NAME /* final_filename */
1365 "select-folder-dialog-3",
1366 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1367 NULL, /* initial_current_folder */
1368 FOLDER_NAME, /* initial_filename */
1369 TRUE, /* open_dialog */
1370 NULL, /* tweak_current_folder */
1371 FOLDER_NAME_2, /* tweak_filename */
1372 GTK_RESPONSE_ACCEPT, /* dialog_response */
1373 FALSE, /* unselect_all */
1374 NULL, /* final_current_folder */
1375 FOLDER_NAME_2 /* final_filename */
1378 "select-folder-dialog-4",
1379 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1380 FOLDER_NAME, /* initial_current_folder */
1381 NULL, /* initial_filename */
1382 TRUE, /* open_dialog */
1383 NULL, /* tweak_current_folder */
1384 FOLDER_NAME_2, /* tweak_filename */
1385 GTK_RESPONSE_ACCEPT, /* dialog_response */
1386 FALSE, /* unselect_all */
1387 NULL, /* final_current_folder */
1388 FOLDER_NAME_2 /* final_filename */
1391 /* Unselection tests */
1394 GTK_FILE_CHOOSER_ACTION_OPEN,
1395 NULL, /* initial_current_folder */
1396 NULL, /* initial_filename */
1397 FALSE, /* open_dialog */
1398 NULL, /* tweak_current_folder */
1399 NULL, /* tweak_filename */
1400 0, /* dialog_response */
1401 TRUE, /* unselect_all */
1402 NULL, /* final_current_folder */
1403 NULL /* final_filename */
1407 GTK_FILE_CHOOSER_ACTION_OPEN,
1408 NULL, /* initial_current_folder */
1409 FILE_NAME, /* initial_filename */
1410 FALSE, /* open_dialog */
1411 NULL, /* tweak_current_folder */
1412 NULL, /* tweak_filename */
1413 0, /* dialog_response */
1414 TRUE, /* unselect_all */
1415 NULL, /* final_current_folder */
1416 NULL /* final_filename */
1420 GTK_FILE_CHOOSER_ACTION_OPEN,
1421 NULL, /* initial_current_folder */
1422 FILE_NAME, /* initial_filename */
1423 FALSE, /* open_dialog */
1424 NULL, /* tweak_current_folder */
1425 FILE_NAME_2, /* tweak_filename */
1426 0, /* dialog_response */
1427 TRUE, /* unselect_all */
1428 NULL, /* final_current_folder */
1429 NULL /* final_filename */
1433 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1434 NULL, /* initial_current_folder */
1435 NULL, /* initial_filename */
1436 FALSE, /* open_dialog */
1437 NULL, /* tweak_current_folder */
1438 NULL, /* tweak_filename */
1439 0, /* dialog_response */
1440 TRUE, /* unselect_all */
1441 NULL, /* final_current_folder */
1442 NULL /* final_filename */
1446 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1447 NULL, /* initial_current_folder */
1448 FOLDER_NAME, /* initial_filename */
1449 FALSE, /* open_dialog */
1450 NULL, /* tweak_current_folder */
1451 NULL, /* tweak_filename */
1452 0, /* dialog_response */
1453 TRUE, /* unselect_all */
1454 NULL, /* final_current_folder */
1455 NULL /* final_filename */
1459 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1460 NULL, /* initial_current_folder */
1461 FOLDER_NAME, /* initial_filename */
1462 FALSE, /* open_dialog */
1463 NULL, /* tweak_current_folder */
1464 FOLDER_NAME_2, /* tweak_filename */
1465 0, /* dialog_response */
1466 TRUE, /* unselect_all */
1467 NULL, /* final_current_folder */
1468 NULL /* final_filename */
1474 setup_file_chooser_button_tests (void)
1478 for (i = 0; i < G_N_ELEMENTS (button_tests); i++)
1482 test_name = make_button_test_name (&button_tests[i]);
1483 g_test_add_data_func (test_name, &button_tests[i], test_file_chooser_button);
1487 setup_file_chooser_button_combo_box_tests ();
1491 struct confirm_overwrite_closure {
1493 GtkWidget *accept_button;
1494 gint confirm_overwrite_signal_emitted;
1498 static GtkFileChooserConfirmation
1499 confirm_overwrite_cb (GtkFileChooser *chooser, gpointer data)
1501 struct confirm_overwrite_closure *closure = data;
1503 if (g_test_verbose())
1504 printf ("bling!\n");
1505 closure->confirm_overwrite_signal_emitted += 1;
1507 return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
1511 overwrite_response_cb (GtkFileChooser *chooser, gint response, gpointer data)
1513 struct confirm_overwrite_closure *closure = data;
1516 if (g_test_verbose())
1517 printf ("plong!\n");
1519 if (response != GTK_RESPONSE_ACCEPT)
1522 filename = gtk_file_chooser_get_filename (chooser);
1524 if (!g_str_has_suffix (filename, closure->extension))
1528 basename = g_path_get_basename (filename);
1531 filename = g_strconcat (basename, closure->extension, NULL);
1532 gtk_file_chooser_set_current_name (chooser, filename);
1534 g_signal_stop_emission_by_name (chooser, "response");
1535 gtk_dialog_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
1540 confirm_overwrite_timeout_cb (gpointer data)
1542 struct confirm_overwrite_closure *closure;
1545 gtk_button_clicked (GTK_BUTTON (closure->accept_button));
1550 /* http://bugzilla.gnome.org/show_bug.cgi?id=347883 */
1552 test_confirm_overwrite_for_path (const char *path, gboolean append_extension)
1555 struct confirm_overwrite_closure closure;
1560 closure.extension = NULL;
1561 closure.confirm_overwrite_signal_emitted = 0;
1562 closure.chooser = gtk_file_chooser_dialog_new ("hello", NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
1563 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1565 closure.accept_button = gtk_dialog_add_button (GTK_DIALOG (closure.chooser),
1566 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT);
1567 gtk_dialog_set_default_response (GTK_DIALOG (closure.chooser), GTK_RESPONSE_ACCEPT);
1569 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (closure.chooser), TRUE);
1571 g_signal_connect (closure.chooser, "confirm-overwrite",
1572 G_CALLBACK (confirm_overwrite_cb), &closure);
1574 if (append_extension)
1578 filename = g_path_get_dirname (path);
1579 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (closure.chooser), filename);
1582 filename = g_path_get_basename (path);
1583 extension = strchr (filename, '.');
1587 closure.extension = g_strdup (extension);
1591 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (closure.chooser), filename);
1594 g_signal_connect (closure.chooser, "response",
1595 G_CALLBACK (overwrite_response_cb), &closure);
1599 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (closure.chooser), path);
1602 gdk_threads_add_timeout_full (G_MAXINT, SLEEP_DURATION, confirm_overwrite_timeout_cb, &closure, NULL);
1603 gtk_dialog_run (GTK_DIALOG (closure.chooser));
1605 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (closure.chooser));
1606 passed = passed && filename && (strcmp (filename, path) == 0);
1609 gtk_widget_destroy (closure.chooser);
1611 passed = passed && (1 == closure.confirm_overwrite_signal_emitted);
1613 log_test (passed, "Confirm overwrite for %s", path);
1619 test_confirm_overwrite (void)
1621 gboolean passed = TRUE;
1623 /* first test for a file we know will always exist */
1624 passed = passed && test_confirm_overwrite_for_path ("/etc/passwd", FALSE);
1626 passed = passed && test_confirm_overwrite_for_path ("/etc/resolv.conf", TRUE);
1631 static const GtkFileChooserAction open_actions[] = {
1632 GTK_FILE_CHOOSER_ACTION_OPEN,
1633 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
1636 static const GtkFileChooserAction save_actions[] = {
1637 GTK_FILE_CHOOSER_ACTION_SAVE,
1638 GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
1644 has_action (const GtkFileChooserAction *actions,
1646 GtkFileChooserAction sought_action)
1650 for (i = 0; i < n_actions; i++)
1651 if (actions[i] == sought_action)
1657 static GtkFileChooserDefault *
1658 get_impl_from_dialog (GtkWidget *dialog)
1660 GtkFileChooserDialog *d;
1661 GtkFileChooserDialogPrivate *dialog_priv;
1662 GtkFileChooserWidget *chooser_widget;
1663 GtkFileChooserWidgetPrivate *widget_priv;
1664 GtkFileChooserDefault *impl;
1666 d = GTK_FILE_CHOOSER_DIALOG (dialog);
1667 dialog_priv = d->priv;
1668 chooser_widget = GTK_FILE_CHOOSER_WIDGET (dialog_priv->widget);
1669 if (!chooser_widget)
1670 g_error ("BUG: dialog_priv->widget is not a GtkFileChooserWidget");
1672 widget_priv = chooser_widget->priv;
1673 impl = (GtkFileChooserDefault *) (widget_priv->impl);
1675 g_error ("BUG: widget_priv->impl is not a GtkFileChooserDefault");
1681 test_widgets_for_current_action (GtkFileChooserDialog *dialog,
1682 GtkFileChooserAction expected_action)
1684 GtkFileChooserDefault *impl;
1687 if (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) != expected_action)
1690 impl = get_impl_from_dialog (GTK_WIDGET (dialog));
1692 g_assert (impl->action == expected_action);
1696 /* OPEN implies that the "new folder" button is hidden; otherwise it is shown */
1697 if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
1698 passed = passed && !gtk_widget_get_visible (impl->browse_new_folder_button);
1700 passed = passed && gtk_widget_get_visible (impl->browse_new_folder_button);
1702 /* Check that the widgets are present/visible or not */
1703 if (has_action (open_actions, G_N_ELEMENTS (open_actions), impl->action))
1705 passed = passed && (impl->save_widgets == NULL
1706 && (impl->location_mode == LOCATION_MODE_PATH_BAR
1707 ? impl->location_entry == NULL
1708 : impl->location_entry != NULL)
1709 && impl->save_folder_label == NULL
1710 && impl->save_folder_combo == NULL
1711 && impl->save_expander == NULL
1712 && GTK_IS_CONTAINER (impl->browse_widgets) && gtk_widget_is_drawable (impl->browse_widgets));
1714 else if (has_action (save_actions, G_N_ELEMENTS (save_actions), impl->action))
1716 /* FIXME: we can't use GTK_IS_FILE_CHOOSER_ENTRY() because it uses
1717 * _gtk_file_chooser_entry_get_type(), which is a non-exported symbol.
1718 * So, we just test impl->location_entry for being non-NULL
1720 passed = passed && (GTK_IS_CONTAINER (impl->save_widgets) && gtk_widget_is_drawable (impl->save_widgets)
1721 && impl->location_entry != NULL && gtk_widget_is_drawable (impl->location_entry)
1722 && GTK_IS_LABEL (impl->save_folder_label) && gtk_widget_is_drawable (impl->save_folder_label)
1723 && GTK_IS_COMBO_BOX (impl->save_folder_combo) && gtk_widget_is_drawable (impl->save_folder_combo)
1724 && GTK_IS_EXPANDER (impl->save_expander) && gtk_widget_is_drawable (impl->save_expander)
1725 && GTK_IS_CONTAINER (impl->browse_widgets));
1727 /* FIXME: we are in a SAVE mode; test the visibility and sensitivity of
1728 * the children that change depending on the state of the expander.
1733 g_error ("BAD TEST: test_widgets_for_current_action() doesn't know about %s", get_action_name (impl->action));
1740 typedef gboolean (* ForeachActionCallback) (GtkFileChooserDialog *dialog,
1741 GtkFileChooserAction action,
1742 gpointer user_data);
1745 foreach_action (GtkFileChooserDialog *dialog,
1746 ForeachActionCallback callback,
1749 GEnumClass *enum_class;
1752 enum_class = g_type_class_peek (GTK_TYPE_FILE_CHOOSER_ACTION);
1754 g_error ("BUG: get_action_name(): no GEnumClass for GTK_TYPE_FILE_CHOOSER_ACTION");
1756 for (i = 0; i < enum_class->n_values; i++)
1758 GEnumValue *enum_value;
1759 GtkFileChooserAction action;
1762 enum_value = enum_class->values + i;
1763 action = enum_value->value;
1765 passed = (* callback) (dialog, action, user_data);
1773 struct action_closure {
1774 GtkFileChooserAction from_action;
1778 switch_from_to_action_cb (GtkFileChooserDialog *dialog,
1779 GtkFileChooserAction action,
1782 struct action_closure *closure;
1785 closure = user_data;
1787 gtk_file_chooser_set_action (GTK_FILE_CHOOSER (dialog), closure->from_action);
1789 passed = test_widgets_for_current_action (dialog, closure->from_action);
1790 log_test (passed, "switch_from_to_action_cb(): reset to action %s", get_action_name (closure->from_action));
1794 gtk_file_chooser_set_action (GTK_FILE_CHOOSER (dialog), action);
1796 passed = test_widgets_for_current_action (dialog, action);
1797 log_test (passed, "switch_from_to_action_cb(): transition from %s to %s",
1798 get_action_name (closure->from_action),
1799 get_action_name (action));
1804 switch_from_action_cb (GtkFileChooserDialog *dialog,
1805 GtkFileChooserAction action,
1808 struct action_closure closure;
1810 closure.from_action = action;
1812 return foreach_action (dialog, switch_from_to_action_cb, &closure);
1816 test_action_widgets (void)
1819 GtkFileChooserAction action;
1822 dialog = gtk_file_chooser_dialog_new ("Test file chooser",
1824 GTK_FILE_CHOOSER_ACTION_OPEN,
1826 GTK_RESPONSE_CANCEL,
1828 GTK_RESPONSE_ACCEPT,
1830 gtk_widget_show_now (dialog);
1832 action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog));
1834 passed = test_widgets_for_current_action (GTK_FILE_CHOOSER_DIALOG (dialog), action);
1835 log_test (passed, "test_action_widgets(): widgets for initial action %s", get_action_name (action));
1838 passed = foreach_action (GTK_FILE_CHOOSER_DIALOG (dialog), switch_from_action_cb, NULL);
1839 log_test (passed, "test_action_widgets(): all transitions through property change");
1842 gtk_widget_destroy (dialog);
1848 test_reload_sequence (gboolean set_folder_before_map)
1851 GtkFileChooserDefault *impl;
1854 char *current_working_dir;
1858 current_working_dir = g_get_current_dir ();
1860 dialog = gtk_file_chooser_dialog_new ("Test file chooser",
1862 GTK_FILE_CHOOSER_ACTION_OPEN,
1864 GTK_RESPONSE_CANCEL,
1866 GTK_RESPONSE_ACCEPT,
1868 impl = get_impl_from_dialog (dialog);
1870 if (set_folder_before_map)
1872 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), g_get_home_dir ());
1876 passed = passed && (impl->current_folder != NULL
1877 && impl->browse_files_model != NULL
1878 && (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1879 && impl->reload_state == RELOAD_HAS_FOLDER
1880 && (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
1881 && ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1882 ? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
1887 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
1888 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
1893 /* Initially, no folder is not loaded or pending */
1894 passed = passed && (impl->current_folder == NULL
1895 && impl->sort_model == NULL
1896 && impl->browse_files_model == NULL
1897 && impl->load_state == LOAD_EMPTY
1898 && impl->reload_state == RELOAD_EMPTY
1899 && impl->load_timeout_id == 0);
1903 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
1904 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
1907 log_test (passed, "test_reload_sequence(): initial status");
1909 /* After mapping, it is loading some folder, either the one that was explicitly set or the default one */
1911 gtk_widget_show_now (dialog);
1915 passed = passed && (impl->current_folder != NULL
1916 && impl->browse_files_model != NULL
1917 && (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1918 && impl->reload_state == RELOAD_HAS_FOLDER
1919 && (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
1920 && ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1921 ? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
1924 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
1925 if (set_folder_before_map)
1926 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
1928 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
1932 log_test (passed, "test_reload_sequence(): status after map");
1934 /* Unmap it; we should still have a folder */
1936 gtk_widget_hide (dialog);
1940 passed = passed && (impl->current_folder != NULL
1941 && impl->browse_files_model != NULL
1942 && (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1943 && (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
1944 && ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1945 ? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
1948 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
1949 if (set_folder_before_map)
1950 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
1952 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
1956 log_test (passed, "test_reload_sequence(): status after unmap");
1960 gtk_widget_show_now (dialog);
1964 passed = passed && (impl->current_folder != NULL
1965 && impl->browse_files_model != NULL
1966 && (impl->load_state == LOAD_PRELOAD || impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1967 && impl->reload_state == RELOAD_HAS_FOLDER
1968 && (impl->load_state == LOAD_PRELOAD ? (impl->load_timeout_id != 0) : TRUE)
1969 && ((impl->load_state == LOAD_LOADING || impl->load_state == LOAD_FINISHED)
1970 ? (impl->load_timeout_id == 0 && impl->sort_model != NULL)
1973 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
1974 if (set_folder_before_map)
1975 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
1977 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
1981 log_test (passed, "test_reload_sequence(): status after re-map");
1983 gtk_widget_destroy (dialog);
1984 g_free (current_working_dir);
1994 passed = test_reload_sequence (FALSE);
1995 log_test (passed, "test_reload(): create and use the default folder");
1998 passed = test_reload_sequence (TRUE);
1999 log_test (passed, "test_reload(): set a folder explicitly before mapping");
2004 test_button_folder_states_for_action (GtkFileChooserAction action, gboolean use_dialog, gboolean set_folder_on_dialog)
2011 char *current_working_dir;
2012 gboolean must_have_cwd;
2016 current_working_dir = g_get_current_dir ();
2017 must_have_cwd = !(use_dialog && set_folder_on_dialog);
2019 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2023 dialog = gtk_file_chooser_dialog_new ("Test", NULL, action,
2024 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
2025 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
2027 button = gtk_file_chooser_button_new_with_dialog (dialog);
2029 if (set_folder_on_dialog)
2030 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), g_get_home_dir ());
2034 button = gtk_file_chooser_button_new ("Test", action);
2035 dialog = NULL; /* keep gcc happy */
2038 gtk_container_add (GTK_CONTAINER (window), button);
2040 /* Pre-map; no folder is set */
2043 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));
2045 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
2047 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
2049 log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, pre-map, %s",
2050 get_action_name (action),
2052 set_folder_on_dialog,
2053 must_have_cwd ? "must have $cwd" : "must have explicit folder");
2055 /* Map; folder should be set */
2057 gtk_widget_show_all (window);
2058 gtk_widget_show_now (window);
2062 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));
2065 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
2067 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
2069 log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, mapped, %s",
2070 get_action_name (action),
2072 set_folder_on_dialog,
2073 must_have_cwd ? "must have $cwd" : "must have explicit folder");
2076 /* Unmap; folder should be set */
2078 gtk_widget_hide (window);
2080 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));
2083 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
2085 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
2087 log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, unmapped, %s",
2088 get_action_name (action),
2090 set_folder_on_dialog,
2091 must_have_cwd ? "must have $cwd" : "must have explicit folder");
2094 /* Re-map; folder should be set */
2096 gtk_widget_show_now (window);
2097 folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));
2100 passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
2102 passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
2104 log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, re-mapped, %s",
2105 get_action_name (action),
2107 set_folder_on_dialog,
2108 must_have_cwd ? "must have $cwd" : "must have explicit folder");
2111 g_free (current_working_dir);
2113 gtk_widget_destroy (window);
2119 test_button_folder_states (void)
2121 /* GtkFileChooserButton only supports OPEN and SELECT_FOLDER */
2122 static const GtkFileChooserAction actions_to_test[] = {
2123 GTK_FILE_CHOOSER_ACTION_OPEN,
2124 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
2131 for (i = 0; i < G_N_ELEMENTS (actions_to_test); i++)
2133 passed = passed && test_button_folder_states_for_action (actions_to_test[i], FALSE, FALSE);
2135 passed = passed && test_button_folder_states_for_action (actions_to_test[i], TRUE, FALSE);
2137 passed = passed && test_button_folder_states_for_action (actions_to_test[i], TRUE, TRUE);
2139 log_test (passed, "test_button_folder_states(): action %s", get_action_name (actions_to_test[i]));
2142 log_test (passed, "test_button_folder_states(): all supported actions");
2146 test_folder_switch_and_filters (void)
2152 GFile *base_dir_file;
2154 GtkFileFilter *all_filter;
2155 GtkFileFilter *txt_filter;
2156 GtkFileChooserDefault *impl;
2160 cwd = g_get_current_dir ();
2161 base_dir = g_build_filename (cwd, "file-chooser-test-dir", NULL);
2163 dialog = gtk_file_chooser_dialog_new ("Test", NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
2164 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
2165 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
2167 impl = get_impl_from_dialog (dialog);
2169 cwd_file = g_file_new_for_path (cwd);
2170 base_dir_file = g_file_new_for_path (base_dir);
2172 passed = passed && gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), base_dir);
2175 /* All files filter */
2177 all_filter = gtk_file_filter_new ();
2178 gtk_file_filter_set_name (all_filter, "All files");
2179 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), all_filter);
2183 txt_filter = gtk_file_filter_new ();
2184 gtk_file_filter_set_name (all_filter, "*.txt");
2185 gtk_file_filter_add_pattern (txt_filter, "*.txt");
2186 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), txt_filter);
2188 /* Test filter set */
2190 gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), all_filter);
2191 passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == all_filter);
2194 gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), txt_filter);
2195 passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == txt_filter);
2196 log_test (passed, "test_folder_switch_and_filters(): set and get filter");
2199 gtk_widget_show (dialog);
2201 /* Test that filter is unchanged when we switch folders */
2203 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd);
2204 sleep_in_main_loop ();
2205 passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == txt_filter);
2208 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), base_dir);
2209 sleep_in_main_loop ();
2211 g_signal_emit_by_name (impl->browse_path_bar, "path-clicked",
2215 sleep_in_main_loop ();
2216 passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == txt_filter);
2217 log_test (passed, "test_folder_switch_and_filters(): filter after changing folder");
2223 g_object_unref (cwd_file);
2224 g_object_unref (base_dir_file);
2226 gtk_widget_destroy (dialog);
2228 log_test (passed, "test_folder_switch_and_filters(): all filter tests");
2236 /* initialize test program */
2237 gtk_test_init (&argc, &argv);
2239 /* Register tests */
2241 setup_file_chooser_button_tests ();
2243 setup_set_filename_tests ();
2244 setup_set_current_name_tests ();
2246 g_test_add_func ("/GtkFileChooser/confirm_overwrite", test_confirm_overwrite);
2247 g_test_add_func ("/GtkFileChooser/action_widgets", test_action_widgets);
2248 g_test_add_func ("/GtkFileChooser/reload", test_reload);
2249 g_test_add_func ("/GtkFileChooser/button_folder_states", test_button_folder_states);
2250 g_test_add_func ("/GtkFileChooser/folder_switch_and_filters", test_folder_switch_and_filters);
2253 /* run and check selected tests */
2254 return g_test_run();