static void test_file_chooser_widget_basic (void) { GtkWidget *widget; /* This test also tests the internal GtkPathBar widget */ g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL); widget = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); g_assert (GTK_IS_FILE_CHOOSER_WIDGET (widget)); /* XXX BUG: * * Spin the mainloop for a bit, this allows the file operations * to complete, GtkFileChooserDefault has a bug where it leaks * GtkTreeRowReferences to the internal shortcuts_model * * Since we assert all automated children are finalized we * can catch this */ g_timeout_add (100, main_loop_quit_cb, NULL); gtk_main(); gtk_widget_destroy (widget); }
int main(int argc, char *argv[]) { g_test_init (&argc, &argv, NULL); setlocale(LC_ALL, ""); g_test_add_func("/layerapi/test_test_file_presence_in_directory", test_test_file_presence_in_directory); g_test_add_func("/layerapi/test_read_file_in_directory", test_read_file_in_directory); g_test_add_func("/layerapi/test_lines_to_gslist", test_lines_to_gslist); g_test_add_func("/layerapi/test_file_in_directory_to_gslist", test_file_in_directory_to_gslist); g_test_add_func("/layerapi/test_get_python_relative_site_packages", test_get_python_relative_site_packages); g_test_add_func("/layerapi/test_log/normal", test_log); g_test_add_func("/layerapi/test_log/debug", test_log_debug); g_test_add_func("/layerapi/test_field_prepend/normal", test_field_prepend_normal); g_test_add_func("/layerapi/test_field_prepend/special", test_field_prepend_special); g_test_add_func("/layerapi/test_prepend_env", test_prepend_env); g_test_add_func("/layerapi/test_remove_env", test_remove_env); g_test_add_func("/layerapi/test_field_remove/normal", test_field_remove_normal); g_test_add_func("/layerapi/test_field_remove/special", test_field_remove_special); g_test_add_func("/layerapi/test_add_extra_env", test_conditional_add_extra_env); g_test_add_func("/layerapi/test_remove_extra_env", test_conditional_remove_extra_env); g_test_add_func("/layerapi/test_get_layers_paths", test_get_layers_paths); g_test_add_func("/layerapi/test_layers_list", test_layers_list); g_test_add_func("/layerapi/test_conditional_prepend_env", test_conditional_prepend_env); g_test_add_func("/layerapi/test_print_conditional_source_bash_cmds", test_print_conditional_source_bash_cmds); g_test_add_func("/layerapi/test_layer_new_from_label_or_home", test_layer_new_from_label_or_home); g_test_add_func("/layerapi/test_layer_load", test_layer_load); g_test_add_func("/layerapi/test_layer_load2", test_layer_load2); g_test_add_func("/layerapi/test_layer_load3", test_layer_load3); g_test_add_func("/layerapi/test_layer_loaderror", test_layer_loaderror); layerapi2_init(FALSE); g_test_log_set_fatal_handler(log_fatal_func, NULL); int res = g_test_run(); layerapi2_destroy(); return res; }
static void expected_message_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) { gint level = log_level & G_LOG_LEVEL_MASK; ExpectedMessage *expected = NULL; gchar *expected_message; gboolean skip = FALSE; G_LOCK (expected); if (level && expected_messages && (level & G_LOG_LEVEL_DEBUG) == 0) { expected = expected_messages->data; if (log_level & G_LOG_FLAG_FATAL) { ignore_fatal_count = 1; /* This handler is reset for each test, so set it right before we need it */ g_test_log_set_fatal_handler (expected_fatal_handler, NULL); } if (g_strcmp0 (expected->log_domain, log_domain) == 0 && ((log_level & expected->log_level) == expected->log_level) && g_pattern_match_simple (expected->pattern, message)) { expected_messages = g_slist_delete_link (expected_messages, expected_messages); g_free (expected->log_domain); g_free (expected->pattern); g_free (expected); skip = TRUE; } } G_UNLOCK (expected); if (skip) return; gtest_default_log_handler (log_domain, log_level, message, NULL); if (expected) { expected_message = g_strdup_printf ("Did not see expected %s-%s: %s", expected->log_domain, calc_prefix (expected->log_level), expected->pattern); g_assertion_message (expected->log_domain, expected->file, expected->line, expected->func, expected_message); g_free (expected_message); } }
static void test_file_chooser_button_basic (void) { GtkWidget *widget; g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL); widget = gtk_file_chooser_button_new ("Choose a file !", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); g_assert (GTK_IS_FILE_CHOOSER_BUTTON (widget)); g_timeout_add (100, main_loop_quit_cb, NULL); gtk_main(); gtk_widget_destroy (widget); }
static void test_input_context (void) { GList *engines; gchar *active_engine_name = NULL; IBusInputContext *context; IBusEngineDesc *engine_desc; gchar *current_ic; context = ibus_bus_create_input_context (bus, "test"); call_basic_ipcs (context); engines = ibus_bus_list_active_engines (bus); if (engines != NULL) { active_engine_name = get_last_engine_id (engines); } else { active_engine_name = g_strdup ("dummy"); } g_assert (active_engine_name); g_debug ("Use '%s' for testing.", active_engine_name); ibus_input_context_set_engine (context, active_engine_name); current_ic = ibus_bus_current_input_context (bus); g_assert (!strcmp (current_ic, g_dbus_proxy_get_object_path ((GDBusProxy *)context))); g_test_log_set_fatal_handler (fatal_handler, NULL); engine_desc = ibus_input_context_get_engine (context); if (engine_desc) { /* FIXME race condition between ibus_input_context_set_engine and _get_engine. * ibus_input_context_get_engine is not guaranteed to return non-NULL * (even if we use synchronous set_engine()) because ibus-daemon sets a context * engine in an asynchronous manner. See _context_request_engine_cb in * ibusimpl.c which handles context_signals[REQUEST_ENGINE] signal. */ g_assert (!strcmp (active_engine_name, ibus_engine_desc_get_name(engine_desc))); g_object_unref (engine_desc); engine_desc = NULL; } ibus_input_context_process_key_event (context, 0, 0, 0); /* An engine is set. Try to call basic IPCs again. */ call_basic_ipcs (context); g_free (current_ic); g_object_unref (context); g_free (active_engine_name); g_list_foreach (engines, (GFunc) g_object_unref, NULL); g_list_free (engines); }
void ide_application_run_tests (IdeApplication *self) { IDE_ENTRY; g_assert (IDE_IS_APPLICATION (self)); if (self->test_funcs != NULL) { g_test_log_set_fatal_handler (fatal_log_handler, NULL); g_application_hold (G_APPLICATION (self)); ide_application_run_next_test (self); } IDE_EXIT; }
static void test_file_chooser_dialog_basic (void) { GtkWidget *widget; g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL); widget = gtk_file_chooser_dialog_new ("The Dialog", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "_OK", GTK_RESPONSE_OK, NULL); g_assert (GTK_IS_FILE_CHOOSER_DIALOG (widget)); g_timeout_add (100, main_loop_quit_cb, NULL); gtk_main(); gtk_widget_destroy (widget); }
static void test_create_widget (gconstpointer data) { GladeWidgetAdaptor *adaptor = (GladeWidgetAdaptor *)data; GladeWidget *widget; GObject *object; gboolean widget_finalized = FALSE; gboolean object_finalized = FALSE; g_test_log_set_fatal_handler (ignore_gvfs_warning, NULL); widget = glade_widget_adaptor_create_widget (adaptor, FALSE, NULL); g_assert (GLADE_IS_WIDGET (widget)); object = glade_widget_get_object (widget); g_assert (G_IS_OBJECT (object)); g_object_weak_ref (G_OBJECT (widget), check_finalized, &widget_finalized); g_object_weak_ref (G_OBJECT (object), check_finalized, &object_finalized); /* filechoosers hold a reference until an async operation is complete */ if (GTK_IS_FILE_CHOOSER (object)) { g_timeout_add (2000, main_loop_quit_cb, NULL); gtk_main(); } /* Our plugin code adds an idle when cell renderers are created */ else if (GTK_IS_CELL_RENDERER (object)) { g_timeout_add (50, main_loop_quit_cb, NULL); gtk_main(); } /* Get rid of the GladeWidget and assert that it finalizes along * with it's internal object */ g_object_unref (widget); g_assert (widget_finalized); g_assert (object_finalized); }
void test_helper_begin_test (void) { g_test_log_set_fatal_handler (fatal_log_handler, NULL); }