OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 EXPECT_EQ(1, GetCurrentIndex()); | 322 EXPECT_EQ(1, GetCurrentIndex()); |
323 | 323 |
324 aura::Window* content = web_contents->GetView()->GetContentNativeView(); | 324 aura::Window* content = web_contents->GetView()->GetContentNativeView(); |
325 aura::WindowEventDispatcher* dispatcher = content->GetDispatcher(); | 325 aura::WindowEventDispatcher* dispatcher = content->GetDispatcher(); |
326 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 326 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
327 | 327 |
328 base::TimeDelta timestamp; | 328 base::TimeDelta timestamp; |
329 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 329 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
330 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), | 330 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), |
331 0, timestamp); | 331 0, timestamp); |
332 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 332 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
| 333 ASSERT_FALSE(details.dispatcher_destroyed); |
333 EXPECT_EQ(1, GetCurrentIndex()); | 334 EXPECT_EQ(1, GetCurrentIndex()); |
334 | 335 |
335 timestamp += base::TimeDelta::FromMilliseconds(10); | 336 timestamp += base::TimeDelta::FromMilliseconds(10); |
336 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, | 337 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, |
337 gfx::Point(bounds.right() - 10, bounds.y() + 5), | 338 gfx::Point(bounds.right() - 10, bounds.y() + 5), |
338 0, timestamp); | 339 0, timestamp); |
339 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); | 340 details = dispatcher->OnEventFromSource(&move1); |
| 341 ASSERT_FALSE(details.dispatcher_destroyed); |
340 EXPECT_EQ(1, GetCurrentIndex()); | 342 EXPECT_EQ(1, GetCurrentIndex()); |
341 | 343 |
342 // Swipe back from the right edge, back to the left edge, back to the right | 344 // Swipe back from the right edge, back to the left edge, back to the right |
343 // edge. | 345 // edge. |
344 | 346 |
345 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { | 347 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { |
346 timestamp += base::TimeDelta::FromMilliseconds(10); | 348 timestamp += base::TimeDelta::FromMilliseconds(10); |
347 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, | 349 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, |
348 gfx::Point(x, bounds.y() + 5), | 350 gfx::Point(x, bounds.y() + 5), |
349 0, timestamp); | 351 0, timestamp); |
350 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&inc); | 352 details = dispatcher->OnEventFromSource(&inc); |
| 353 ASSERT_FALSE(details.dispatcher_destroyed); |
351 EXPECT_EQ(1, GetCurrentIndex()); | 354 EXPECT_EQ(1, GetCurrentIndex()); |
352 } | 355 } |
353 | 356 |
354 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { | 357 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { |
355 timestamp += base::TimeDelta::FromMilliseconds(10); | 358 timestamp += base::TimeDelta::FromMilliseconds(10); |
356 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, | 359 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, |
357 gfx::Point(x, bounds.y() + 5), | 360 gfx::Point(x, bounds.y() + 5), |
358 0, timestamp); | 361 0, timestamp); |
359 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&inc); | 362 details = dispatcher->OnEventFromSource(&inc); |
| 363 ASSERT_FALSE(details.dispatcher_destroyed); |
360 EXPECT_EQ(1, GetCurrentIndex()); | 364 EXPECT_EQ(1, GetCurrentIndex()); |
361 } | 365 } |
362 | 366 |
363 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { | 367 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { |
364 timestamp += base::TimeDelta::FromMilliseconds(10); | 368 timestamp += base::TimeDelta::FromMilliseconds(10); |
365 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, | 369 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, |
366 gfx::Point(x, bounds.y() + 5), | 370 gfx::Point(x, bounds.y() + 5), |
367 0, timestamp); | 371 0, timestamp); |
368 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&inc); | 372 details = dispatcher->OnEventFromSource(&inc); |
| 373 ASSERT_FALSE(details.dispatcher_destroyed); |
369 EXPECT_EQ(1, GetCurrentIndex()); | 374 EXPECT_EQ(1, GetCurrentIndex()); |
370 } | 375 } |
371 | 376 |
372 // Do not end the overscroll sequence. | 377 // Do not end the overscroll sequence. |
373 } | 378 } |
374 | 379 |
375 // Tests that the page has has a screenshot when navigation happens: | 380 // Tests that the page has has a screenshot when navigation happens: |
376 // - from within the page (from a JS function) | 381 // - from within the page (from a JS function) |
377 // - interactively, when user does an overscroll gesture | 382 // - interactively, when user does an overscroll gesture |
378 // - interactively, when user navigates in history without the overscroll | 383 // - interactively, when user navigates in history without the overscroll |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 10); | 658 10); |
654 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 659 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
655 EXPECT_EQ(expected_title, actual_title); | 660 EXPECT_EQ(expected_title, actual_title); |
656 | 661 |
657 EXPECT_EQ(2, GetCurrentIndex()); | 662 EXPECT_EQ(2, GetCurrentIndex()); |
658 EXPECT_TRUE(controller.CanGoBack()); | 663 EXPECT_TRUE(controller.CanGoBack()); |
659 EXPECT_FALSE(controller.CanGoForward()); | 664 EXPECT_FALSE(controller.CanGoForward()); |
660 } | 665 } |
661 | 666 |
662 } // namespace content | 667 } // namespace content |
OLD | NEW |