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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/core/core.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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& textControl() const { return *m_textControl; }
23
24 private:
25 OwnPtr<DummyPageHolder> m_dummyPageHolder;
26
27 RefPtrWillBePersistent<HTMLTextFormControlElement> m_textControl;
28 };
29
30 void HTMLTextFormControlElementTest::SetUp()
31 {
32 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
33 HTMLDocument& document = toHTMLDocument(m_dummyPageHolder->document());
34 document.documentElement()->setInnerHTML("<body><textarea id=textarea></text area></body>", ASSERT_NO_EXCEPTION);
35 document.view()->updateLayoutAndStyleIfNeededRecursive();
36 m_textControl = toHTMLTextFormControlElement(document.getElementById("textar ea"));
37 m_textControl->focus();
38 }
39
40 TEST_F(HTMLTextFormControlElementTest, SetSelectionRange)
41 {
42 EXPECT_EQ(0, textControl().selectionStart());
43 EXPECT_EQ(0, textControl().selectionEnd());
44
45 textControl().setInnerTextValue("Hello, text form.");
46 EXPECT_EQ(0, textControl().selectionStart());
47 EXPECT_EQ(0, textControl().selectionEnd());
48
49 textControl().setSelectionRange(1, 3);
50 EXPECT_EQ(1, textControl().selectionStart());
51 EXPECT_EQ(3, textControl().selectionEnd());
52 }
53
54 }
OLDNEW
« 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