2 * Copyright (C) 2010 Igalia S.L.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #include <glib/gstdio.h>
24 #include <webkit/webkit.h>
26 #if GTK_CHECK_VERSION(2, 14, 0)
28 /* This function is not public, so we need an extern declaration */
29 extern void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* view, const gchar* directory);
31 static void test_webkit_web_plugin_database_get_plugins()
33 WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new());
34 WebKitWebPluginDatabase* database;
35 GSList* pluginList, *p;
36 gboolean found = FALSE;
37 gboolean enabled = FALSE;
39 webkit_web_settings_add_extra_plugin_directory(view, TEST_PLUGIN_DIR);
40 g_object_ref_sink(G_OBJECT(view));
42 database = webkit_get_web_plugin_database();
43 pluginList = webkit_web_plugin_database_get_plugins(database);
44 for (p = pluginList; p; p = p->next) {
45 WebKitWebPlugin* plugin = (WebKitWebPlugin*)p->data;
46 if (!g_strcmp0(webkit_web_plugin_get_name(plugin), "WebKit Test PlugIn") &&
47 !g_strcmp0(webkit_web_plugin_get_description(plugin), "Simple Netscape plug-in that handles test content for WebKit")) {
49 enabled = webkit_web_plugin_get_enabled(plugin);
50 webkit_web_plugin_set_enabled(plugin, FALSE);
53 webkit_web_plugin_database_plugins_list_free(pluginList);
57 webkit_web_plugin_database_refresh(database);
58 pluginList = webkit_web_plugin_database_get_plugins(database);
60 for (p = pluginList; p; p = p->next) {
61 WebKitWebPlugin* plugin = (WebKitWebPlugin*)p->data;
62 if (!g_strcmp0(webkit_web_plugin_get_name(plugin), "WebKit Test PlugIn") &&
63 !g_strcmp0(webkit_web_plugin_get_description(plugin), "Simple Netscape plug-in that handles test content for WebKit"))
64 enabled = webkit_web_plugin_get_enabled(plugin);
66 webkit_web_plugin_database_plugins_list_free(pluginList);
72 int main(int argc, char** argv)
75 gtk_test_init(&argc, &argv, NULL);
77 g_test_bug_base("https://bugs.webkit.org/");
78 g_test_add_func("/webkit/webplugindatabase/getplugins", test_webkit_web_plugin_database_get_plugins);
83 int main(int argc, char** argv)
85 g_critical("You will need at least gtk-2.14.0 to run the unit tests. Doing nothing now.");