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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
14 #endif | 14 #endif |
15 #include "content/browser/frame_host/navigation_controller_impl.h" | 15 #include "content/browser/frame_host/navigation_controller_impl.h" |
16 #include "content/browser/frame_host/navigation_entry_impl.h" | 16 #include "content/browser/frame_host/navigation_entry_impl.h" |
17 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 17 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
18 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
19 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
20 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/browser/web_contents_view.h" | 21 #include "content/public/browser/web_contents_view.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
24 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
25 #include "content/shell/browser/shell.h" | 25 #include "content/shell/browser/shell.h" |
26 #include "content/test/content_browser_test.h" | 26 #include "content/test/content_browser_test.h" |
27 #include "content/test/content_browser_test_utils.h" | 27 #include "content/test/content_browser_test_utils.h" |
28 #include "ui/aura/test/event_generator.h" | 28 #include "ui/aura/test/event_generator.h" |
29 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
30 #include "ui/aura/window_event_dispatcher.h" | 30 #include "ui/aura/window_tree_host.h" |
31 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 31 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 32 #include "ui/events/event_processor.h" |
32 | 33 |
33 namespace content { | 34 namespace content { |
34 | 35 |
35 // This class keeps track of the RenderViewHost whose screenshot was captured. | 36 // This class keeps track of the RenderViewHost whose screenshot was captured. |
36 class ScreenshotTracker : public NavigationEntryScreenshotManager { | 37 class ScreenshotTracker : public NavigationEntryScreenshotManager { |
37 public: | 38 public: |
38 explicit ScreenshotTracker(NavigationControllerImpl* controller) | 39 explicit ScreenshotTracker(NavigationControllerImpl* controller) |
39 : NavigationEntryScreenshotManager(controller), | 40 : NavigationEntryScreenshotManager(controller), |
40 screenshot_taken_for_(NULL), | 41 screenshot_taken_for_(NULL), |
41 waiting_for_screenshots_(0) { | 42 waiting_for_screenshots_(0) { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 316 |
316 // Make sure the page has both back/forward history. | 317 // Make sure the page has both back/forward history. |
317 ExecuteSyncJSFunction(view_host, "navigate_next()"); | 318 ExecuteSyncJSFunction(view_host, "navigate_next()"); |
318 EXPECT_EQ(1, GetCurrentIndex()); | 319 EXPECT_EQ(1, GetCurrentIndex()); |
319 ExecuteSyncJSFunction(view_host, "navigate_next()"); | 320 ExecuteSyncJSFunction(view_host, "navigate_next()"); |
320 EXPECT_EQ(2, GetCurrentIndex()); | 321 EXPECT_EQ(2, GetCurrentIndex()); |
321 web_contents->GetController().GoBack(); | 322 web_contents->GetController().GoBack(); |
322 EXPECT_EQ(1, GetCurrentIndex()); | 323 EXPECT_EQ(1, GetCurrentIndex()); |
323 | 324 |
324 aura::Window* content = web_contents->GetView()->GetContentNativeView(); | 325 aura::Window* content = web_contents->GetView()->GetContentNativeView(); |
325 aura::WindowEventDispatcher* dispatcher = content->GetHost()->dispatcher(); | 326 ui::EventProcessor* dispatcher = content->GetHost()->event_processor(); |
326 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 327 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
327 | 328 |
328 base::TimeDelta timestamp; | 329 base::TimeDelta timestamp; |
329 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 330 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
330 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), | 331 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), |
331 0, timestamp); | 332 0, timestamp); |
332 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 333 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
333 ASSERT_FALSE(details.dispatcher_destroyed); | 334 ASSERT_FALSE(details.dispatcher_destroyed); |
334 EXPECT_EQ(1, GetCurrentIndex()); | 335 EXPECT_EQ(1, GetCurrentIndex()); |
335 | 336 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 10); | 659 10); |
659 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 660 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
660 EXPECT_EQ(expected_title, actual_title); | 661 EXPECT_EQ(expected_title, actual_title); |
661 | 662 |
662 EXPECT_EQ(2, GetCurrentIndex()); | 663 EXPECT_EQ(2, GetCurrentIndex()); |
663 EXPECT_TRUE(controller.CanGoBack()); | 664 EXPECT_TRUE(controller.CanGoBack()); |
664 EXPECT_FALSE(controller.CanGoForward()); | 665 EXPECT_FALSE(controller.CanGoForward()); |
665 } | 666 } |
666 | 667 |
667 } // namespace content | 668 } // namespace content |
OLD | NEW |