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

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: 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..b914511e5031d1c23f6cc162b80733a4f7a8b009
--- /dev/null
+++ b/Source/core/html/HTMLTextFormControlElementTest.cpp
@@ -0,0 +1,56 @@
+// 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& textform() const { return *m_textarea; }
Yuta Kitamura 2014/06/17 09:07:50 nit: The function name should be textForm().
tkent 2014/06/18 00:06:38 textControl() is better, IMO. This is not a 'form
yoichio 2014/06/18 01:36:47 Done.
+
+private:
+ OwnPtr<DummyPageHolder> m_dummyPageHolder;
+
+ RefPtr<HTMLTextFormControlElement> m_textarea;
yosin_UTC9 2014/06/17 08:45:12 nit: RefPtrWillBeRawPtr? not sure...
Yuta Kitamura 2014/06/17 09:07:50 Well, I'm not sure either, but RefPtrWillBeRawPtr
tkent 2014/06/18 00:06:38 This should be RefPtrWillBePersistent<>.
yoichio 2014/06/18 01:36:46 Done.
+};
+
+void HTMLTextFormControlElementTest::SetUp()
+{
+ m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
+ HTMLDocument* document = toHTMLDocument(&m_dummyPageHolder->document());
+ ASSERT(document);
yosin_UTC9 2014/06/17 08:45:12 nit: We don't need this ASSERT.
Yuta Kitamura 2014/06/17 09:07:50 This ASSERT is meaningless, because toHTMLDocument
yoichio 2014/06/18 01:36:46 Done.
yoichio 2014/06/18 01:36:47 Done.
+ document->documentElement()->setInnerHTML(String::fromUTF8("<body><div id=div></div><textarea id=\"textarea\"></textarea></body>"), ASSERT_NO_EXCEPTION);
yosin_UTC9 2014/06/17 08:45:12 nit: I think we don't need to have String::fromUTF
Yuta Kitamura 2014/06/17 09:07:50 nit: It's strange to use an unquoted attribute val
yoichio 2014/06/18 01:36:46 Done.
yoichio 2014/06/18 01:36:47 Done.
+ document->view()->updateLayoutAndStyleIfNeededRecursive();
+ m_textarea = toHTMLTextFormControlElement(document->getElementById("textarea"));
+ ASSERT(m_textarea);
yosin_UTC9 2014/06/17 08:45:12 nit: We don't need this ASSERT.
Yuta Kitamura 2014/06/17 09:07:50 Same as line 34, since we are sure that getElement
yoichio 2014/06/18 01:36:47 Done.
+ m_textarea->focus();
+}
+
+TEST_F(HTMLTextFormControlElementTest, SetSelectionRange)
+{
+ HTMLTextFormControlElement& form = textform();
+ EXPECT_EQ(0, form.selectionStart());
+ EXPECT_EQ(0, form.selectionEnd());
+
+ form.setInnerTextValue("Hello, text form.");
+ EXPECT_EQ(0, form.selectionStart());
+ EXPECT_EQ(0, form.selectionEnd());
+
+ form.setSelectionRange(1, 3);
+ EXPECT_EQ(1, form.selectionStart());
+ EXPECT_EQ(3, form.selectionEnd());
+}
+}
Yuta Kitamura 2014/06/17 09:07:50 nit: There is a blank line after "namespace {" (li
yoichio 2014/06/18 01:36:46 Done.
« 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