2009-03-05 22:10:05 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 Christian Dywan <christian@twotoasts.de>
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "midori.h"
|
|
|
|
|
|
|
|
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"))
|
2009-05-21 23:35:47 +00:00
|
|
|
if (g_strcmp0 (gtk_action_get_name (action), "AddSpeedDial"))
|
2011-01-16 13:04:11 +00:00
|
|
|
if (g_strcmp0 (gtk_action_get_name (action), "PrivateBrowsing"))
|
|
|
|
if (g_strcmp0 (gtk_action_get_name (action), "AddDesktopShortcut"))
|
|
|
|
gtk_action_activate (action);
|
2009-03-05 22:10:05 +00:00
|
|
|
actions = g_list_next (actions);
|
|
|
|
}
|
|
|
|
g_list_free (actions);
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (browser));
|
2009-04-05 21:46:15 +00:00
|
|
|
g_object_unref (app);
|
2009-03-05 22:10:05 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 20:54:46 +00:00
|
|
|
static void
|
|
|
|
browser_tooltips (void)
|
|
|
|
{
|
|
|
|
MidoriBrowser* browser;
|
|
|
|
GtkActionGroup* action_group;
|
|
|
|
GList* actions;
|
|
|
|
gchar* toolbar;
|
|
|
|
guint errors = 0;
|
|
|
|
|
|
|
|
browser = midori_browser_new ();
|
|
|
|
action_group = midori_browser_get_action_group (browser);
|
|
|
|
actions = gtk_action_group_list_actions (action_group);
|
|
|
|
toolbar = g_strjoinv (" ", (gchar**)midori_browser_get_toolbar_actions (browser));
|
|
|
|
|
|
|
|
while (actions)
|
|
|
|
{
|
|
|
|
GtkAction* action = actions->data;
|
|
|
|
const gchar* name = gtk_action_get_name (action);
|
|
|
|
|
|
|
|
if (strstr ("CompactMenu Location Separator", name))
|
|
|
|
{
|
|
|
|
actions = g_list_next (actions);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strstr (toolbar, name) != NULL)
|
|
|
|
{
|
|
|
|
if (!gtk_action_get_tooltip (action))
|
|
|
|
{
|
|
|
|
printf ("'%s' can be toolbar item but tooltip is unset\n", name);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gtk_action_get_tooltip (action))
|
|
|
|
{
|
|
|
|
printf ("'%s' is no toolbar item but tooltip is set\n", name);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actions = g_list_next (actions);
|
|
|
|
}
|
|
|
|
g_free (toolbar);
|
|
|
|
g_list_free (actions);
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (browser));
|
|
|
|
|
|
|
|
if (errors)
|
|
|
|
g_error ("Tooltip errors");
|
|
|
|
}
|
|
|
|
|
2012-02-25 23:00:14 +00:00
|
|
|
static void
|
|
|
|
browser_site_data (void)
|
|
|
|
{
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar* url;
|
|
|
|
MidoriSiteDataPolicy policy;
|
|
|
|
} PolicyItem;
|
|
|
|
|
|
|
|
static const PolicyItem items[] = {
|
|
|
|
{ "google.com", MIDORI_SITE_DATA_BLOCK },
|
|
|
|
{ "facebook.com", MIDORI_SITE_DATA_BLOCK },
|
|
|
|
{ "bugzilla.gnome.org", MIDORI_SITE_DATA_PRESERVE },
|
|
|
|
{ "bugs.launchpad.net", MIDORI_SITE_DATA_ACCEPT },
|
|
|
|
};
|
|
|
|
|
|
|
|
const gchar* rules = "-google.com,-facebook.com,!bugzilla.gnome.org,+bugs.launchpad.net";
|
|
|
|
MidoriWebSettings* settings = g_object_new (MIDORI_TYPE_WEB_SETTINGS,
|
|
|
|
"site-data-rules", rules, NULL);
|
|
|
|
|
|
|
|
guint i;
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (items); i++)
|
|
|
|
{
|
|
|
|
MidoriSiteDataPolicy policy = midori_web_settings_get_site_data_policy (
|
|
|
|
settings, items[i].url);
|
|
|
|
if (policy != items[i].policy)
|
|
|
|
g_error ("Match '%s' yields %d but %d expected",
|
|
|
|
items[i].url, policy, items[i].policy);
|
|
|
|
}
|
|
|
|
g_object_unref (settings);
|
|
|
|
}
|
|
|
|
|
2009-03-05 22:10:05 +00:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char** argv)
|
|
|
|
{
|
|
|
|
g_test_init (&argc, &argv, NULL);
|
2012-08-05 22:25:29 +00:00
|
|
|
midori_app_setup (&argc, &argv, NULL, NULL);
|
2012-08-27 19:49:36 +00:00
|
|
|
midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, NULL);
|
2009-03-05 22:10:05 +00:00
|
|
|
|
2012-08-08 23:01:44 +00:00
|
|
|
g_object_set_data (G_OBJECT (webkit_get_default_session ()),
|
|
|
|
"midori-session-initialized", (void*)1);
|
|
|
|
|
2009-03-05 22:10:05 +00:00
|
|
|
g_test_add_func ("/browser/create", browser_create);
|
2011-11-08 20:54:46 +00:00
|
|
|
g_test_add_func ("/browser/tooltips", browser_tooltips);
|
2012-02-25 23:00:14 +00:00
|
|
|
g_test_add_func ("/browser/site_data", browser_site_data);
|
2009-03-05 22:10:05 +00:00
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
}
|