summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/tests/testwebsettings.c
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2009-08-11 17:01:47 +0100
committerBen Murdoch <benm@google.com>2009-08-11 18:21:02 +0100
commit0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch)
tree2943df35f62d885c89d01063cc528dd73b480fea /WebKit/gtk/tests/testwebsettings.c
parent7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff)
downloadexternal_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2
Merge in WebKit r47029.
Diffstat (limited to 'WebKit/gtk/tests/testwebsettings.c')
-rw-r--r--WebKit/gtk/tests/testwebsettings.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/WebKit/gtk/tests/testwebsettings.c b/WebKit/gtk/tests/testwebsettings.c
new file mode 100644
index 0000000..8c77def
--- /dev/null
+++ b/WebKit/gtk/tests/testwebsettings.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2009 Jan Michael Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
+
+static void test_webkit_web_settings_user_agent(void)
+{
+ WebKitWebSettings* settings;
+ GtkWidget* webView;
+ gchar* defaultUserAgent;
+ gchar* userAgent;
+ g_test_bug("17375");
+
+ webView = webkit_web_view_new();
+ g_object_ref_sink(webView);
+
+ settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView));
+ defaultUserAgent = g_strdup(webkit_web_settings_get_user_agent(settings));
+
+ // test a custom UA string
+ userAgent = NULL;
+ g_object_set(G_OBJECT(settings), "user-agent", "testwebsettings/0.1", NULL);
+ g_object_get(G_OBJECT(settings),"user-agent", &userAgent, NULL);
+ g_assert_cmpstr(userAgent, ==, "testwebsettings/0.1");
+ g_free(userAgent);
+
+ // setting it to NULL or an empty value should give us the default UA string
+ userAgent = NULL;
+ g_object_set(G_OBJECT(settings), "user-agent", NULL, NULL);
+ g_object_get(G_OBJECT(settings),"user-agent", &userAgent, NULL);
+ g_assert_cmpstr(userAgent, ==, defaultUserAgent);
+ g_free(userAgent);
+
+ userAgent = NULL;
+ g_object_set(G_OBJECT(settings), "user-agent", "", NULL);
+ g_object_get(G_OBJECT(settings),"user-agent", &userAgent, NULL);
+ g_assert_cmpstr(userAgent, ==, defaultUserAgent);
+ g_free(userAgent);
+
+ g_free(defaultUserAgent);
+ g_object_unref(webView);
+}
+
+int main(int argc, char** argv)
+{
+ g_thread_init(NULL);
+ gtk_test_init(&argc, &argv, NULL);
+
+ g_test_bug_base("https://bugs.webkit.org/");
+ g_test_add_func("/webkit/websettings/user_agent", test_webkit_web_settings_user_agent);
+ return g_test_run ();
+}
+
+#else
+int main(int argc, char** argv)
+{
+ g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now.");
+ return 0;
+}
+
+#endif