Chromium Code Reviews| 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/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #include "content/browser/web_contents/web_contents_view.h" | 19 #include "content/browser/web_contents/web_contents_view.h" |
| 20 #include "content/common/view_messages.h" | |
| 20 #include "content/public/browser/render_frame_host.h" | 21 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
| 24 #include "content/public/test/content_browser_test.h" | 25 #include "content/public/test/content_browser_test.h" |
| 25 #include "content/public/test/content_browser_test_utils.h" | 26 #include "content/public/test/content_browser_test_utils.h" |
| 27 #include "content/public/test/test_renderer_host.h" | |
| 26 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 27 #include "content/shell/browser/shell.h" | 29 #include "content/shell/browser/shell.h" |
| 28 #include "ui/aura/test/event_generator.h" | 30 #include "ui/aura/test/event_generator.h" |
| 29 #include "ui/aura/window.h" | 31 #include "ui/aura/window.h" |
| 30 #include "ui/aura/window_tree_host.h" | 32 #include "ui/aura/window_tree_host.h" |
| 31 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 33 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 32 #include "ui/events/event_processor.h" | 34 #include "ui/events/event_processor.h" |
| 33 | 35 |
| 34 namespace content { | 36 namespace content { |
| 35 | 37 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 kScrollSteps); | 201 kScrollSteps); |
| 200 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 202 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 201 EXPECT_EQ(expected_title, actual_title); | 203 EXPECT_EQ(expected_title, actual_title); |
| 202 value = content::ExecuteScriptAndGetValue(main_frame, "get_current()"); | 204 value = content::ExecuteScriptAndGetValue(main_frame, "get_current()"); |
| 203 ASSERT_TRUE(value->GetAsInteger(&index)); | 205 ASSERT_TRUE(value->GetAsInteger(&index)); |
| 204 EXPECT_EQ(1, index); | 206 EXPECT_EQ(1, index); |
| 205 EXPECT_TRUE(controller.CanGoBack()); | 207 EXPECT_TRUE(controller.CanGoBack()); |
| 206 EXPECT_TRUE(controller.CanGoForward()); | 208 EXPECT_TRUE(controller.CanGoForward()); |
| 207 } | 209 } |
| 208 | 210 |
| 211 // Generate DidFirstVisuallyNonEmptyPaint message in order to have the | |
| 212 // overscroll overlay dismissed. | |
| 213 RenderViewHost* rvh = web_contents->GetRenderViewHost(); | |
| 214 ViewHostMsg_DidFirstVisuallyNonEmptyPaint msg(rvh->GetRoutingID()); | |
| 215 RenderViewHostTester::TestOnMessageReceived(rvh, msg); | |
|
mfomitchev
2014/05/14 17:46:35
It would be much better if we could actually enabl
| |
| 216 | |
| 209 { | 217 { |
| 210 // Do a fling-right now. That should navigate backwards. | 218 // Do a fling-right now. That should navigate backwards. |
| 211 base::string16 expected_title = base::ASCIIToUTF16("Title:"); | 219 base::string16 expected_title = base::ASCIIToUTF16("Title:"); |
| 212 content::TitleWatcher title_watcher(web_contents, expected_title); | 220 content::TitleWatcher title_watcher(web_contents, expected_title); |
| 213 generator.GestureScrollSequence( | 221 generator.GestureScrollSequence( |
| 214 gfx::Point(bounds.x() + 2, bounds.y() + 10), | 222 gfx::Point(bounds.x() + 2, bounds.y() + 10), |
| 215 gfx::Point(bounds.right() - 10, bounds.y() + 10), | 223 gfx::Point(bounds.right() - 10, bounds.y() + 10), |
| 216 base::TimeDelta::FromMilliseconds(kScrollDurationMs), | 224 base::TimeDelta::FromMilliseconds(kScrollDurationMs), |
| 217 kScrollSteps); | 225 kScrollSteps); |
| 218 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 226 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 219 EXPECT_EQ(expected_title, actual_title); | 227 EXPECT_EQ(expected_title, actual_title); |
| 220 value = content::ExecuteScriptAndGetValue(main_frame, "get_current()"); | 228 value = content::ExecuteScriptAndGetValue(main_frame, "get_current()"); |
| 221 ASSERT_TRUE(value->GetAsInteger(&index)); | 229 ASSERT_TRUE(value->GetAsInteger(&index)); |
| 222 EXPECT_EQ(0, index); | 230 EXPECT_EQ(0, index); |
| 223 EXPECT_FALSE(controller.CanGoBack()); | 231 EXPECT_FALSE(controller.CanGoBack()); |
| 224 EXPECT_TRUE(controller.CanGoForward()); | 232 EXPECT_TRUE(controller.CanGoForward()); |
| 225 } | 233 } |
| 226 | 234 |
| 235 // Generate DidFirstVisuallyNonEmptyPaint message in order to have the | |
| 236 // overscroll overlay dismissed. | |
| 237 ViewHostMsg_DidFirstVisuallyNonEmptyPaint msg2(rvh->GetRoutingID()); | |
| 238 RenderViewHostTester::TestOnMessageReceived(rvh, msg2); | |
| 239 | |
| 227 { | 240 { |
| 228 // Do a swipe-left now. That should navigate forward. | 241 // Do a swipe-left now. That should navigate forward. |
| 229 base::string16 expected_title = base::ASCIIToUTF16("Title: #1"); | 242 base::string16 expected_title = base::ASCIIToUTF16("Title: #1"); |
| 230 content::TitleWatcher title_watcher(web_contents, expected_title); | 243 content::TitleWatcher title_watcher(web_contents, expected_title); |
| 231 generator.GestureScrollSequence( | 244 generator.GestureScrollSequence( |
| 232 gfx::Point(bounds.right() - 10, bounds.y() + 10), | 245 gfx::Point(bounds.right() - 10, bounds.y() + 10), |
| 233 gfx::Point(bounds.x() + 2, bounds.y() + 10), | 246 gfx::Point(bounds.x() + 2, bounds.y() + 10), |
| 234 base::TimeDelta::FromMilliseconds(kScrollDurationMs), | 247 base::TimeDelta::FromMilliseconds(kScrollDurationMs), |
| 235 kScrollSteps); | 248 kScrollSteps); |
| 236 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 249 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 10); | 691 10); |
| 679 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 692 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 680 EXPECT_EQ(expected_title, actual_title); | 693 EXPECT_EQ(expected_title, actual_title); |
| 681 | 694 |
| 682 EXPECT_EQ(2, GetCurrentIndex()); | 695 EXPECT_EQ(2, GetCurrentIndex()); |
| 683 EXPECT_TRUE(controller.CanGoBack()); | 696 EXPECT_TRUE(controller.CanGoBack()); |
| 684 EXPECT_FALSE(controller.CanGoForward()); | 697 EXPECT_FALSE(controller.CanGoForward()); |
| 685 } | 698 } |
| 686 | 699 |
| 687 } // namespace content | 700 } // namespace content |
| OLD | NEW |