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/HTMLTextFormControlElement.h" | |
| 7 | |
| 8 #include "core/frame/FrameView.h" | |
| 9 #include "core/html/HTMLDocument.h" | |
| 10 #include "core/testing/DummyPageHolder.h" | |
| 11 #include "wtf/OwnPtr.h" | |
| 12 #include <gtest/gtest.h> | |
| 13 | |
| 14 using namespace WebCore; | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 class HTMLTextFormControlElementTest : public ::testing::Test { | |
| 19 protected: | |
| 20 virtual void SetUp() OVERRIDE; | |
| 21 | |
| 22 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.
| |
| 23 | |
| 24 private: | |
| 25 OwnPtr<DummyPageHolder> m_dummyPageHolder; | |
| 26 | |
| 27 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.
| |
| 28 }; | |
| 29 | |
| 30 void HTMLTextFormControlElementTest::SetUp() | |
| 31 { | |
| 32 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | |
| 33 HTMLDocument* document = toHTMLDocument(&m_dummyPageHolder->document()); | |
| 34 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.
| |
| 35 document->documentElement()->setInnerHTML(String::fromUTF8("<body><div id=di v></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.
| |
| 36 document->view()->updateLayoutAndStyleIfNeededRecursive(); | |
| 37 m_textarea = toHTMLTextFormControlElement(document->getElementById("textarea ")); | |
| 38 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.
| |
| 39 m_textarea->focus(); | |
| 40 } | |
| 41 | |
| 42 TEST_F(HTMLTextFormControlElementTest, SetSelectionRange) | |
| 43 { | |
| 44 HTMLTextFormControlElement& form = textform(); | |
| 45 EXPECT_EQ(0, form.selectionStart()); | |
| 46 EXPECT_EQ(0, form.selectionEnd()); | |
| 47 | |
| 48 form.setInnerTextValue("Hello, text form."); | |
| 49 EXPECT_EQ(0, form.selectionStart()); | |
| 50 EXPECT_EQ(0, form.selectionEnd()); | |
| 51 | |
| 52 form.setSelectionRange(1, 3); | |
| 53 EXPECT_EQ(1, form.selectionStart()); | |
| 54 EXPECT_EQ(3, form.selectionEnd()); | |
| 55 } | |
| 56 } | |
|
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.
| |
| OLD | NEW |