Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 "core/html/HTMLFormElement.h" | |
| 7 | |
| 8 #include "core/frame/FrameView.h" | |
| 9 #include "core/html/HTMLDocument.h" | |
| 10 #include "core/html/HTMLInputElement.h" | |
| 11 #include "core/loader/EmptyClients.h" | |
| 12 #include "core/testing/DummyPageHolder.h" | |
| 13 #include <gtest/gtest.h> | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 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
| |
| 18 protected: | |
| 19 virtual void SetUp() OVERRIDE; | |
| 20 | |
| 21 DummyPageHolder& page() const { return *m_dummyPageHolder; } | |
| 22 HTMLDocument& document() const { return *m_document; } | |
| 23 | |
| 24 private: | |
| 25 OwnPtr<DummyPageHolder> m_dummyPageHolder; | |
| 26 RefPtrWillBePersistent<HTMLDocument> m_document; | |
| 27 }; | |
| 28 | |
| 29 void HTMLFormElementTest::SetUp() | |
| 30 { | |
| 31 Page::PageClients pageClients; | |
| 32 fillWithEmptyClients(pageClients); | |
| 33 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ; | |
| 34 | |
| 35 m_document = toHTMLDocument(&m_dummyPageHolder->document()); | |
| 36 m_document->setMimeType("text/html"); | |
| 37 m_document->setCharset("utf-8"); | |
| 38 } | |
| 39 | |
| 40 TEST_F(HTMLFormElementTest, isValidElement) | |
| 41 { | |
| 42 document().documentElement()->setInnerHTML( | |
| 43 "<body><form id=form1><input required><input required value=0></form>" | |
| 44 "<form id=form2><input><input required value=0></form>" | |
| 45 "<form id=form3></form></body>", ASSERT_NO_EXCEPTION); | |
| 46 document().view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 47 | |
| 48 HTMLFormElement* form1 = toHTMLFormElement(document().getElementById("form1" )); | |
| 49 HTMLFormElement* form2 = toHTMLFormElement(document().getElementById("form2" )); | |
| 50 HTMLFormElement* form3 = toHTMLFormElement(document().getElementById("form3" )); | |
| 51 | |
| 52 EXPECT_FALSE(form1->isValidElement()); | |
| 53 EXPECT_TRUE(form2->isValidElement()); | |
| 54 EXPECT_TRUE(form3->isValidElement()); | |
| 55 } | |
| 56 | |
| 57 } | |
| OLD | NEW |