[gtk+/gtk-2-24] filechooserbutton: In the tests, run through the dialog more than one time
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] filechooserbutton: In the tests, run through the dialog more than one time
- Date: Thu, 21 Feb 2013 00:56:19 +0000 (UTC)
commit a05d51e7ab880eae5f27a135fa25e6fbc1d6b80a
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Feb 20 18:28:59 2013 -0600
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>
gtk/tests/filechooser.c | 84 +++++++++++++++++++++++++++--------------------
1 files changed, 48 insertions(+), 36 deletions(-)
---
diff --git a/gtk/tests/filechooser.c b/gtk/tests/filechooser.c
index d68171d..35da0fa 100644
--- a/gtk/tests/filechooser.c
+++ b/gtk/tests/filechooser.c
@@ -380,6 +380,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);
@@ -396,54 +398,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);
@@ -999,7 +1013,6 @@ static FileChooserButtonTest button_tests[] =
NULL, /* final_current_folder */
FILE_NAME /* final_filename */
},
-#if 0 /* FIXME: this currently doesn't pass */
{
"open-dialog-3",
GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -1012,7 +1025,6 @@ static FileChooserButtonTest button_tests[] =
NULL, /* final_current_folder */
FILE_NAME_2 /* final_filename */
},
-#endif
{
"open-dialog-4",
GTK_FILE_CHOOSER_ACTION_OPEN,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]