filechooser: Get the filechooser tests to build

Some are ifdef-ed out with BROKEN_TESTS, but at least the tests will compile for now.
This commit is contained in:
Federico Mena Quintero
2013-02-11 13:38:58 -06:00
parent 2ffaa468e5
commit e14808fdd3
3 changed files with 19 additions and 10 deletions

View File

@@ -62,7 +62,7 @@ crossingevents_LDADD = $(progs_ldadd)
# this doesn't work in make distcheck, since it doesn't
# find file-chooser-test-dir
# TEST_PROGS += filechooser
TEST_PROGS += filechooser
filechooser_SOURCES = filechooser.c pixbuf-init.c
filechooser_LDADD = $(progs_ldadd)

View File

@@ -498,7 +498,7 @@ get_impl_from_dialog (GtkWidget *dialog)
return impl;
}
#ifdef BROKEN_TESTS
static gboolean
test_widgets_for_current_action (GtkFileChooserDialog *dialog,
GtkFileChooserAction expected_action)
@@ -663,7 +663,9 @@ test_action_widgets (void)
gtk_widget_destroy (dialog);
}
#endif
#ifdef BROKEN_TESTS
static gboolean
test_reload_sequence (gboolean set_folder_before_map)
{
@@ -820,6 +822,7 @@ test_reload (void)
log_test (passed, "test_reload(): set a folder explicitly before mapping");
g_assert (passed);
}
#endif
static gboolean
test_button_folder_states_for_action (GtkFileChooserAction action, gboolean use_dialog, gboolean set_folder_on_dialog)
@@ -990,8 +993,8 @@ test_folder_switch_and_filters (void)
gboolean passed;
char *cwd;
char *base_dir;
GtkFilePath *cwd_path;
GtkFilePath *base_dir_path;
GFile *cwd_file;
GFile *base_dir_file;
GtkWidget *dialog;
GtkFileFilter *all_filter;
GtkFileFilter *txt_filter;
@@ -1008,8 +1011,8 @@ test_folder_switch_and_filters (void)
NULL);
impl = get_impl_from_dialog (dialog);
cwd_path = gtk_file_system_filename_to_path (impl->file_system, cwd);
base_dir_path = gtk_file_system_filename_to_path (impl->file_system, base_dir);
cwd_file = g_file_new_for_path (cwd);
base_dir_file = g_file_new_for_path (base_dir);
passed = passed && gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), base_dir);
g_assert (passed);
@@ -1051,8 +1054,8 @@ test_folder_switch_and_filters (void)
sleep_in_main_loop (0.25);
g_signal_emit_by_name (impl->browse_path_bar, "path-clicked",
(GtkFilePath *) cwd_path,
(GtkFilePath *) base_dir_path,
cwd_file,
base_dir_file,
FALSE);
sleep_in_main_loop (0.25);
passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == txt_filter);
@@ -1062,8 +1065,8 @@ test_folder_switch_and_filters (void)
/* cleanups */
g_free (cwd);
g_free (base_dir);
gtk_file_path_free (cwd_path);
gtk_file_path_free (base_dir_path);
g_object_unref (cwd_file);
g_object_unref (base_dir_file);
gtk_widget_destroy (dialog);
@@ -1083,8 +1086,12 @@ main (int argc,
/* register tests */
g_test_add_func ("/GtkFileChooser/black_box", test_black_box);
g_test_add_func ("/GtkFileChooser/confirm_overwrite", test_confirm_overwrite);
#ifdef BROKEN_TESTS
g_test_add_func ("/GtkFileChooser/action_widgets", test_action_widgets);
#endif
#ifdef BROKEN_TESTS
g_test_add_func ("/GtkFileChooser/reload", test_reload);
#endif
g_test_add_func ("/GtkFileChooser/button_folder_states", test_button_folder_states);
g_test_add_func ("/GtkFileChooser/folder_switch_and_filters", test_folder_switch_and_filters);

View File

@@ -346,6 +346,8 @@ main (int argc,
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (chooser), gtk_src_dir, NULL);
gtk_file_chooser_remove_shortcut_folder (GTK_FILE_CHOOSER (chooser), gtk_src_dir, NULL);
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (chooser), gtk_src_dir, NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(chooser), "/home/federico/balin");
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
g_signal_connect (chooser, "current-folder-changed",
G_CALLBACK (chooser_current_folder_changed_cb), NULL);