diff options
author | Federico Mena Quintero <federico@gnome.org> | 2013-02-20 18:28:59 -0600 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2013-02-20 20:12:52 -0600 |
commit | cefcafc5087cfbc627d2ad719e85b9a0b7a96232 (patch) | |
tree | 5d119c3666c3aa7d9d757fa61cb7dac25fc35719 | |
parent | ac5cc198369950a9fddc8e08a5227dce8fc2aabf (diff) | |
download | gtk+-cefcafc5087cfbc627d2ad719e85b9a0b7a96232.tar.gz |
filechooserbutton: In the tests, run through the dialog more than one time
This ensures that data maintained by the button while the dialog opens/closes remains consistent.
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
-rw-r--r-- | gtk/tests/filechooser.c | 82 |
1 files changed, 48 insertions, 34 deletions
diff --git a/gtk/tests/filechooser.c b/gtk/tests/filechooser.c index 8e5ffc9b77..399e8e7ccb 100644 --- a/gtk/tests/filechooser.c +++ b/gtk/tests/filechooser.c @@ -382,6 +382,8 @@ test_file_chooser_button (gconstpointer data) GtkWidget *window; GtkWidget *fc_button; GtkWidget *fc_dialog; + int iterations; + int i; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -398,54 +400,66 @@ test_file_chooser_button (gconstpointer data) gtk_widget_show_all (window); wait_for_idle (); + /* If there is a dialog to be opened, we actually test going through it a + * couple of times. This ensures that any state that the button frobs for + * each appearance of the dialog will make sense. + */ if (setup->open_dialog) + iterations = 2; + else + iterations = 1; + + for (i = 0; i < iterations; i++) { - GList *children; + if (setup->open_dialog) + { + GList *children; - /* Hack our way into the file chooser button; get its GtkButton child and click it */ - children = gtk_container_get_children (GTK_CONTAINER (fc_button)); - g_assert (children && GTK_IS_BUTTON (children->data)); - gtk_button_clicked (GTK_BUTTON (children->data)); - g_list_free (children); + /* Hack our way into the file chooser button; get its GtkButton child and click it */ + children = gtk_container_get_children (GTK_CONTAINER (fc_button)); + g_assert (children && GTK_IS_BUTTON (children->data)); + gtk_button_clicked (GTK_BUTTON (children->data)); + g_list_free (children); - wait_for_idle (); + wait_for_idle (); - /* Give me the internal dialog, damnit */ - fc_dialog = g_object_get_qdata (G_OBJECT (fc_button), delegate_get_quark ()); - g_assert (GTK_IS_FILE_CHOOSER (fc_dialog)); - g_assert (GTK_IS_DIALOG (fc_dialog)); - } + /* Give me the internal dialog, damnit */ + fc_dialog = g_object_get_qdata (G_OBJECT (fc_button), delegate_get_quark ()); + g_assert (GTK_IS_FILE_CHOOSER (fc_dialog)); + g_assert (GTK_IS_DIALOG (fc_dialog)); + } - /* Okay, now frob the button and its optional dialog */ + /* Okay, now frob the button and its optional dialog */ - if (setup->tweak_current_folder) - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc_button), setup->tweak_current_folder); + if (setup->tweak_current_folder) + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc_button), setup->tweak_current_folder); - if (setup->tweak_filename) - gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (fc_button), setup->tweak_filename); + if (setup->tweak_filename) + gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (fc_button), setup->tweak_filename); - sleep_in_main_loop (); + sleep_in_main_loop (); - if (setup->open_dialog) - { - gtk_dialog_response (GTK_DIALOG (fc_dialog), setup->dialog_response); - wait_for_idle (); - } + if (setup->open_dialog) + { + gtk_dialog_response (GTK_DIALOG (fc_dialog), setup->dialog_response); + wait_for_idle (); + } - if (setup->final_current_folder) - { - char *folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (fc_button)); + if (setup->final_current_folder) + { + char *folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (fc_button)); - g_assert_cmpstr (folder, ==, setup->final_current_folder); - g_free (folder); - } + g_assert_cmpstr (folder, ==, setup->final_current_folder); + g_free (folder); + } - if (setup->final_filename) - { - char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc_button)); + if (setup->final_filename) + { + char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc_button)); - g_assert_cmpstr (filename, ==, setup->final_filename); - g_free (filename); + g_assert_cmpstr (filename, ==, setup->final_filename); + g_free (filename); + } } gtk_widget_destroy (window); |