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

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

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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/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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 // Starts the test server and navigates to the given url. Sets a large enough 144 // Starts the test server and navigates to the given url. Sets a large enough
145 // size to the root window. Returns after the navigation to the url is 145 // size to the root window. Returns after the navigation to the url is
146 // complete. 146 // complete.
147 void StartTestWithPage(const std::string& url) { 147 void StartTestWithPage(const std::string& url) {
148 ASSERT_TRUE(test_server()->Start()); 148 ASSERT_TRUE(test_server()->Start());
149 GURL test_url(test_server()->GetURL(url)); 149 GURL test_url(test_server()->GetURL(url));
150 NavigateToURL(shell(), test_url); 150 NavigateToURL(shell(), test_url);
151 aura::Window* content = 151 aura::Window* content =
152 shell()->web_contents()->GetView()->GetContentNativeView(); 152 shell()->web_contents()->GetView()->GetContentNativeView();
153 content->GetRootWindow()->SetHostSize(gfx::Size(800, 600)); 153 content->GetDispatcher()->SetHostSize(gfx::Size(800, 600));
154 154
155 WebContentsImpl* web_contents = 155 WebContentsImpl* web_contents =
156 static_cast<WebContentsImpl*>(shell()->web_contents()); 156 static_cast<WebContentsImpl*>(shell()->web_contents());
157 NavigationControllerImpl* controller = &web_contents->GetController(); 157 NavigationControllerImpl* controller = &web_contents->GetController();
158 158
159 screenshot_manager_ = new ScreenshotTracker(controller); 159 screenshot_manager_ = new ScreenshotTracker(controller);
160 controller->SetScreenshotManager(screenshot_manager_); 160 controller->SetScreenshotManager(screenshot_manager_);
161 } 161 }
162 162
163 void TestOverscrollNavigation(bool touch_handler) { 163 void TestOverscrollNavigation(bool touch_handler) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 324
325 // Make sure the page has both back/forward history. 325 // Make sure the page has both back/forward history.
326 ExecuteSyncJSFunction(view_host, "navigate_next()"); 326 ExecuteSyncJSFunction(view_host, "navigate_next()");
327 EXPECT_EQ(1, GetCurrentIndex()); 327 EXPECT_EQ(1, GetCurrentIndex());
328 ExecuteSyncJSFunction(view_host, "navigate_next()"); 328 ExecuteSyncJSFunction(view_host, "navigate_next()");
329 EXPECT_EQ(2, GetCurrentIndex()); 329 EXPECT_EQ(2, GetCurrentIndex());
330 web_contents->GetController().GoBack(); 330 web_contents->GetController().GoBack();
331 EXPECT_EQ(1, GetCurrentIndex()); 331 EXPECT_EQ(1, GetCurrentIndex());
332 332
333 aura::Window* content = web_contents->GetView()->GetContentNativeView(); 333 aura::Window* content = web_contents->GetView()->GetContentNativeView();
334 aura::RootWindow* root_window = content->GetRootWindow(); 334 aura::WindowEventDispatcher* dispatcher = content->GetDispatcher();
335 gfx::Rect bounds = content->GetBoundsInRootWindow(); 335 gfx::Rect bounds = content->GetBoundsInRootWindow();
336 336
337 base::TimeDelta timestamp; 337 base::TimeDelta timestamp;
338 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 338 ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
339 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 339 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
340 0, timestamp); 340 0, timestamp);
341 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 341 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
342 EXPECT_EQ(1, GetCurrentIndex()); 342 EXPECT_EQ(1, GetCurrentIndex());
343 343
344 timestamp += base::TimeDelta::FromMilliseconds(10); 344 timestamp += base::TimeDelta::FromMilliseconds(10);
345 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, 345 ui::TouchEvent move1(ui::ET_TOUCH_MOVED,
346 gfx::Point(bounds.right() - 10, bounds.y() + 5), 346 gfx::Point(bounds.right() - 10, bounds.y() + 5),
347 0, timestamp); 347 0, timestamp);
348 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); 348 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1);
349 EXPECT_EQ(1, GetCurrentIndex()); 349 EXPECT_EQ(1, GetCurrentIndex());
350 350
351 // Swipe back from the right edge, back to the left edge, back to the right 351 // Swipe back from the right edge, back to the left edge, back to the right
352 // edge. 352 // edge.
353 353
354 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) { 354 for (int x = bounds.right() - 10; x >= bounds.x() + 10; x-= 10) {
355 timestamp += base::TimeDelta::FromMilliseconds(10); 355 timestamp += base::TimeDelta::FromMilliseconds(10);
356 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, 356 ui::TouchEvent inc(ui::ET_TOUCH_MOVED,
357 gfx::Point(x, bounds.y() + 5), 357 gfx::Point(x, bounds.y() + 5),
358 0, timestamp); 358 0, timestamp);
359 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc); 359 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc);
360 EXPECT_EQ(1, GetCurrentIndex()); 360 EXPECT_EQ(1, GetCurrentIndex());
361 } 361 }
362 362
363 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) { 363 for (int x = bounds.x() + 10; x <= bounds.width() - 10; x+= 10) {
364 timestamp += base::TimeDelta::FromMilliseconds(10); 364 timestamp += base::TimeDelta::FromMilliseconds(10);
365 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, 365 ui::TouchEvent inc(ui::ET_TOUCH_MOVED,
366 gfx::Point(x, bounds.y() + 5), 366 gfx::Point(x, bounds.y() + 5),
367 0, timestamp); 367 0, timestamp);
368 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc); 368 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc);
369 EXPECT_EQ(1, GetCurrentIndex()); 369 EXPECT_EQ(1, GetCurrentIndex());
370 } 370 }
371 371
372 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) { 372 for (int x = bounds.width() - 10; x >= bounds.x() + 10; x-= 10) {
373 timestamp += base::TimeDelta::FromMilliseconds(10); 373 timestamp += base::TimeDelta::FromMilliseconds(10);
374 ui::TouchEvent inc(ui::ET_TOUCH_MOVED, 374 ui::TouchEvent inc(ui::ET_TOUCH_MOVED,
375 gfx::Point(x, bounds.y() + 5), 375 gfx::Point(x, bounds.y() + 5),
376 0, timestamp); 376 0, timestamp);
377 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc); 377 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&inc);
378 EXPECT_EQ(1, GetCurrentIndex()); 378 EXPECT_EQ(1, GetCurrentIndex());
379 } 379 }
380 380
381 // Do not end the overscroll sequence. 381 // Do not end the overscroll sequence.
382 } 382 }
383 383
384 // Tests that the page has has a screenshot when navigation happens: 384 // Tests that the page has has a screenshot when navigation happens:
385 // - from within the page (from a JS function) 385 // - from within the page (from a JS function)
386 // - interactively, when user does an overscroll gesture 386 // - interactively, when user does an overscroll gesture
387 // - interactively, when user navigates in history without the overscroll 387 // - interactively, when user navigates in history without the overscroll
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 10); 662 10);
663 string16 actual_title = title_watcher.WaitAndGetTitle(); 663 string16 actual_title = title_watcher.WaitAndGetTitle();
664 EXPECT_EQ(expected_title, actual_title); 664 EXPECT_EQ(expected_title, actual_title);
665 665
666 EXPECT_EQ(2, GetCurrentIndex()); 666 EXPECT_EQ(2, GetCurrentIndex());
667 EXPECT_TRUE(controller.CanGoBack()); 667 EXPECT_TRUE(controller.CanGoBack());
668 EXPECT_FALSE(controller.CanGoForward()); 668 EXPECT_FALSE(controller.CanGoForward());
669 } 669 }
670 670
671 } // namespace content 671 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.cc ('k') | content/shell/browser/shell_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698