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

Unified Diff: third_party/WebKit/Source/web/tests/SmoothScrollTest.cpp

Issue 2935813002: "Find" scrolling should be smoothly animated. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/SmoothScrollTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/SmoothScrollTest.cpp b/third_party/WebKit/Source/web/tests/SmoothScrollTest.cpp
index 8f74a32ac1de17d5c1332c78338c4e2ff2ff3898..6c09bc08d37ff0345904139a29f0e74a83229662 100644
--- a/third_party/WebKit/Source/web/tests/SmoothScrollTest.cpp
+++ b/third_party/WebKit/Source/web/tests/SmoothScrollTest.cpp
@@ -3,10 +3,13 @@
// found in the LICENSE file.
#include "bindings/core/v8/ScrollIntoViewOptionsOrBoolean.h"
+#include "core/dom/Range.h"
+#include "core/editing/Editor.h"
#include "core/frame/ScrollIntoViewOptions.h"
#include "core/frame/ScrollToOptions.h"
#include "public/web/WebScriptSource.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "web/TextFinder.h"
#include "web/WebLocalFrameImpl.h"
#include "web/tests/sim/SimCompositor.h"
#include "web/tests/sim/SimDisplayItemList.h"
@@ -283,6 +286,30 @@ TEST_F(SmoothScrollTest, BlockAndInlineSettings) {
content->OffsetTop() + content_height - window_height);
}
+TEST_F(SmoothScrollTest, FindTriggersSmoothScroll) {
+ v8::HandleScope HandleScope(v8::Isolate::GetCurrent());
+ WebView().Resize(WebSize(800, 600));
+ SimRequest request("https://example.com/test.html", "text/html");
+ LoadURL("https://example.com/test.html");
+ request.Complete(
+ "<div id='space' style='height: 2000px'></div>"
+ "<div id='content' style='height: 2000px'>text</div>");
+
+ Range* range = GetDocument().createRange();
+ MainFrame().GetFrame()->GetEditor().FindStringAndScrollToVisible(
+ "text", range, kCaseInsensitive);
+
+ // Scrolling the container
+ Compositor().BeginFrame(); // update run_state_.
+ Compositor().BeginFrame(); // Set start_time = now.
+ Compositor().BeginFrame(0.2);
+ ASSERT_EQ(Window().scrollY(), 299);
+
+ // Finish scrolling the container
+ Compositor().BeginFrame(1);
+ ASSERT_EQ(Window().scrollY(), 1708);
+}
+
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698