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

Unified Diff: third_party/WebKit/Source/core/html/TextControlElementTest.cpp

Issue 2716793002: Simplify TextControlElementTest.SetSelectionRangeDoesNotCaluseLayout (Closed)
Patch Set: update Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/TextControlElementTest.cpp
diff --git a/third_party/WebKit/Source/core/html/TextControlElementTest.cpp b/third_party/WebKit/Source/core/html/TextControlElementTest.cpp
index 22d78a48528e4e4c689d3daf698f4b35f4e02dd3..a502e30ca30bcd31dafba6846a894725d492ee0a 100644
--- a/third_party/WebKit/Source/core/html/TextControlElementTest.cpp
+++ b/third_party/WebKit/Source/core/html/TextControlElementTest.cpp
@@ -27,9 +27,6 @@ class TextControlElementTest : public ::testing::Test {
TextControlElement& textControl() const { return *m_textControl; }
HTMLInputElement& input() const { return *m_input; }
- int layoutCount() const { return page().frameView().layoutCount(); }
- void forceLayoutFlag();
-
private:
std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
@@ -52,15 +49,6 @@ void TextControlElementTest::SetUp() {
m_input = toHTMLInputElement(m_document->getElementById("input"));
}
-void TextControlElementTest::forceLayoutFlag() {
- FrameView& frameView = page().frameView();
- IntRect frameRect = frameView.frameRect();
- frameRect.setWidth(frameRect.width() + 1);
- frameRect.setHeight(frameRect.height() + 1);
- page().frameView().setFrameRect(frameRect);
- document().updateStyleAndLayoutIgnorePendingStylesheets();
-}
-
TEST_F(TextControlElementTest, SetSelectionRange) {
EXPECT_EQ(0u, textControl().selectionStart());
EXPECT_EQ(0u, textControl().selectionEnd());
@@ -78,24 +66,14 @@ TEST_F(TextControlElementTest, SetSelectionRangeDoesNotCauseLayout) {
input().focus();
input().setValue("Hello, input form.");
input().setSelectionRange(1, 1);
- FrameSelection& frameSelection = document().frame()->selection();
- forceLayoutFlag();
- LayoutRect oldCaretRect(frameSelection.absoluteCaretBounds());
- EXPECT_FALSE(oldCaretRect.isEmpty());
- int startLayoutCount = layoutCount();
- input().setSelectionRange(1, 1);
- EXPECT_EQ(startLayoutCount, layoutCount());
- LayoutRect newCaretRect(frameSelection.absoluteCaretBounds());
- EXPECT_EQ(oldCaretRect, newCaretRect);
-
- forceLayoutFlag();
- oldCaretRect = LayoutRect(frameSelection.absoluteCaretBounds());
- EXPECT_FALSE(oldCaretRect.isEmpty());
- startLayoutCount = layoutCount();
+
+ // Force layout if document().updateStyleAndLayoutIgnorePendingStylesheets()
+ // is called.
+ document().body()->appendChild(document().createTextNode("foo"));
+ const int startLayoutCount = page().frameView().layoutCount();
+ EXPECT_TRUE(document().needsLayoutTreeUpdate());
input().setSelectionRange(2, 2);
- EXPECT_EQ(startLayoutCount, layoutCount());
- newCaretRect = LayoutRect(frameSelection.absoluteCaretBounds());
- EXPECT_NE(oldCaretRect, newCaretRect);
+ EXPECT_EQ(startLayoutCount, page().frameView().layoutCount());
}
TEST_F(TextControlElementTest, IndexForPosition) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698