Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura_browsertest.cc

Issue 12334073: Remove WebContents methods that duplicate WebContentsView methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/test/test_timeouts.h" 9 #include "base/test/test_timeouts.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/web_contents/navigation_controller_impl.h" 13 #include "content/browser/web_contents/navigation_controller_impl.h"
14 #include "content/browser/web_contents/navigation_entry_impl.h" 14 #include "content/browser/web_contents/navigation_entry_impl.h"
15 #include "content/browser/web_contents/web_contents_impl.h" 15 #include "content/browser/web_contents/web_contents_impl.h"
16 #include "content/public/browser/web_contents_view.h"
16 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
17 #include "content/public/test/browser_test_utils.h" 18 #include "content/public/test/browser_test_utils.h"
18 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
19 #include "content/shell/shell.h" 20 #include "content/shell/shell.h"
20 #include "content/test/content_browser_test.h" 21 #include "content/test/content_browser_test.h"
21 #include "content/test/content_browser_test_utils.h" 22 #include "content/test/content_browser_test_utils.h"
22 #include "ui/aura/root_window.h" 23 #include "ui/aura/root_window.h"
23 #include "ui/aura/test/event_generator.h" 24 #include "ui/aura/test/event_generator.h"
24 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
25 26
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 content::ExecuteScriptAndGetValue(rvh, jscript); 78 content::ExecuteScriptAndGetValue(rvh, jscript);
78 } 79 }
79 80
80 // Starts the test server and navigates to the given url. Sets a large enough 81 // Starts the test server and navigates to the given url. Sets a large enough
81 // size to the root window. Returns after the navigation to the url is 82 // size to the root window. Returns after the navigation to the url is
82 // complete. 83 // complete.
83 void StartTestWithPage(const std::string& url) { 84 void StartTestWithPage(const std::string& url) {
84 ASSERT_TRUE(test_server()->Start()); 85 ASSERT_TRUE(test_server()->Start());
85 GURL test_url(test_server()->GetURL(url)); 86 GURL test_url(test_server()->GetURL(url));
86 NavigateToURL(shell(), test_url); 87 NavigateToURL(shell(), test_url);
87 aura::Window* content = shell()->web_contents()->GetContentNativeView(); 88 aura::Window* content =
89 shell()->web_contents()->GetView()->GetContentNativeView();
88 content->GetRootWindow()->SetHostSize(gfx::Size(800, 600)); 90 content->GetRootWindow()->SetHostSize(gfx::Size(800, 600));
89 } 91 }
90 92
91 void TestOverscrollNavigation(bool touch_handler) { 93 void TestOverscrollNavigation(bool touch_handler) {
92 ASSERT_NO_FATAL_FAILURE( 94 ASSERT_NO_FATAL_FAILURE(
93 StartTestWithPage("files/overscroll_navigation.html")); 95 StartTestWithPage("files/overscroll_navigation.html"));
94 WebContentsImpl* web_contents = 96 WebContentsImpl* web_contents =
95 static_cast<WebContentsImpl*>(shell()->web_contents()); 97 static_cast<WebContentsImpl*>(shell()->web_contents());
96 NavigationController& controller = web_contents->GetController(); 98 NavigationController& controller = web_contents->GetController();
97 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( 99 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(
(...skipping 11 matching lines...) Expand all
109 ExecuteSyncJSFunction(view_host, "install_touch_handler()"); 111 ExecuteSyncJSFunction(view_host, "install_touch_handler()");
110 112
111 ExecuteSyncJSFunction(view_host, "navigate_next()"); 113 ExecuteSyncJSFunction(view_host, "navigate_next()");
112 ExecuteSyncJSFunction(view_host, "navigate_next()"); 114 ExecuteSyncJSFunction(view_host, "navigate_next()");
113 value = content::ExecuteScriptAndGetValue(view_host, "get_current()"); 115 value = content::ExecuteScriptAndGetValue(view_host, "get_current()");
114 ASSERT_TRUE(value->GetAsInteger(&index)); 116 ASSERT_TRUE(value->GetAsInteger(&index));
115 EXPECT_EQ(2, index); 117 EXPECT_EQ(2, index);
116 EXPECT_TRUE(controller.CanGoBack()); 118 EXPECT_TRUE(controller.CanGoBack());
117 EXPECT_FALSE(controller.CanGoForward()); 119 EXPECT_FALSE(controller.CanGoForward());
118 120
119 aura::Window* content = web_contents->GetContentNativeView(); 121 aura::Window* content = web_contents->GetView()->GetContentNativeView();
120 gfx::Rect bounds = content->GetBoundsInRootWindow(); 122 gfx::Rect bounds = content->GetBoundsInRootWindow();
121 aura::test::EventGenerator generator(content->GetRootWindow(), content); 123 aura::test::EventGenerator generator(content->GetRootWindow(), content);
122 124
123 { 125 {
124 // Do a swipe-right now. That should navigate backwards. 126 // Do a swipe-right now. That should navigate backwards.
125 string16 expected_title = ASCIIToUTF16("Title: #1"); 127 string16 expected_title = ASCIIToUTF16("Title: #1");
126 content::TitleWatcher title_watcher(web_contents, expected_title); 128 content::TitleWatcher title_watcher(web_contents, expected_title);
127 generator.GestureScrollSequence( 129 generator.GestureScrollSequence(
128 gfx::Point(bounds.x() + 2, bounds.y() + 10), 130 gfx::Point(bounds.x() + 2, bounds.y() + 10),
129 gfx::Point(bounds.right() - 10, bounds.y() + 10), 131 gfx::Point(bounds.right() - 10, bounds.y() + 10),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 web_contents->GetRenderViewHost()); 214 web_contents->GetRenderViewHost());
213 215
214 // Make sure the page has both back/forward history. 216 // Make sure the page has both back/forward history.
215 ExecuteSyncJSFunction(view_host, "navigate_next()"); 217 ExecuteSyncJSFunction(view_host, "navigate_next()");
216 EXPECT_EQ(1, GetCurrentIndex()); 218 EXPECT_EQ(1, GetCurrentIndex());
217 ExecuteSyncJSFunction(view_host, "navigate_next()"); 219 ExecuteSyncJSFunction(view_host, "navigate_next()");
218 EXPECT_EQ(2, GetCurrentIndex()); 220 EXPECT_EQ(2, GetCurrentIndex());
219 web_contents->GetController().GoBack(); 221 web_contents->GetController().GoBack();
220 EXPECT_EQ(1, GetCurrentIndex()); 222 EXPECT_EQ(1, GetCurrentIndex());
221 223
222 aura::Window* content = web_contents->GetContentNativeView(); 224 aura::Window* content = web_contents->GetView()->GetContentNativeView();
223 aura::RootWindow* root_window = content->GetRootWindow(); 225 aura::RootWindow* root_window = content->GetRootWindow();
224 gfx::Rect bounds = content->GetBoundsInRootWindow(); 226 gfx::Rect bounds = content->GetBoundsInRootWindow();
225 227
226 base::TimeDelta timestamp; 228 base::TimeDelta timestamp;
227 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 229 ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
228 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 230 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
229 0, timestamp); 231 0, timestamp);
230 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 232 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
231 EXPECT_EQ(1, GetCurrentIndex()); 233 EXPECT_EQ(1, GetCurrentIndex());
232 234
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 316
315 entry = NavigationEntryImpl::FromNavigationEntry( 317 entry = NavigationEntryImpl::FromNavigationEntry(
316 web_contents->GetController().GetEntryAtIndex(3)); 318 web_contents->GetController().GetEntryAtIndex(3));
317 EXPECT_FALSE(entry->screenshot().get()); 319 EXPECT_FALSE(entry->screenshot().get());
318 320
319 { 321 {
320 // Now, swipe right to navigate backwards. This should navigate away from 322 // Now, swipe right to navigate backwards. This should navigate away from
321 // index 3 to index 2, and index 3 should have a screenshot. 323 // index 3 to index 2, and index 3 should have a screenshot.
322 string16 expected_title = ASCIIToUTF16("Title: #2"); 324 string16 expected_title = ASCIIToUTF16("Title: #2");
323 content::TitleWatcher title_watcher(web_contents, expected_title); 325 content::TitleWatcher title_watcher(web_contents, expected_title);
324 aura::Window* content = web_contents->GetContentNativeView(); 326 aura::Window* content = web_contents->GetView()->GetContentNativeView();
325 gfx::Rect bounds = content->GetBoundsInRootWindow(); 327 gfx::Rect bounds = content->GetBoundsInRootWindow();
326 aura::test::EventGenerator generator(content->GetRootWindow(), content); 328 aura::test::EventGenerator generator(content->GetRootWindow(), content);
327 generator.GestureScrollSequence( 329 generator.GestureScrollSequence(
328 gfx::Point(bounds.x() + 2, bounds.y() + 10), 330 gfx::Point(bounds.x() + 2, bounds.y() + 10),
329 gfx::Point(bounds.right() - 10, bounds.y() + 10), 331 gfx::Point(bounds.right() - 10, bounds.y() + 10),
330 base::TimeDelta::FromMilliseconds(20), 332 base::TimeDelta::FromMilliseconds(20),
331 1); 333 1);
332 string16 actual_title = title_watcher.WaitAndGetTitle(); 334 string16 actual_title = title_watcher.WaitAndGetTitle();
333 EXPECT_EQ(expected_title, actual_title); 335 EXPECT_EQ(expected_title, actual_title);
334 EXPECT_EQ(2, GetCurrentIndex()); 336 EXPECT_EQ(2, GetCurrentIndex());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 web_contents->GetController().GetEntryAtOffset(-1)); 410 web_contents->GetController().GetEntryAtOffset(-1));
409 EXPECT_TRUE(entry->screenshot().get()); 411 EXPECT_TRUE(entry->screenshot().get());
410 412
411 entry = NavigationEntryImpl::FromNavigationEntry( 413 entry = NavigationEntryImpl::FromNavigationEntry(
412 web_contents->GetController().GetActiveEntry()); 414 web_contents->GetController().GetActiveEntry());
413 EXPECT_FALSE(entry->screenshot().get()); 415 EXPECT_FALSE(entry->screenshot().get());
414 } 416 }
415 } 417 }
416 418
417 } // namespace content 419 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698