[gtk+/gtk-2-24] filechooser: Test canceling the dialog inside a GtkFileChooserButton
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] filechooser: Test canceling the dialog inside a GtkFileChooserButton
- Date: Tue, 12 Feb 2013 05:21:41 +0000 (UTC)
commit 2900fa9b62f594f780a4c9f69075f6221bbb1448
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Feb 11 18:19:45 2013 -0600
filechooser: Test canceling the dialog inside a GtkFileChooserButton
Signed-off-by: Federico Mena Quintero <federico gnome org>
gtk/tests/filechooser.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/gtk/tests/filechooser.c b/gtk/tests/filechooser.c
index 15646ac..e2b37fb 100644
--- a/gtk/tests/filechooser.c
+++ b/gtk/tests/filechooser.c
@@ -334,10 +334,58 @@ test_file_chooser_button_set_folder (void)
}
static void
+test_file_chooser_button_dialog_cancel (void)
+{
+ GtkWidget *window;
+ GtkWidget *fc_dialog;
+ GtkWidget *fc_button;
+ GList *children;
+ char *filename;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ fc_dialog = gtk_file_chooser_dialog_new ("Select a file",
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ fc_button = gtk_file_chooser_button_new_with_dialog (fc_dialog);
+ gtk_container_add (GTK_CONTAINER (window), fc_button);
+
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fc_button), FILE_NAME);
+
+ gtk_widget_show_all (window);
+ wait_for_idle ();
+
+ children = gtk_container_get_children (GTK_CONTAINER (fc_button));
+ g_assert (children && GTK_IS_BUTTON (children->data));
+ gtk_button_clicked (GTK_WIDGET (children->data));
+ g_list_free (children);
+
+ wait_for_idle ();
+
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fc_dialog), "/etc/group");
+ wait_for_idle ();
+
+ gtk_dialog_response (GTK_DIALOG (fc_dialog), GTK_RESPONSE_CANCEL);
+ wait_for_idle ();
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc_button));
+ g_assert_cmpstr (filename, ==, FILE_NAME);
+
+ g_free (filename);
+ gtk_widget_destroy (window);
+ gtk_widget_destroy (fc_dialog);
+}
+
+static void
setup_file_chooser_button_tests (void)
{
g_test_add_func ("/GtkFileChooserButton/set_filename", test_file_chooser_button_set_filename);
g_test_add_func ("/GtkFileChooserButton/set_folder", test_file_chooser_button_set_folder);
+ g_test_add_func ("/GtkFileChooserButton/set_folder", test_file_chooser_button_dialog_cancel);
}
struct confirm_overwrite_closure {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]