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

Unified Diff: Source/core/html/HTMLTextFormControlElementTest.cpp

Issue 431983005: FrameSelection::updateApperance for caret should not cause layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: wip Created 6 years, 5 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
Index: Source/core/html/HTMLTextFormControlElementTest.cpp
diff --git a/Source/core/html/HTMLTextFormControlElementTest.cpp b/Source/core/html/HTMLTextFormControlElementTest.cpp
index 08e34078ae330e467f35f4bca5cdd3a1e3dcdea3..09df1883b4985edff384136afee68734f1bfe0eb 100644
--- a/Source/core/html/HTMLTextFormControlElementTest.cpp
+++ b/Source/core/html/HTMLTextFormControlElementTest.cpp
@@ -20,6 +20,7 @@
#include "core/page/SpellCheckerClient.h"
#include "core/rendering/RenderTreeAsText.h"
#include "core/testing/DummyPageHolder.h"
+#include "core/testing/UnitTestHelpers.h"
#include "wtf/OwnPtr.h"
#include <gtest/gtest.h>
@@ -107,35 +108,29 @@ 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());
-}
-
-TEST_F(HTMLTextFormControlElementTest, SetSameSelectionRangeDoesNotCauseLayout)
+TEST_F(HTMLTextFormControlElementTest, SetSelectionRangeDoesNotCauseLayout)
{
input().focus();
input().setValue("Hello, input form.");
input().setSelectionRange(1, 1);
FrameSelection& frameSelection = document().frame()->selection();
- LayoutRect oldCaretRect = frameSelection.localCaretRectWithoutUpdateForTesting();
- EXPECT_FALSE(oldCaretRect.isEmpty());
-
forceLayoutFlag();
+ LayoutRect oldCaretRect = frameSelection.localCaretRect();
+ EXPECT_FALSE(oldCaretRect.isEmpty());
int startLayoutCount = layoutCount();
input().setSelectionRange(1, 1);
EXPECT_EQ(startLayoutCount, layoutCount());
-
- LayoutRect newCaretRect = frameSelection.localCaretRectWithoutUpdateForTesting();
+ LayoutRect newCaretRect = frameSelection.localCaretRect();
EXPECT_EQ(oldCaretRect, newCaretRect);
+
+ forceLayoutFlag();
+ oldCaretRect = frameSelection.localCaretRect();
+ EXPECT_FALSE(oldCaretRect.isEmpty());
+ startLayoutCount = layoutCount();
+ input().setSelectionRange(2, 2);
+ EXPECT_EQ(startLayoutCount, layoutCount());
+ newCaretRect = frameSelection.localCaretRect();
+ EXPECT_NE(oldCaretRect, newCaretRect);
}
typedef Position (*PositionFunction)(const Position&);
@@ -164,7 +159,7 @@ void testBoundary(HTMLDocument& document, HTMLTextFormControlElement& textContro
for (unsigned i = 0; i < textControl.innerEditorValue().length(); i++) {
textControl.setSelectionRange(i, i);
Position position = document.frame()->selection().start();
- SCOPED_TRACE(testing::Message() << "offset " << position.deprecatedEditingOffset() << " of " << nodePositionAsStringForTesting(position.deprecatedNode()).ascii().data());
+ SCOPED_TRACE(::testing::Message() << "offset " << position.deprecatedEditingOffset() << " of " << nodePositionAsStringForTesting(position.deprecatedNode()).ascii().data());
{
SCOPED_TRACE("HTMLTextFormControlElement::startOfWord");
testFunctionEquivalence(position, HTMLTextFormControlElement::startOfWord, startOfWord);
« Source/core/editing/FrameSelection.cpp ('K') | « Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698