Chromium Code Reviews| Index: Source/core/html/HTMLTextFormControlElementTest.cpp |
| diff --git a/Source/core/html/HTMLTextFormControlElementTest.cpp b/Source/core/html/HTMLTextFormControlElementTest.cpp |
| index 5ac92f8325c2ef0a1593833e244e63404f77ec97..f86e9d73dbaa56928e90d96d57b9fc62e4ebea9d 100644 |
| --- a/Source/core/html/HTMLTextFormControlElementTest.cpp |
| +++ b/Source/core/html/HTMLTextFormControlElementTest.cpp |
| @@ -34,13 +34,17 @@ protected: |
| DummyPageHolder& page() const { return *m_dummyPageHolder; } |
| HTMLDocument& document() const { return *m_document; } |
| HTMLTextFormControlElement& textControl() const { return *m_textControl; } |
| + HTMLInputElement& input() const { return *m_input; } |
| + int layoutCount() const { return page().frameView().layoutCount(); } |
| + void forceLayoutFlag(); |
| private: |
|
tkent
2014/07/29 09:30:20
nit: We put one blank line before private:.
yoichio
2014/07/29 10:32:46
Done.
|
| OwnPtr<SpellCheckerClient> m_spellCheckerClient; |
| OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| RefPtrWillBePersistent<HTMLDocument> m_document; |
| RefPtrWillBePersistent<HTMLTextFormControlElement> m_textControl; |
| + RefPtrWillBePersistent<HTMLInputElement> m_input; |
| }; |
| class DummyTextCheckerClient : public EmptyTextCheckerClient { |
| @@ -76,6 +80,16 @@ void HTMLTextFormControlElementTest::SetUp() |
| m_document->view()->updateLayoutAndStyleIfNeededRecursive(); |
| m_textControl = toHTMLTextFormControlElement(m_document->getElementById("textarea")); |
| m_textControl->focus(); |
| + m_input = toHTMLInputElement(m_document->getElementById("input")); |
| +} |
| + |
| +void HTMLTextFormControlElementTest::forceLayoutFlag() |
| +{ |
| + FrameView& frameView = page().frameView(); |
| + IntRect frameRect = frameView.frameRect(); |
| + frameRect.setWidth(frameRect.width() + 1); |
| + frameRect.setHeight(frameRect.height() + 1); |
| + page().frameView().setFrameRect(frameRect); |
| } |
| TEST_F(HTMLTextFormControlElementTest, SetSelectionRange) |
| @@ -92,6 +106,19 @@ TEST_F(HTMLTextFormControlElementTest, SetSelectionRange) |
| EXPECT_EQ(3, textControl().selectionEnd()); |
| } |
| +TEST_F(HTMLTextFormControlElementTest, FrameSelectionLocalCaretRectDoesNotCauseLayout) |
| +{ |
| + input().focus(); |
| + input().setValue("Hello, input form."); |
| + FrameSelection& frameSelection = document().frame()->selection(); |
| + frameSelection.setCaretRectNeedsUpdate(); |
| + |
| + forceLayoutFlag(); |
| + int startLayoutCount = layoutCount(); |
| + frameSelection.localCaretRect(); |
| + EXPECT_EQ(startLayoutCount, layoutCount()); |
| +} |
| + |
| typedef Position (*PositionFunction)(const Position&); |
| typedef VisiblePosition(*VisblePositionFunction)(const VisiblePosition&); |
| @@ -178,10 +205,10 @@ TEST_F(HTMLTextFormControlElementTest, SpellCheckDoesNotCauseUpdateLayout) |
| ASSERT_EQ(3, input->selectionStart()); |
| OwnPtr<SpellChecker> spellChecker(SpellChecker::create(page().frame())); |
| - page().frameView().setFrameRect(IntRect(0, 0, 801, 601)); |
| - int startCount = page().frameView().layoutCount(); |
| + forceLayoutFlag(); |
| + int startCount = layoutCount(); |
| spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle); |
| - EXPECT_EQ(startCount, page().frameView().layoutCount()); |
| + EXPECT_EQ(startCount, layoutCount()); |
| } |
| } |