Chromium Code Reviews| Index: Source/core/html/HTMLFormElementTest.cpp |
| diff --git a/Source/core/html/HTMLFormElementTest.cpp b/Source/core/html/HTMLFormElementTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2076398b0891715eb6de9a128239e388949c8c74 |
| --- /dev/null |
| +++ b/Source/core/html/HTMLFormElementTest.cpp |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "core/html/HTMLFormElement.h" |
| + |
| +#include "core/frame/FrameView.h" |
| +#include "core/html/HTMLDocument.h" |
| +#include "core/html/HTMLInputElement.h" |
| +#include "core/loader/EmptyClients.h" |
| +#include "core/testing/DummyPageHolder.h" |
| +#include <gtest/gtest.h> |
| + |
| +namespace blink { |
| + |
| +class HTMLFormElementTest : public ::testing::Test { |
|
keishi
2014/10/01 09:25:28
In blink we try to write layout tests if possible
Bartek Nowierski
2014/10/02 14:26:43
Added a LayoutTests/fast/forms/form-pseudo-valid-s
|
| +protected: |
| + virtual void SetUp() OVERRIDE; |
| + |
| + DummyPageHolder& page() const { return *m_dummyPageHolder; } |
| + HTMLDocument& document() const { return *m_document; } |
| + |
| +private: |
| + OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| + RefPtrWillBePersistent<HTMLDocument> m_document; |
| +}; |
| + |
| +void HTMLFormElementTest::SetUp() |
| +{ |
| + Page::PageClients pageClients; |
| + fillWithEmptyClients(pageClients); |
| + m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients); |
| + |
| + m_document = toHTMLDocument(&m_dummyPageHolder->document()); |
| + m_document->setMimeType("text/html"); |
| + m_document->setCharset("utf-8"); |
| +} |
| + |
| +TEST_F(HTMLFormElementTest, isValidElement) |
| +{ |
| + document().documentElement()->setInnerHTML( |
| + "<body><form id=form1><input required><input required value=0></form>" |
| + "<form id=form2><input><input required value=0></form>" |
| + "<form id=form3></form></body>", ASSERT_NO_EXCEPTION); |
| + document().view()->updateLayoutAndStyleIfNeededRecursive(); |
| + |
| + HTMLFormElement* form1 = toHTMLFormElement(document().getElementById("form1")); |
| + HTMLFormElement* form2 = toHTMLFormElement(document().getElementById("form2")); |
| + HTMLFormElement* form3 = toHTMLFormElement(document().getElementById("form3")); |
| + |
| + EXPECT_FALSE(form1->isValidElement()); |
| + EXPECT_TRUE(form2->isValidElement()); |
| + EXPECT_TRUE(form3->isValidElement()); |
| +} |
| + |
| +} |