Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1024)

Unified Diff: Source/core/html/HTMLFormElementTest.cpp

Issue 616443002: Implement :valid and :invalid pseudoclass for <form> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add layout tests, apply feedback from Keishi, add support for removing/inserting elements into the … Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {
+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());
+}
+
+}
« Source/core/html/HTMLFormControlElement.cpp ('K') | « Source/core/html/HTMLFormElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698