Commit a97fa34f authored by carlosgc@webkit.org's avatar carlosgc@webkit.org

[GTK] Add a unit tests to WebKit2 to test node names

https://bugs.webkit.org/show_bug.cgi?id=125686

Reviewed by Gustavo Noronha Silva.

* UIProcess/API/gtk/tests/DOMNodeTest.cpp:
(WebKitDOMNodeTest::testTagNames):
(WebKitDOMNodeTest::runTest):
(registerTests):
* UIProcess/API/gtk/tests/TestDOMNode.cpp:
(testWebKitDOMNodeTagNames):
(beforeAll):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160540 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 780a04c0
2013-12-13 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Add a unit tests to WebKit2 to test node names
https://bugs.webkit.org/show_bug.cgi?id=125686
Reviewed by Gustavo Noronha Silva.
* UIProcess/API/gtk/tests/DOMNodeTest.cpp:
(WebKitDOMNodeTest::testTagNames):
(WebKitDOMNodeTest::runTest):
(registerTests):
* UIProcess/API/gtk/tests/TestDOMNode.cpp:
(testWebKitDOMNodeTagNames):
(beforeAll):
2013-12-13 Zan Dobersek <zdobersek@igalia.com>
Unreviewed. Further GTK WK2 build fixes after r160504.
......
......@@ -22,6 +22,7 @@
#include "WebProcessTest.h"
#include <gio/gio.h>
#include <webkit2/webkit-web-extension.h>
#include <wtf/gobject/GOwnPtr.h>
class WebKitDOMNodeTest : public WebProcessTest {
public:
......@@ -169,12 +170,36 @@ private:
return true;
}
bool testTagNames(WebKitWebExtension* extension, GVariant* args)
{
static const char* expectedTagNames[] = { "HTML", "HEAD", "BODY", "VIDEO", "SOURCE", "VIDEO", "SOURCE", "INPUT" };
WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
g_assert(WEBKIT_IS_WEB_PAGE(page));
WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
WebKitDOMNodeList* list = webkit_dom_document_get_elements_by_tag_name(document, "*");
gulong nodeCount = webkit_dom_node_list_get_length(list);
g_assert_cmpuint(nodeCount, ==, G_N_ELEMENTS(expectedTagNames));
for (unsigned i = 0; i < nodeCount; i++) {
WebKitDOMNode* node = webkit_dom_node_list_item(list, i);
g_assert(WEBKIT_DOM_IS_NODE(node));
GOwnPtr<char> tagName(webkit_dom_node_get_node_name(node));
g_assert_cmpstr(tagName.get(), ==, expectedTagNames[i]);
}
return true;
}
virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
{
if (!strcmp(testName, "hierarchy-navigation"))
return testHierarchyNavigation(extension, args);
if (!strcmp(testName, "insertion"))
return testInsertion(extension, args);
if (!strcmp(testName, "tag-names"))
return testTagNames(extension, args);
g_assert_not_reached();
return false;
......@@ -185,6 +210,7 @@ static void __attribute__((constructor)) registerTests()
{
REGISTER_TEST(WebKitDOMNodeTest, "WebKitDOMNode/hierarchy-navigation");
REGISTER_TEST(WebKitDOMNodeTest, "WebKitDOMNode/insertion");
REGISTER_TEST(WebKitDOMNodeTest, "WebKitDOMNode/tag-names");
}
......@@ -50,6 +50,27 @@ static void testWebKitDOMNodeInsertion(WebViewTest* test, gconstpointer)
g_assert(testRunner->runTest("WebKitDOMNode", "insertion", g_variant_builder_end(&builder)));
}
static void testWebKitDOMNodeTagNames(WebViewTest* test, gconstpointer)
{
static const char* testHTML = "<html><head></head><body>"
"<video id='video' preload='none'>"
" <source src='movie.ogg' type='video/ogg'>"
" Your browser does not support the video tag."
"</video>"
"<video id='video2' preload='none'>"
" <source src='movie.ogg' type='video/ogg'>"
" Your browser does not support the video tag."
"</video>"
"<input type='hidden' id='test' name='finish' value='false'></body></html>";
test->loadHtml(testHTML, 0);
test->waitUntilLoadFinished();
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
g_assert(testRunner->runTest("WebKitDOMNode", "tag-names", g_variant_builder_end(&builder)));
}
void beforeAll()
{
testRunner = new WebProcessTestRunner();
......@@ -57,6 +78,7 @@ void beforeAll()
WebViewTest::add("WebKitDOMNode", "hierarchy-navigation", testWebKitDOMNodeHierarchyNavigation);
WebViewTest::add("WebKitDOMNode", "insertion", testWebKitDOMNodeInsertion);
WebViewTest::add("WebKitDOMNode", "tag-names", testWebKitDOMNodeTagNames);
}
void afterAll()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment