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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 EXPECT_EQ(1, GetCurrentIndex()); | 328 EXPECT_EQ(1, GetCurrentIndex()); |
329 | 329 |
330 aura::Window* content = web_contents->GetView()->GetContentNativeView(); | 330 aura::Window* content = web_contents->GetView()->GetContentNativeView(); |
331 aura::WindowEventDispatcher* dispatcher = content->GetDispatcher(); | 331 aura::WindowEventDispatcher* dispatcher = content->GetDispatcher(); |
332 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 332 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
333 | 333 |
334 base::TimeDelta timestamp; | 334 base::TimeDelta timestamp; |
335 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 335 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
336 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), | 336 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), |
337 0, timestamp); | 337 0, timestamp); |
338 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 338 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); |
339 EXPECT_EQ(1, GetCurrentIndex()); | 339 EXPECT_EQ(1, GetCurrentIndex()); |
340 | 340 |
341 timestamp += base::TimeDelta::FromMilliseconds(10); | 341 timestamp += base::TimeDelta::FromMilliseconds(10); |
342 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, | 342 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, |
343 gfx::Point(bounds.right() - 10, bounds.y() + 5), | 343 gfx::Point(bounds.right() - 10, bounds.y() + 5), |
344 0, timestamp); | 344 0, timestamp); |
345 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); | 345 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move1); |
346 EXPECT_EQ(1, GetCurrentIndex()); | 346 EXPECT_EQ(1, GetCurrentIndex()); |
347 | 347 |
348 // Swipe back from the right edge, back to the left edge, back to the right | 348 // Swipe back from the right edge, back to the left edge, back to the right |
349 // edge. | 349 // edge. |
350 | 350 |
351 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { | 351 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { |
352 timestamp += base::TimeDelta::FromMilliseconds(10); | 352 timestamp += base::TimeDelta::FromMilliseconds(10); |
353 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, | 353 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, |
354 gfx::Point(x, bounds.y() + 5), | 354 gfx::Point(x, bounds.y() + 5), |
355 0, timestamp); | 355 0, timestamp); |
356 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc); | 356 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&inc); |
357 EXPECT_EQ(1, GetCurrentIndex()); | 357 EXPECT_EQ(1, GetCurrentIndex()); |
358 } | 358 } |
359 | 359 |
360 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { | 360 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { |
361 timestamp += base::TimeDelta::FromMilliseconds(10); | 361 timestamp += base::TimeDelta::FromMilliseconds(10); |
362 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, | 362 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, |
363 gfx::Point(x, bounds.y() + 5), | 363 gfx::Point(x, bounds.y() + 5), |
364 0, timestamp); | 364 0, timestamp); |
365 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc); | 365 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&inc); |
366 EXPECT_EQ(1, GetCurrentIndex()); | 366 EXPECT_EQ(1, GetCurrentIndex()); |
367 } | 367 } |
368 | 368 |
369 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { | 369 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { |
370 timestamp += base::TimeDelta::FromMilliseconds(10); | 370 timestamp += base::TimeDelta::FromMilliseconds(10); |
371 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, | 371 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, |
372 gfx::Point(x, bounds.y() + 5), | 372 gfx::Point(x, bounds.y() + 5), |
373 0, timestamp); | 373 0, timestamp); |
374 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc); | 374 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&inc); |
375 EXPECT_EQ(1, GetCurrentIndex()); | 375 EXPECT_EQ(1, GetCurrentIndex()); |
376 } | 376 } |
377 | 377 |
378 // Do not end the overscroll sequence. | 378 // Do not end the overscroll sequence. |
379 } | 379 } |
380 | 380 |
381 // Tests that the page has has a screenshot when navigation happens: | 381 // Tests that the page has has a screenshot when navigation happens: |
382 // - from within the page (from a JS function) | 382 // - from within the page (from a JS function) |
383 // - interactively, when user does an overscroll gesture | 383 // - interactively, when user does an overscroll gesture |
384 // - interactively, when user navigates in history without the overscroll | 384 // - interactively, when user navigates in history without the overscroll |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 10); | 659 10); |
660 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 660 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
661 EXPECT_EQ(expected_title, actual_title); | 661 EXPECT_EQ(expected_title, actual_title); |
662 | 662 |
663 EXPECT_EQ(2, GetCurrentIndex()); | 663 EXPECT_EQ(2, GetCurrentIndex()); |
664 EXPECT_TRUE(controller.CanGoBack()); | 664 EXPECT_TRUE(controller.CanGoBack()); |
665 EXPECT_FALSE(controller.CanGoForward()); | 665 EXPECT_FALSE(controller.CanGoForward()); |
666 } | 666 } |
667 | 667 |
668 } // namespace content | 668 } // namespace content |
OLD | NEW |