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

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

Issue 338283003: Add HTMLTextFormControlElement unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update Created 6 years, 6 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
« no previous file with comments | « Source/core/core.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTextFormControlElementTest.cpp
diff --git a/Source/core/html/HTMLTextFormControlElementTest.cpp b/Source/core/html/HTMLTextFormControlElementTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..614f3c1f2429a39c2cab698f836c71d34585d986
--- /dev/null
+++ b/Source/core/html/HTMLTextFormControlElementTest.cpp
@@ -0,0 +1,54 @@
+// 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/HTMLTextFormControlElement.h"
+
+#include "core/frame/FrameView.h"
+#include "core/html/HTMLDocument.h"
+#include "core/testing/DummyPageHolder.h"
+#include "wtf/OwnPtr.h"
+#include <gtest/gtest.h>
+
+using namespace WebCore;
+
+namespace {
+
+class HTMLTextFormControlElementTest : public ::testing::Test {
+protected:
+ virtual void SetUp() OVERRIDE;
+
+ HTMLTextFormControlElement& textControl() const { return *m_textControl; }
+
+private:
+ OwnPtr<DummyPageHolder> m_dummyPageHolder;
+
+ RefPtrWillBePersistent<HTMLTextFormControlElement> m_textControl;
+};
+
+void HTMLTextFormControlElementTest::SetUp()
+{
+ m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
+ HTMLDocument& document = toHTMLDocument(m_dummyPageHolder->document());
+ document.documentElement()->setInnerHTML("<body><textarea id=textarea></textarea></body>", ASSERT_NO_EXCEPTION);
+ document.view()->updateLayoutAndStyleIfNeededRecursive();
+ m_textControl = toHTMLTextFormControlElement(document.getElementById("textarea"));
+ m_textControl->focus();
+}
+
+TEST_F(HTMLTextFormControlElementTest, SetSelectionRange)
+{
+ EXPECT_EQ(0, textControl().selectionStart());
+ EXPECT_EQ(0, textControl().selectionEnd());
+
+ textControl().setInnerTextValue("Hello, text form.");
+ EXPECT_EQ(0, textControl().selectionStart());
+ EXPECT_EQ(0, textControl().selectionEnd());
+
+ textControl().setSelectionRange(1, 3);
+ EXPECT_EQ(1, textControl().selectionStart());
+ EXPECT_EQ(3, textControl().selectionEnd());
+}
+
+}
« no previous file with comments | « Source/core/core.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698