summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp')
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp124
1 files changed, 0 insertions, 124 deletions
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp b/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp
deleted file mode 100644
index 110677e41..000000000
--- a/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2014 Igalia S.L.
- *
- * 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 "config.h"
-
-#include "WebProcessTest.h"
-#include <gio/gio.h>
-#include <webkit2/webkit-web-extension.h>
-#include <wtf/glib/GUniquePtr.h>
-
-typedef struct _WebKitXPathNSResolver {
- GObject parent;
-} WebKitXPathNSResolver;
-
-typedef struct _WebKitXPathNSResolverClass {
- GObjectClass parentClass;
-} WebKitXPathNSResolverClass;
-
-static char* webkitXPathNSResolverLookupNamespaceURI(WebKitDOMXPathNSResolver* resolver, const char* prefix)
-{
- if (!g_strcmp0(prefix, "foo"))
- return g_strdup("http://www.example.com");
-
- return nullptr;
-}
-
-static void webkitXPathNSResolverDOMXPathNSResolverIfaceInit(WebKitDOMXPathNSResolverIface* iface)
-{
- iface->lookup_namespace_uri = webkitXPathNSResolverLookupNamespaceURI;
-}
-
-G_DEFINE_TYPE_WITH_CODE(WebKitXPathNSResolver, webkit_xpath_ns_resolver, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER, webkitXPathNSResolverDOMXPathNSResolverIfaceInit))
-
-static void webkit_xpath_ns_resolver_init(WebKitXPathNSResolver*)
-{
-}
-
-static void webkit_xpath_ns_resolver_class_init(WebKitXPathNSResolverClass*)
-{
-}
-
-class WebKitDOMXPathNSResolverTest : public WebProcessTest {
-public:
- static std::unique_ptr<WebProcessTest> create() { return std::unique_ptr<WebProcessTest>(new WebKitDOMXPathNSResolverTest()); }
-
-private:
- void evaluateFooChildTextAndCheckResult(WebKitDOMDocument* document, WebKitDOMXPathNSResolver* resolver)
- {
- WebKitDOMElement* documentElement = webkit_dom_document_get_document_element(document);
- g_assert(WEBKIT_DOM_IS_ELEMENT(documentElement));
- assertObjectIsDeletedWhenTestFinishes(G_OBJECT(documentElement));
-
- GRefPtr<WebKitDOMXPathResult> result = adoptGRef(webkit_dom_document_evaluate(document, "foo:child/text()", WEBKIT_DOM_NODE(documentElement), resolver, WEBKIT_DOM_XPATH_RESULT_ORDERED_NODE_ITERATOR_TYPE, nullptr, nullptr));
- g_assert(WEBKIT_DOM_IS_XPATH_RESULT(result.get()));
- assertObjectIsDeletedWhenTestFinishes(G_OBJECT(result.get()));
-
- WebKitDOMNode* nodeResult = webkit_dom_xpath_result_iterate_next(result.get(), nullptr);
- g_assert(WEBKIT_DOM_IS_NODE(nodeResult));
- assertObjectIsDeletedWhenTestFinishes(G_OBJECT(nodeResult));
-
- GUniquePtr<char> nodeValue(webkit_dom_node_get_node_value(nodeResult));
- g_assert_cmpstr(nodeValue.get(), ==, "SUCCESS");
- }
-
- bool testXPathNSResolverNative(WebKitWebPage* page)
- {
- WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
- g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
- assertObjectIsDeletedWhenTestFinishes(G_OBJECT(document));
-
- GRefPtr<WebKitDOMXPathNSResolver> resolver = adoptGRef(webkit_dom_document_create_ns_resolver(document, WEBKIT_DOM_NODE(webkit_dom_document_get_document_element(document))));
- g_assert(WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver.get()));
- assertObjectIsDeletedWhenTestFinishes(G_OBJECT(resolver.get()));
- evaluateFooChildTextAndCheckResult(document, resolver.get());
-
- return true;
- }
-
- bool testXPathNSResolverCustom(WebKitWebPage* page)
- {
- WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
- g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
- assertObjectIsDeletedWhenTestFinishes(G_OBJECT(document));
-
- GRefPtr<WebKitDOMXPathNSResolver> resolver = adoptGRef(WEBKIT_DOM_XPATH_NS_RESOLVER(g_object_new(webkit_xpath_ns_resolver_get_type(), nullptr)));
- assertObjectIsDeletedWhenTestFinishes(G_OBJECT(resolver.get()));
- evaluateFooChildTextAndCheckResult(document, resolver.get());
-
- return true;
- }
-
- bool runTest(const char* testName, WebKitWebPage* page) override
- {
- if (!strcmp(testName, "native"))
- return testXPathNSResolverNative(page);
- if (!strcmp(testName, "custom"))
- return testXPathNSResolverCustom(page);
-
- g_assert_not_reached();
- return false;
- }
-};
-
-static void __attribute__((constructor)) registerTests()
-{
- REGISTER_TEST(WebKitDOMXPathNSResolverTest, "WebKitDOMXPathNSResolver/native");
- REGISTER_TEST(WebKitDOMXPathNSResolverTest, "WebKitDOMXPathNSResolver/custom");
-}