1 // Copyright (c) 2012 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.
5 #include "content/browser/web_contents/web_contents_view_aura.h"
7 #include "base/command_line.h"
8 #include "base/location.h"
9 #include "base/run_loop.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/test_timeouts.h"
13 #include "base/thread_task_runner_handle.h"
14 #include "base/values.h"
16 #include "base/win/windows_version.h"
18 #include "content/browser/frame_host/navigation_controller_impl.h"
19 #include "content/browser/frame_host/navigation_entry_impl.h"
20 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
21 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
22 #include "content/browser/web_contents/web_contents_impl.h"
23 #include "content/browser/web_contents/web_contents_view.h"
24 #include "content/common/input/synthetic_web_input_event_builders.h"
25 #include "content/common/input_messages.h"
26 #include "content/common/view_messages.h"
27 #include "content/public/browser/browser_message_filter.h"
28 #include "content/public/browser/render_frame_host.h"
29 #include "content/public/browser/web_contents_delegate.h"
30 #include "content/public/browser/web_contents_observer.h"
31 #include "content/public/common/content_switches.h"
32 #include "content/public/test/browser_test_utils.h"
33 #include "content/public/test/content_browser_test.h"
34 #include "content/public/test/content_browser_test_utils.h"
35 #include "content/public/test/test_renderer_host.h"
36 #include "content/public/test/test_utils.h"
37 #include "content/shell/browser/shell.h"
38 #include "ui/aura/window.h"
39 #include "ui/aura/window_tree_host.h"
40 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
41 #include "ui/events/event_processor.h"
42 #include "ui/events/event_switches.h"
43 #include "ui/events/event_utils.h"
44 #include "ui/events/test/event_generator.h"
48 // TODO(tdresser): Find a way to avoid sleeping like this. See crbug.com/405282
50 void GiveItSomeTime() {
51 base::RunLoop run_loop
;
52 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
53 FROM_HERE
, run_loop
.QuitClosure(),
54 base::TimeDelta::FromMillisecondsD(10));
58 // WebContentsDelegate which tracks vertical overscroll updates.
59 class VerticalOverscrollTracker
: public content::WebContentsDelegate
{
61 VerticalOverscrollTracker() : count_(0), completed_(false) {}
62 ~VerticalOverscrollTracker() override
{}
64 int num_overscroll_updates() const {
68 bool overscroll_completed() const {
78 bool CanOverscrollContent() const override
{ return true; }
80 void OverscrollUpdate(float delta_y
) override
{ ++count_
; }
82 void OverscrollComplete() override
{ completed_
= true; }
87 DISALLOW_COPY_AND_ASSIGN(VerticalOverscrollTracker
);
95 // This class keeps track of the RenderViewHost whose screenshot was captured.
96 class ScreenshotTracker
: public NavigationEntryScreenshotManager
{
98 explicit ScreenshotTracker(NavigationControllerImpl
* controller
)
99 : NavigationEntryScreenshotManager(controller
),
100 screenshot_taken_for_(NULL
),
101 waiting_for_screenshots_(0) {
104 ~ScreenshotTracker() override
{}
106 RenderViewHost
* screenshot_taken_for() { return screenshot_taken_for_
; }
109 screenshot_taken_for_
= NULL
;
110 screenshot_set_
.clear();
113 void SetScreenshotInterval(int interval_ms
) {
114 SetMinScreenshotIntervalMS(interval_ms
);
117 void WaitUntilScreenshotIsReady() {
118 if (!waiting_for_screenshots_
)
120 message_loop_runner_
= new content::MessageLoopRunner
;
121 message_loop_runner_
->Run();
124 bool ScreenshotSetForEntry(NavigationEntryImpl
* entry
) const {
125 return screenshot_set_
.count(entry
) > 0;
129 // Overridden from NavigationEntryScreenshotManager:
130 void TakeScreenshotImpl(RenderViewHost
* host
,
131 NavigationEntryImpl
* entry
) override
{
132 ++waiting_for_screenshots_
;
133 screenshot_taken_for_
= host
;
134 NavigationEntryScreenshotManager::TakeScreenshotImpl(host
, entry
);
137 void OnScreenshotSet(NavigationEntryImpl
* entry
) override
{
138 --waiting_for_screenshots_
;
139 screenshot_set_
[entry
] = true;
140 NavigationEntryScreenshotManager::OnScreenshotSet(entry
);
141 if (waiting_for_screenshots_
== 0 && message_loop_runner_
.get())
142 message_loop_runner_
->Quit();
145 RenderViewHost
* screenshot_taken_for_
;
146 scoped_refptr
<content::MessageLoopRunner
> message_loop_runner_
;
147 int waiting_for_screenshots_
;
148 std::map
<NavigationEntryImpl
*, bool> screenshot_set_
;
150 DISALLOW_COPY_AND_ASSIGN(ScreenshotTracker
);
153 class NavigationWatcher
: public WebContentsObserver
{
155 explicit NavigationWatcher(WebContents
* contents
)
156 : WebContentsObserver(contents
),
158 should_quit_loop_(false) {
161 ~NavigationWatcher() override
{}
163 void WaitUntilNavigationStarts() {
166 should_quit_loop_
= true;
167 base::MessageLoop::current()->Run();
171 // Overridden from WebContentsObserver:
172 void DidStartNavigationToPendingEntry(
173 const GURL
& validated_url
,
174 NavigationController::ReloadType reload_type
) override
{
176 if (should_quit_loop_
)
177 base::MessageLoop::current()->Quit();
181 bool should_quit_loop_
;
183 DISALLOW_COPY_AND_ASSIGN(NavigationWatcher
);
186 class InputEventMessageFilterWaitsForAcks
: public BrowserMessageFilter
{
188 InputEventMessageFilterWaitsForAcks()
189 : BrowserMessageFilter(InputMsgStart
),
190 type_(blink::WebInputEvent::Undefined
),
191 state_(INPUT_EVENT_ACK_STATE_UNKNOWN
) {}
193 void WaitForAck(blink::WebInputEvent::Type type
) {
194 base::RunLoop run_loop
;
195 base::AutoReset
<base::Closure
> reset_quit(&quit_
, run_loop
.QuitClosure());
196 base::AutoReset
<blink::WebInputEvent::Type
> reset_type(&type_
, type
);
200 InputEventAckState
last_ack_state() const { return state_
; }
203 ~InputEventMessageFilterWaitsForAcks() override
{}
206 void ReceivedEventAck(blink::WebInputEvent::Type type
,
207 InputEventAckState state
) {
214 // BrowserMessageFilter:
215 bool OnMessageReceived(const IPC::Message
& message
) override
{
216 if (message
.type() == InputHostMsg_HandleInputEvent_ACK::ID
) {
217 InputHostMsg_HandleInputEvent_ACK::Param params
;
218 InputHostMsg_HandleInputEvent_ACK::Read(&message
, ¶ms
);
219 blink::WebInputEvent::Type type
= base::get
<0>(params
).type
;
220 InputEventAckState ack
= base::get
<0>(params
).state
;
221 BrowserThread::PostTask(BrowserThread::UI
, FROM_HERE
,
222 base::Bind(&InputEventMessageFilterWaitsForAcks::ReceivedEventAck
,
229 blink::WebInputEvent::Type type_
;
230 InputEventAckState state_
;
232 DISALLOW_COPY_AND_ASSIGN(InputEventMessageFilterWaitsForAcks
);
235 class WebContentsViewAuraTest
: public ContentBrowserTest
{
237 WebContentsViewAuraTest()
238 : screenshot_manager_(NULL
) {
241 // Executes the javascript synchronously and makes sure the returned value is
243 void ExecuteSyncJSFunction(RenderFrameHost
* rfh
, const std::string
& jscript
) {
244 scoped_ptr
<base::Value
> value
=
245 content::ExecuteScriptAndGetValue(rfh
, jscript
);
248 // Starts the test server and navigates to the given url. Sets a large enough
249 // size to the root window. Returns after the navigation to the url is
251 void StartTestWithPage(const std::string
& url
) {
252 ASSERT_TRUE(test_server()->Start());
253 GURL
test_url(test_server()->GetURL(url
));
254 NavigateToURL(shell(), test_url
);
256 WebContentsImpl
* web_contents
=
257 static_cast<WebContentsImpl
*>(shell()->web_contents());
258 NavigationControllerImpl
* controller
= &web_contents
->GetController();
260 screenshot_manager_
= new ScreenshotTracker(controller
);
261 controller
->SetScreenshotManager(make_scoped_ptr(screenshot_manager_
));
263 frame_watcher_
= new FrameWatcher();
264 GetRenderWidgetHost()->GetProcess()->AddFilter(frame_watcher_
.get());
267 void SetUpCommandLine(base::CommandLine
* cmd
) override
{
268 cmd
->AppendSwitchASCII(switches::kTouchEvents
,
269 switches::kTouchEventsEnabled
);
272 void TestOverscrollNavigation(bool touch_handler
) {
273 ASSERT_NO_FATAL_FAILURE(
274 StartTestWithPage("files/overscroll_navigation.html"));
275 WebContentsImpl
* web_contents
=
276 static_cast<WebContentsImpl
*>(shell()->web_contents());
277 NavigationController
& controller
= web_contents
->GetController();
278 RenderFrameHost
* main_frame
= web_contents
->GetMainFrame();
280 EXPECT_FALSE(controller
.CanGoBack());
281 EXPECT_FALSE(controller
.CanGoForward());
283 scoped_ptr
<base::Value
> value
=
284 content::ExecuteScriptAndGetValue(main_frame
, "get_current()");
285 ASSERT_TRUE(value
->GetAsInteger(&index
));
289 ExecuteSyncJSFunction(main_frame
, "install_touch_handler()");
291 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
292 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
293 value
= content::ExecuteScriptAndGetValue(main_frame
, "get_current()");
294 ASSERT_TRUE(value
->GetAsInteger(&index
));
296 EXPECT_TRUE(controller
.CanGoBack());
297 EXPECT_FALSE(controller
.CanGoForward());
299 aura::Window
* content
= web_contents
->GetContentNativeView();
300 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
301 ui::test::EventGenerator
generator(content
->GetRootWindow(), content
);
302 const int kScrollDurationMs
= 20;
303 const int kScrollSteps
= 10;
306 // Do a swipe-right now. That should navigate backwards.
307 base::string16 expected_title
= base::ASCIIToUTF16("Title: #1");
308 content::TitleWatcher
title_watcher(web_contents
, expected_title
);
309 generator
.GestureScrollSequence(
310 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
311 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
312 base::TimeDelta::FromMilliseconds(kScrollDurationMs
),
314 base::string16 actual_title
= title_watcher
.WaitAndGetTitle();
315 EXPECT_EQ(expected_title
, actual_title
);
316 value
= content::ExecuteScriptAndGetValue(main_frame
, "get_current()");
317 ASSERT_TRUE(value
->GetAsInteger(&index
));
319 EXPECT_TRUE(controller
.CanGoBack());
320 EXPECT_TRUE(controller
.CanGoForward());
324 // Do a fling-right now. That should navigate backwards.
325 base::string16 expected_title
= base::ASCIIToUTF16("Title:");
326 content::TitleWatcher
title_watcher(web_contents
, expected_title
);
327 generator
.GestureScrollSequence(
328 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
329 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
330 base::TimeDelta::FromMilliseconds(kScrollDurationMs
),
332 base::string16 actual_title
= title_watcher
.WaitAndGetTitle();
333 EXPECT_EQ(expected_title
, actual_title
);
334 value
= content::ExecuteScriptAndGetValue(main_frame
, "get_current()");
335 ASSERT_TRUE(value
->GetAsInteger(&index
));
337 EXPECT_FALSE(controller
.CanGoBack());
338 EXPECT_TRUE(controller
.CanGoForward());
342 // Do a swipe-left now. That should navigate forward.
343 base::string16 expected_title
= base::ASCIIToUTF16("Title: #1");
344 content::TitleWatcher
title_watcher(web_contents
, expected_title
);
345 generator
.GestureScrollSequence(
346 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
347 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
348 base::TimeDelta::FromMilliseconds(kScrollDurationMs
),
350 base::string16 actual_title
= title_watcher
.WaitAndGetTitle();
351 EXPECT_EQ(expected_title
, actual_title
);
352 value
= content::ExecuteScriptAndGetValue(main_frame
, "get_current()");
353 ASSERT_TRUE(value
->GetAsInteger(&index
));
355 EXPECT_TRUE(controller
.CanGoBack());
356 EXPECT_TRUE(controller
.CanGoForward());
360 int GetCurrentIndex() {
361 WebContentsImpl
* web_contents
=
362 static_cast<WebContentsImpl
*>(shell()->web_contents());
363 RenderFrameHost
* main_frame
= web_contents
->GetMainFrame();
365 scoped_ptr
<base::Value
> value
;
366 value
= content::ExecuteScriptAndGetValue(main_frame
, "get_current()");
367 if (!value
->GetAsInteger(&index
))
372 int ExecuteScriptAndExtractInt(const std::string
& script
) {
374 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
375 shell()->web_contents(),
376 "domAutomationController.send(" + script
+ ")",
381 RenderViewHost
* GetRenderViewHost() const {
382 RenderViewHost
* const rvh
= shell()->web_contents()->GetRenderViewHost();
387 RenderWidgetHostImpl
* GetRenderWidgetHost() const {
388 RenderWidgetHostImpl
* const rwh
=
389 RenderWidgetHostImpl::From(shell()
391 ->GetRenderWidgetHostView()
392 ->GetRenderWidgetHost());
397 RenderWidgetHostViewBase
* GetRenderWidgetHostView() const {
398 return static_cast<RenderWidgetHostViewBase
*>(
399 GetRenderViewHost()->GetView());
402 InputEventMessageFilterWaitsForAcks
* filter() {
403 return filter_
.get();
407 while (!GetRenderWidgetHost()->ScheduleComposite())
409 frame_watcher_
->WaitFrames(1);
413 ScreenshotTracker
* screenshot_manager() { return screenshot_manager_
; }
414 void set_min_screenshot_interval(int interval_ms
) {
415 screenshot_manager_
->SetScreenshotInterval(interval_ms
);
418 void AddInputEventMessageFilter() {
419 filter_
= new InputEventMessageFilterWaitsForAcks();
420 GetRenderWidgetHost()->GetProcess()->AddFilter(filter_
.get());
424 ScreenshotTracker
* screenshot_manager_
;
425 scoped_refptr
<InputEventMessageFilterWaitsForAcks
> filter_
;
426 scoped_refptr
<FrameWatcher
> frame_watcher_
;
428 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAuraTest
);
431 // Flaky on Windows: http://crbug.com/305722
432 // The test frequently times out on Linux, too. See crbug.com/440043.
433 #if defined(OS_WIN) || defined(OS_LINUX)
434 #define MAYBE_OverscrollNavigation DISABLED_OverscrollNavigation
436 #define MAYBE_OverscrollNavigation OverscrollNavigation
439 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
, MAYBE_OverscrollNavigation
) {
440 TestOverscrollNavigation(false);
443 // Flaky on Windows (might be related to the above test):
444 // http://crbug.com/305722
445 // On Linux, the test frequently times out. (See crbug.com/440043).
446 #if defined(OS_WIN) || defined(OS_LINUX)
447 #define MAYBE_OverscrollNavigationWithTouchHandler \
448 DISABLED_OverscrollNavigationWithTouchHandler
450 #define MAYBE_OverscrollNavigationWithTouchHandler \
451 OverscrollNavigationWithTouchHandler
453 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
,
454 MAYBE_OverscrollNavigationWithTouchHandler
) {
455 TestOverscrollNavigation(true);
458 // Disabled because the test always fails the first time it runs on the Win Aura
459 // bots, and usually but not always passes second-try (See crbug.com/179532).
460 // On Linux, the test frequently times out. (See crbug.com/440043).
461 #if defined(OS_WIN) || defined(OS_LINUX)
462 #define MAYBE_QuickOverscrollDirectionChange \
463 DISABLED_QuickOverscrollDirectionChange
465 #define MAYBE_QuickOverscrollDirectionChange QuickOverscrollDirectionChange
467 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
,
468 MAYBE_QuickOverscrollDirectionChange
) {
469 ASSERT_NO_FATAL_FAILURE(
470 StartTestWithPage("files/overscroll_navigation.html"));
471 WebContentsImpl
* web_contents
=
472 static_cast<WebContentsImpl
*>(shell()->web_contents());
473 RenderFrameHost
* main_frame
= web_contents
->GetMainFrame();
475 // This test triggers a large number of animations. Speed them up to ensure
476 // the test completes within its time limit.
477 ui::ScopedAnimationDurationScaleMode
fast_duration_mode(
478 ui::ScopedAnimationDurationScaleMode::FAST_DURATION
);
480 // Make sure the page has both back/forward history.
481 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
482 EXPECT_EQ(1, GetCurrentIndex());
483 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
484 EXPECT_EQ(2, GetCurrentIndex());
485 web_contents
->GetController().GoBack();
486 EXPECT_EQ(1, GetCurrentIndex());
488 aura::Window
* content
= web_contents
->GetContentNativeView();
489 ui::EventProcessor
* dispatcher
= content
->GetHost()->event_processor();
490 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
492 base::TimeDelta timestamp
= ui::EventTimeForNow();
493 ui::TouchEvent
press(ui::ET_TOUCH_PRESSED
,
494 gfx::Point(bounds
.x() + bounds
.width() / 2, bounds
.y() + 5),
496 ui::EventDispatchDetails details
= dispatcher
->OnEventFromSource(&press
);
497 ASSERT_FALSE(details
.dispatcher_destroyed
);
498 EXPECT_EQ(1, GetCurrentIndex());
500 timestamp
+= base::TimeDelta::FromMilliseconds(10);
501 ui::TouchEvent
move1(ui::ET_TOUCH_MOVED
,
502 gfx::Point(bounds
.right() - 10, bounds
.y() + 5),
504 details
= dispatcher
->OnEventFromSource(&move1
);
505 ASSERT_FALSE(details
.dispatcher_destroyed
);
506 EXPECT_EQ(1, GetCurrentIndex());
508 // Swipe back from the right edge, back to the left edge, back to the right
511 for (int x
= bounds
.right() - 10; x
>= bounds
.x() + 10; x
-= 10) {
512 timestamp
+= base::TimeDelta::FromMilliseconds(10);
513 ui::TouchEvent
inc(ui::ET_TOUCH_MOVED
,
514 gfx::Point(x
, bounds
.y() + 5),
516 details
= dispatcher
->OnEventFromSource(&inc
);
517 ASSERT_FALSE(details
.dispatcher_destroyed
);
518 EXPECT_EQ(1, GetCurrentIndex());
521 for (int x
= bounds
.x() + 10; x
<= bounds
.width() - 10; x
+= 10) {
522 timestamp
+= base::TimeDelta::FromMilliseconds(10);
523 ui::TouchEvent
inc(ui::ET_TOUCH_MOVED
,
524 gfx::Point(x
, bounds
.y() + 5),
526 details
= dispatcher
->OnEventFromSource(&inc
);
527 ASSERT_FALSE(details
.dispatcher_destroyed
);
528 EXPECT_EQ(1, GetCurrentIndex());
531 for (int x
= bounds
.width() - 10; x
>= bounds
.x() + 10; x
-= 10) {
532 timestamp
+= base::TimeDelta::FromMilliseconds(10);
533 ui::TouchEvent
inc(ui::ET_TOUCH_MOVED
,
534 gfx::Point(x
, bounds
.y() + 5),
536 details
= dispatcher
->OnEventFromSource(&inc
);
537 ASSERT_FALSE(details
.dispatcher_destroyed
);
538 EXPECT_EQ(1, GetCurrentIndex());
541 // Do not end the overscroll sequence.
544 // Tests that the page has has a screenshot when navigation happens:
545 // - from within the page (from a JS function)
546 // - interactively, when user does an overscroll gesture
547 // - interactively, when user navigates in history without the overscroll
549 // Flaky on Windows (http://crbug.com/357311). Might be related to
550 // OverscrollNavigation test.
551 // Flaky on Ozone (http://crbug.com/399676).
552 // Flaky on ChromeOS (http://crbug.com/405945).
553 #if defined(OS_WIN) || defined(USE_OZONE) || defined(OS_CHROMEOS)
554 #define MAYBE_OverscrollScreenshot DISABLED_OverscrollScreenshot
556 #define MAYBE_OverscrollScreenshot OverscrollScreenshot
558 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
, MAYBE_OverscrollScreenshot
) {
559 // Disable the test for WinXP. See http://crbug/294116.
561 if (base::win::GetVersion() < base::win::VERSION_VISTA
) {
562 LOG(WARNING
) << "Test disabled due to unknown bug on WinXP.";
567 ASSERT_NO_FATAL_FAILURE(
568 StartTestWithPage("files/overscroll_navigation.html"));
569 WebContentsImpl
* web_contents
=
570 static_cast<WebContentsImpl
*>(shell()->web_contents());
571 RenderFrameHost
* main_frame
= web_contents
->GetMainFrame();
573 set_min_screenshot_interval(0);
575 // Do a few navigations initiated by the page.
576 // Screenshots should never be captured since these are all in-page
578 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
579 EXPECT_EQ(1, GetCurrentIndex());
580 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
581 EXPECT_EQ(2, GetCurrentIndex());
582 screenshot_manager()->WaitUntilScreenshotIsReady();
584 NavigationEntryImpl
* entry
= web_contents
->GetController().GetEntryAtIndex(2);
585 EXPECT_FALSE(entry
->screenshot().get());
587 entry
= web_contents
->GetController().GetEntryAtIndex(1);
588 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry
));
590 entry
= web_contents
->GetController().GetEntryAtIndex(0);
591 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry
));
593 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
594 screenshot_manager()->WaitUntilScreenshotIsReady();
596 entry
= web_contents
->GetController().GetEntryAtIndex(2);
597 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry
));
599 entry
= web_contents
->GetController().GetEntryAtIndex(3);
600 EXPECT_FALSE(entry
->screenshot().get());
602 // Now, swipe right to navigate backwards. This should navigate away from
603 // index 3 to index 2.
604 base::string16 expected_title
= base::ASCIIToUTF16("Title: #2");
605 content::TitleWatcher
title_watcher(web_contents
, expected_title
);
606 aura::Window
* content
= web_contents
->GetContentNativeView();
607 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
608 ui::test::EventGenerator
generator(content
->GetRootWindow(), content
);
609 generator
.GestureScrollSequence(
610 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
611 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
612 base::TimeDelta::FromMilliseconds(20),
614 base::string16 actual_title
= title_watcher
.WaitAndGetTitle();
615 EXPECT_EQ(expected_title
, actual_title
);
616 EXPECT_EQ(2, GetCurrentIndex());
617 screenshot_manager()->WaitUntilScreenshotIsReady();
618 entry
= web_contents
->GetController().GetEntryAtIndex(3);
619 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry
));
622 // Navigate a couple more times.
623 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
624 EXPECT_EQ(3, GetCurrentIndex());
625 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
626 EXPECT_EQ(4, GetCurrentIndex());
627 screenshot_manager()->WaitUntilScreenshotIsReady();
628 entry
= web_contents
->GetController().GetEntryAtIndex(4);
629 EXPECT_FALSE(entry
->screenshot().get());
632 // Navigate back in history.
633 base::string16 expected_title
= base::ASCIIToUTF16("Title: #3");
634 content::TitleWatcher
title_watcher(web_contents
, expected_title
);
635 web_contents
->GetController().GoBack();
636 base::string16 actual_title
= title_watcher
.WaitAndGetTitle();
637 EXPECT_EQ(expected_title
, actual_title
);
638 EXPECT_EQ(3, GetCurrentIndex());
639 screenshot_manager()->WaitUntilScreenshotIsReady();
640 entry
= web_contents
->GetController().GetEntryAtIndex(4);
641 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry
));
645 // Crashes under ThreadSanitizer, http://crbug.com/356758.
646 #if defined(THREAD_SANITIZER)
647 #define MAYBE_ScreenshotForSwappedOutRenderViews \
648 DISABLED_ScreenshotForSwappedOutRenderViews
650 #define MAYBE_ScreenshotForSwappedOutRenderViews \
651 ScreenshotForSwappedOutRenderViews
653 // Tests that screenshot is taken correctly when navigation causes a
654 // RenderViewHost to be swapped out.
655 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
,
656 MAYBE_ScreenshotForSwappedOutRenderViews
) {
657 ASSERT_NO_FATAL_FAILURE(
658 StartTestWithPage("files/overscroll_navigation.html"));
659 // Create a new server with a different site.
660 net::SpawnedTestServer
https_server(
661 net::SpawnedTestServer::TYPE_HTTPS
,
662 net::SpawnedTestServer::kLocalhost
,
663 base::FilePath(FILE_PATH_LITERAL("content/test/data")));
664 ASSERT_TRUE(https_server
.Start());
666 WebContentsImpl
* web_contents
=
667 static_cast<WebContentsImpl
*>(shell()->web_contents());
668 set_min_screenshot_interval(0);
674 { https_server
.GetURL("files/title1.html"),
675 ui::PAGE_TRANSITION_TYPED
| ui::PAGE_TRANSITION_FROM_ADDRESS_BAR
},
676 { test_server()->GetURL("files/title2.html"),
677 ui::PAGE_TRANSITION_AUTO_BOOKMARK
},
678 { https_server
.GetURL("files/title3.html"),
679 ui::PAGE_TRANSITION_TYPED
| ui::PAGE_TRANSITION_FROM_ADDRESS_BAR
},
683 screenshot_manager()->Reset();
684 for (int i
= 0; !navigations
[i
].url
.is_empty(); ++i
) {
685 // Navigate via the user initiating a navigation from the UI.
686 NavigationController::LoadURLParams
params(navigations
[i
].url
);
687 params
.transition_type
=
688 ui::PageTransitionFromInt(navigations
[i
].transition
);
690 RenderViewHost
* old_host
= web_contents
->GetRenderViewHost();
691 web_contents
->GetController().LoadURLWithParams(params
);
692 WaitForLoadStop(web_contents
);
693 screenshot_manager()->WaitUntilScreenshotIsReady();
695 EXPECT_NE(old_host
, web_contents
->GetRenderViewHost())
696 << navigations
[i
].url
.spec();
697 EXPECT_EQ(old_host
, screenshot_manager()->screenshot_taken_for());
699 NavigationEntryImpl
* entry
=
700 web_contents
->GetController().GetEntryAtOffset(-1);
701 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry
));
703 entry
= web_contents
->GetController().GetLastCommittedEntry();
704 EXPECT_FALSE(screenshot_manager()->ScreenshotSetForEntry(entry
));
705 EXPECT_FALSE(entry
->screenshot().get());
706 screenshot_manager()->Reset();
709 // Increase the minimum interval between taking screenshots.
710 set_min_screenshot_interval(60000);
712 // Navigate again. This should not take any screenshot because of the
713 // increased screenshot interval.
714 NavigationController::LoadURLParams
params(navigations
[0].url
);
715 params
.transition_type
= ui::PageTransitionFromInt(navigations
[0].transition
);
716 web_contents
->GetController().LoadURLWithParams(params
);
717 WaitForLoadStop(web_contents
);
718 screenshot_manager()->WaitUntilScreenshotIsReady();
720 EXPECT_EQ(NULL
, screenshot_manager()->screenshot_taken_for());
723 // Tests that navigations resulting from reloads, history.replaceState,
724 // and history.pushState do not capture screenshots.
725 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
, ReplaceStateReloadPushState
) {
726 ASSERT_NO_FATAL_FAILURE(
727 StartTestWithPage("files/overscroll_navigation.html"));
728 WebContentsImpl
* web_contents
=
729 static_cast<WebContentsImpl
*>(shell()->web_contents());
730 RenderFrameHost
* main_frame
= web_contents
->GetMainFrame();
732 set_min_screenshot_interval(0);
733 screenshot_manager()->Reset();
734 ExecuteSyncJSFunction(main_frame
, "use_replace_state()");
735 screenshot_manager()->WaitUntilScreenshotIsReady();
736 // history.replaceState shouldn't capture a screenshot
737 EXPECT_FALSE(screenshot_manager()->screenshot_taken_for());
738 screenshot_manager()->Reset();
739 web_contents
->GetController().Reload(true);
740 WaitForLoadStop(web_contents
);
741 // reloading the page shouldn't capture a screenshot
742 // TODO (mfomitchev): currently broken. Uncomment when
743 // FrameHostMsg_DidCommitProvisionalLoad_Params.was_within_same_page
744 // is populated properly when reloading the page.
745 //EXPECT_FALSE(screenshot_manager()->screenshot_taken_for());
746 screenshot_manager()->Reset();
747 ExecuteSyncJSFunction(main_frame
, "use_push_state()");
748 screenshot_manager()->WaitUntilScreenshotIsReady();
749 // pushing a state shouldn't capture a screenshot
750 // TODO (mfomitchev): currently broken. Uncomment when
751 // FrameHostMsg_DidCommitProvisionalLoad_Params.was_within_same_page
752 // is populated properly when pushState is used.
753 //EXPECT_FALSE(screenshot_manager()->screenshot_taken_for());
756 // TODO(sadrul): This test is disabled because it reparents in a way the
757 // FocusController does not support. This code would crash in
758 // a production build. It only passed prior to this revision
759 // because testing used the old FocusManager which did some
760 // different (osbolete) processing. TODO(sadrul) to figure out
761 // how this test should work that mimics production code a bit
763 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
,
764 DISABLED_ContentWindowReparent
) {
765 ASSERT_NO_FATAL_FAILURE(
766 StartTestWithPage("files/overscroll_navigation.html"));
768 scoped_ptr
<aura::Window
> window(new aura::Window(NULL
));
769 window
->Init(ui::LAYER_NOT_DRAWN
);
771 WebContentsImpl
* web_contents
=
772 static_cast<WebContentsImpl
*>(shell()->web_contents());
773 ExecuteSyncJSFunction(web_contents
->GetMainFrame(), "navigate_next()");
774 EXPECT_EQ(1, GetCurrentIndex());
776 aura::Window
* content
= web_contents
->GetContentNativeView();
777 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
778 ui::test::EventGenerator
generator(content
->GetRootWindow(), content
);
779 generator
.GestureScrollSequence(
780 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
781 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
782 base::TimeDelta::FromMilliseconds(20),
785 window
->AddChild(shell()->web_contents()->GetContentNativeView());
788 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
, ContentWindowClose
) {
789 ASSERT_NO_FATAL_FAILURE(
790 StartTestWithPage("files/overscroll_navigation.html"));
792 WebContentsImpl
* web_contents
=
793 static_cast<WebContentsImpl
*>(shell()->web_contents());
794 ExecuteSyncJSFunction(web_contents
->GetMainFrame(), "navigate_next()");
795 EXPECT_EQ(1, GetCurrentIndex());
797 aura::Window
* content
= web_contents
->GetContentNativeView();
798 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
799 ui::test::EventGenerator
generator(content
->GetRootWindow(), content
);
800 generator
.GestureScrollSequence(
801 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
802 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
803 base::TimeDelta::FromMilliseconds(20),
806 delete web_contents
->GetContentNativeView();
810 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
811 // This appears to be flaky in the same was as the other overscroll
812 // tests. Enabling for non-Windows platforms.
813 // See http://crbug.com/369871.
814 // For linux, see http://crbug.com/381294
815 #define MAYBE_RepeatedQuickOverscrollGestures DISABLED_RepeatedQuickOverscrollGestures
817 #define MAYBE_RepeatedQuickOverscrollGestures RepeatedQuickOverscrollGestures
820 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
,
821 MAYBE_RepeatedQuickOverscrollGestures
) {
822 ASSERT_NO_FATAL_FAILURE(
823 StartTestWithPage("files/overscroll_navigation.html"));
825 WebContentsImpl
* web_contents
=
826 static_cast<WebContentsImpl
*>(shell()->web_contents());
827 NavigationController
& controller
= web_contents
->GetController();
828 RenderFrameHost
* main_frame
= web_contents
->GetMainFrame();
829 ExecuteSyncJSFunction(main_frame
, "install_touch_handler()");
831 // Navigate twice, then navigate back in history once.
832 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
833 ExecuteSyncJSFunction(main_frame
, "navigate_next()");
834 EXPECT_EQ(2, GetCurrentIndex());
835 EXPECT_TRUE(controller
.CanGoBack());
836 EXPECT_FALSE(controller
.CanGoForward());
838 web_contents
->GetController().GoBack();
839 WaitForLoadStop(web_contents
);
840 EXPECT_EQ(1, GetCurrentIndex());
841 EXPECT_EQ(base::ASCIIToUTF16("Title: #1"), web_contents
->GetTitle());
842 EXPECT_TRUE(controller
.CanGoBack());
843 EXPECT_TRUE(controller
.CanGoForward());
845 aura::Window
* content
= web_contents
->GetContentNativeView();
846 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
847 ui::test::EventGenerator
generator(content
->GetRootWindow(), content
);
849 // Do a swipe left to start a forward navigation. Then quickly do a swipe
851 base::string16 expected_title
= base::ASCIIToUTF16("Title: #2");
852 content::TitleWatcher
title_watcher(web_contents
, expected_title
);
853 NavigationWatcher
nav_watcher(web_contents
);
855 generator
.GestureScrollSequence(
856 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
857 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
858 base::TimeDelta::FromMilliseconds(2000),
860 nav_watcher
.WaitUntilNavigationStarts();
862 generator
.GestureScrollSequence(
863 gfx::Point(bounds
.x() + 2, bounds
.y() + 10),
864 gfx::Point(bounds
.right() - 10, bounds
.y() + 10),
865 base::TimeDelta::FromMilliseconds(2000),
867 base::string16 actual_title
= title_watcher
.WaitAndGetTitle();
868 EXPECT_EQ(expected_title
, actual_title
);
870 EXPECT_EQ(2, GetCurrentIndex());
871 EXPECT_TRUE(controller
.CanGoBack());
872 EXPECT_FALSE(controller
.CanGoForward());
875 // Verify that hiding a parent of the renderer will hide the content too.
876 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
, HideContentOnParenHide
) {
877 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/title1.html"));
878 WebContentsImpl
* web_contents
=
879 static_cast<WebContentsImpl
*>(shell()->web_contents());
880 aura::Window
* content
= web_contents
->GetNativeView()->parent();
881 EXPECT_TRUE(web_contents
->should_normally_be_visible());
883 EXPECT_FALSE(web_contents
->should_normally_be_visible());
885 EXPECT_TRUE(web_contents
->should_normally_be_visible());
888 // Ensure that SnapToPhysicalPixelBoundary() is called on WebContentsView parent
889 // change. This is a regression test for http://crbug.com/388908.
890 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
, WebContentsViewReparent
) {
891 ASSERT_NO_FATAL_FAILURE(
892 StartTestWithPage("files/overscroll_navigation.html"));
894 scoped_ptr
<aura::Window
> window(new aura::Window(NULL
));
895 window
->Init(ui::LAYER_NOT_DRAWN
);
897 RenderWidgetHostViewAura
* rwhva
=
898 static_cast<RenderWidgetHostViewAura
*>(
899 shell()->web_contents()->GetRenderWidgetHostView());
900 rwhva
->ResetHasSnappedToBoundary();
901 EXPECT_FALSE(rwhva
->has_snapped_to_boundary());
902 window
->AddChild(shell()->web_contents()->GetNativeView());
903 EXPECT_TRUE(rwhva
->has_snapped_to_boundary());
906 // Flaky on some platforms, likely for the same reason as other flaky overscroll
907 // tests. http://crbug.com/305722
908 // TODO(tdresser): Re-enable this once eager GR is back on. See
910 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
911 #define MAYBE_OverscrollNavigationTouchThrottling \
912 DISABLED_OverscrollNavigationTouchThrottling
914 #define MAYBE_OverscrollNavigationTouchThrottling \
915 DISABLED_OverscrollNavigationTouchThrottling
918 // Tests that touch moves are not throttled when performing a scroll gesture on
919 // a non-scrollable area, except during gesture-nav.
920 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
,
921 MAYBE_OverscrollNavigationTouchThrottling
) {
922 ASSERT_NO_FATAL_FAILURE(
923 StartTestWithPage("files/overscroll_navigation.html"));
925 AddInputEventMessageFilter();
927 WebContentsImpl
* web_contents
=
928 static_cast<WebContentsImpl
*>(shell()->web_contents());
929 aura::Window
* content
= web_contents
->GetContentNativeView();
930 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
933 ExecuteSyncJSFunction(web_contents
->GetMainFrame(),
934 "install_touchmove_handler()");
938 for (int navigated
= 0; navigated
<= 1; ++navigated
) {
940 ExecuteSyncJSFunction(web_contents
->GetMainFrame(), "navigate_next()");
941 ExecuteSyncJSFunction(web_contents
->GetMainFrame(),
942 "reset_touchmove_count()");
945 SyntheticWebTouchEvent touch
;
946 touch
.PressPoint(bounds
.x() + 2, bounds
.y() + 10);
947 GetRenderWidgetHost()->ForwardTouchEventWithLatencyInfo(touch
,
949 filter()->WaitForAck(blink::WebInputEvent::TouchStart
);
952 // Assert on the ack, because we'll end up waiting for acks that will never
953 // come if this is not true.
954 ASSERT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED
, filter()->last_ack_state());
956 // Send first touch move, and then a scroll begin.
957 touch
.MovePoint(0, bounds
.x() + 20 + 1 * dx
, bounds
.y() + 100);
958 GetRenderWidgetHost()->ForwardTouchEventWithLatencyInfo(touch
,
960 filter()->WaitForAck(blink::WebInputEvent::TouchMove
);
961 ASSERT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED
, filter()->last_ack_state());
963 blink::WebGestureEvent scroll_begin
=
964 SyntheticWebGestureEventBuilder::BuildScrollBegin(1, 1);
965 GetRenderWidgetHost()->ForwardGestureEventWithLatencyInfo(
966 scroll_begin
, ui::LatencyInfo());
967 // Scroll begin ignores ack disposition, so don't wait for the ack.
970 // First touchmove already sent, start at 2.
971 for (int i
= 2; i
<= 10; ++i
) {
972 // Send a touch move, followed by a scroll update
973 touch
.MovePoint(0, bounds
.x() + 20 + i
* dx
, bounds
.y() + 100);
974 GetRenderWidgetHost()->ForwardTouchEventWithLatencyInfo(
975 touch
, ui::LatencyInfo());
978 blink::WebGestureEvent scroll_update
=
979 SyntheticWebGestureEventBuilder::BuildScrollUpdate(
980 dx
, 5, 0, blink::WebGestureDeviceTouchscreen
);
982 GetRenderWidgetHost()->ForwardGestureEventWithLatencyInfo(
983 scroll_update
, ui::LatencyInfo());
988 touch
.ReleasePoint(0);
989 GetRenderWidgetHost()->ForwardTouchEventWithLatencyInfo(touch
,
993 blink::WebGestureEvent scroll_end
;
994 scroll_end
.type
= blink::WebInputEvent::GestureScrollEnd
;
995 GetRenderWidgetHost()->ForwardGestureEventWithLatencyInfo(
996 scroll_end
, ui::LatencyInfo());
1000 EXPECT_EQ(10, ExecuteScriptAndExtractInt("touchmoveCount"));
1002 EXPECT_GT(10, ExecuteScriptAndExtractInt("touchmoveCount"));
1006 // Test that vertical overscroll updates are sent only when a user overscrolls
1009 #define MAYBE_VerticalOverscroll DISABLED_VerticalOverscroll
1011 #define MAYBE_VerticalOverscroll VerticalOverscroll
1014 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest
, MAYBE_VerticalOverscroll
) {
1015 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
1016 switches::kScrollEndEffect
, "1");
1018 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("about:blank"));
1019 WebContentsImpl
* web_contents
=
1020 static_cast<WebContentsImpl
*>(shell()->web_contents());
1021 VerticalOverscrollTracker tracker
;
1022 web_contents
->SetDelegate(&tracker
);
1024 // This test triggers a large number of animations. Speed them up to ensure
1025 // the test completes within its time limit.
1026 ui::ScopedAnimationDurationScaleMode
fast_duration_mode(
1027 ui::ScopedAnimationDurationScaleMode::FAST_DURATION
);
1029 aura::Window
* content
= web_contents
->GetContentNativeView();
1030 ui::EventProcessor
* dispatcher
= content
->GetHost()->event_processor();
1031 gfx::Rect bounds
= content
->GetBoundsInRootWindow();
1033 // Overscroll horizontally.
1035 int kXStep
= bounds
.width() / 10;
1036 gfx::Point
location(bounds
.right() - kXStep
, bounds
.y() + 5);
1037 base::TimeDelta timestamp
= ui::EventTimeForNow();
1038 ui::TouchEvent
press(
1039 ui::ET_TOUCH_PRESSED
,
1043 ui::EventDispatchDetails details
= dispatcher
->OnEventFromSource(&press
);
1044 ASSERT_FALSE(details
.dispatcher_destroyed
);
1046 location
-= gfx::Vector2d(kXStep
, 0);
1047 timestamp
+= base::TimeDelta::FromMilliseconds(10);
1049 while (location
.x() > bounds
.x() + kXStep
) {
1050 ui::TouchEvent
inc(ui::ET_TOUCH_MOVED
, location
, 0, timestamp
);
1051 details
= dispatcher
->OnEventFromSource(&inc
);
1052 ASSERT_FALSE(details
.dispatcher_destroyed
);
1054 location
-= gfx::Vector2d(10, 0);
1055 timestamp
+= base::TimeDelta::FromMilliseconds(10);
1058 ui::TouchEvent
release(ui::ET_TOUCH_RELEASED
, location
, 0, timestamp
);
1059 details
= dispatcher
->OnEventFromSource(&release
);
1060 ASSERT_FALSE(details
.dispatcher_destroyed
);
1063 EXPECT_EQ(0, tracker
.num_overscroll_updates());
1064 EXPECT_FALSE(tracker
.overscroll_completed());
1067 // Overscroll vertically.
1071 int kYStep
= bounds
.height() / 10;
1072 gfx::Point
location(bounds
.x() + 10, bounds
.y() + kYStep
);
1073 base::TimeDelta timestamp
= ui::EventTimeForNow();
1074 ui::TouchEvent
press(
1075 ui::ET_TOUCH_PRESSED
,
1079 ui::EventDispatchDetails details
= dispatcher
->OnEventFromSource(&press
);
1080 ASSERT_FALSE(details
.dispatcher_destroyed
);
1082 location
+= gfx::Vector2d(0, kYStep
);
1083 timestamp
+= base::TimeDelta::FromMilliseconds(10);
1085 while (location
.y() < bounds
.bottom() - kYStep
) {
1086 ui::TouchEvent
inc(ui::ET_TOUCH_MOVED
, location
, 0, timestamp
);
1087 details
= dispatcher
->OnEventFromSource(&inc
);
1088 ASSERT_FALSE(details
.dispatcher_destroyed
);
1090 location
+= gfx::Vector2d(0, kYStep
);
1091 timestamp
+= base::TimeDelta::FromMilliseconds(10);
1094 ui::TouchEvent
release(ui::ET_TOUCH_RELEASED
, location
, 0, timestamp
);
1095 details
= dispatcher
->OnEventFromSource(&release
);
1096 ASSERT_FALSE(details
.dispatcher_destroyed
);
1099 EXPECT_LT(0, tracker
.num_overscroll_updates());
1100 EXPECT_TRUE(tracker
.overscroll_completed());
1103 // Start out overscrolling vertically, then switch directions and finish
1104 // overscrolling horizontally.
1108 int kXStep
= bounds
.width() / 10;
1109 int kYStep
= bounds
.height() / 10;
1110 gfx::Point location
= bounds
.origin() + gfx::Vector2d(0, kYStep
);
1111 base::TimeDelta timestamp
= ui::EventTimeForNow();
1112 ui::TouchEvent
press(
1113 ui::ET_TOUCH_PRESSED
,
1117 ui::EventDispatchDetails details
= dispatcher
->OnEventFromSource(&press
);
1118 ASSERT_FALSE(details
.dispatcher_destroyed
);
1120 location
+= gfx::Vector2d(0, kYStep
);
1121 timestamp
+= base::TimeDelta::FromMilliseconds(10);
1123 for (size_t i
= 0; i
< 3; ++i
) {
1124 ui::TouchEvent
inc(ui::ET_TOUCH_MOVED
, location
, 0, timestamp
);
1125 details
= dispatcher
->OnEventFromSource(&inc
);
1126 ASSERT_FALSE(details
.dispatcher_destroyed
);
1128 location
+= gfx::Vector2d(0, kYStep
);
1129 timestamp
+= base::TimeDelta::FromMilliseconds(10);
1132 while (location
.x() < bounds
.right() - kXStep
) {
1133 ui::TouchEvent
inc(ui::ET_TOUCH_MOVED
, location
, 0, timestamp
);
1134 details
= dispatcher
->OnEventFromSource(&inc
);
1135 ASSERT_FALSE(details
.dispatcher_destroyed
);
1137 location
+= gfx::Vector2d(kXStep
, 0);
1138 timestamp
+= base::TimeDelta::FromMilliseconds(10);
1141 ui::TouchEvent
release(ui::ET_TOUCH_RELEASED
, location
, 0, timestamp
);
1142 details
= dispatcher
->OnEventFromSource(&release
);
1143 ASSERT_FALSE(details
.dispatcher_destroyed
);
1146 EXPECT_LT(0, tracker
.num_overscroll_updates());
1147 EXPECT_FALSE(tracker
.overscroll_completed());
1151 } // namespace content