Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / WebNodeTest.cpp
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "public/web/WebNode.h"
7
8 #include "core/testing/DummyPageHolder.h"
9 #include "public/web/WebElement.h"
10 #include "public/web/WebElementCollection.h"
11 #include <gtest/gtest.h>
12
13 namespace blink {
14
15 class WebNodeTest : public testing::Test {
16 protected:
17     Document& document() { return m_pageHolder->document(); }
18
19 private:
20     virtual void SetUp() OVERRIDE;
21
22     OwnPtr<DummyPageHolder> m_pageHolder;
23 };
24
25 void WebNodeTest::SetUp()
26 {
27     m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
28 }
29
30 TEST_F(WebNodeTest, GetElementsByHTMLTagName)
31 {
32     document().documentElement()->setInnerHTML("<body><LABEL></LABEL><svg xmlns='http://www.w3.org/2000/svg'><label></label></svg></body>", ASSERT_NO_EXCEPTION);
33     WebNode node(document().documentElement());
34     // WebNode::getElementsByHTMLTagName returns only HTML elements.
35     WebElementCollection collection = node.getElementsByHTMLTagName("label");
36     EXPECT_EQ(1u, collection.length());
37     EXPECT_TRUE(collection.firstItem().hasHTMLTagName("label"));
38     // The argument should be lower-case.
39     collection = node.getElementsByHTMLTagName("LABEL");
40     EXPECT_EQ(0u, collection.length());
41 }
42
43 }