From b91b8c5c4bdb7db715ca4733ec166d96637f319c Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Thu, 5 Mar 2009 23:10:05 +0100 Subject: [PATCH] Add unit test for the browser, it tests actions at this point --- tests/browser.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/browser.c diff --git a/tests/browser.c b/tests/browser.c new file mode 100644 index 00000000..63e3fa11 --- /dev/null +++ b/tests/browser.c @@ -0,0 +1,66 @@ +/* + Copyright (C) 2009 Christian Dywan + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + See the file COPYING for the full license text. +*/ + +#if HAVE_CONFIG_H + #include +#endif + +#include "midori.h" +#include "midori-stock.h" +#include "sokoke.h" + +#if GLIB_CHECK_VERSION (2, 16, 0) + +static void +browser_create (void) +{ + MidoriApp* app; + MidoriBrowser* browser; + GtkActionGroup* action_group; + GList* actions; + + app = midori_app_new (); + browser = midori_app_create_browser (app); + gtk_widget_destroy (GTK_WIDGET (browser)); + + app = midori_app_new (); + browser = midori_app_create_browser (app); + action_group = midori_browser_get_action_group (browser); + actions = gtk_action_group_list_actions (action_group); + while (actions) + { + GtkAction* action = actions->data; + if (g_strcmp0 (gtk_action_get_name (action), "WindowClose")) + if (g_strcmp0 (gtk_action_get_name (action), "EncodingCustom")) + gtk_action_activate (action); + actions = g_list_next (actions); + } + g_list_free (actions); + gtk_widget_destroy (GTK_WIDGET (browser)); +} + +int +main (int argc, + char** argv) +{ + /* libSoup uses threads, therefore if WebKit is built with libSoup + or Midori is using it, we need to initialize threads. */ + if (!g_thread_supported ()) g_thread_init (NULL); + g_test_init (&argc, &argv, NULL); + gtk_init_check (&argc, &argv); + sokoke_register_stock_items (); + + g_test_add_func ("/browser/create", browser_create); + + return g_test_run (); +} + +#endif