| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/browser/ui/browser_window.h" | 37 #include "chrome/browser/ui/browser_window.h" |
| 38 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 38 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 39 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 39 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 40 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 40 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 41 #include "chrome/common/chrome_notification_types.h" | 41 #include "chrome/common/chrome_notification_types.h" |
| 42 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
| 43 #include "chrome/common/extensions/extension_action.h" | 43 #include "chrome/common/extensions/extension_action.h" |
| 44 #include "chrome/test/automation/javascript_execution_controller.h" | 44 #include "chrome/test/automation/javascript_execution_controller.h" |
| 45 #include "chrome/test/base/bookmark_load_observer.h" | 45 #include "chrome/test/base/bookmark_load_observer.h" |
| 46 #include "content/browser/renderer_host/render_view_host.h" | 46 #include "content/browser/renderer_host/render_view_host.h" |
| 47 #include "content/browser/tab_contents/navigation_controller.h" | |
| 48 #include "content/browser/tab_contents/tab_contents.h" | 47 #include "content/browser/tab_contents/tab_contents.h" |
| 49 #include "content/public/browser/download_item.h" | 48 #include "content/public/browser/download_item.h" |
| 50 #include "content/public/browser/download_manager.h" | 49 #include "content/public/browser/download_manager.h" |
| 50 #include "content/public/browser/navigation_controller.h" |
| 51 #include "content/public/browser/navigation_entry.h" | 51 #include "content/public/browser/navigation_entry.h" |
| 52 #include "content/public/browser/notification_service.h" | 52 #include "content/public/browser/notification_service.h" |
| 53 #include "content/public/browser/render_process_host.h" | 53 #include "content/public/browser/render_process_host.h" |
| 54 #include "content/public/browser/web_contents_observer.h" | 54 #include "content/public/browser/web_contents_observer.h" |
| 55 #include "content/test/test_navigation_observer.h" | 55 #include "content/test/test_navigation_observer.h" |
| 56 #include "googleurl/src/gurl.h" | 56 #include "googleurl/src/gurl.h" |
| 57 #include "net/base/net_util.h" | 57 #include "net/base/net_util.h" |
| 58 #include "testing/gtest/include/gtest/gtest.h" | 58 #include "testing/gtest/include/gtest/gtest.h" |
| 59 #include "third_party/skia/include/core/SkBitmap.h" | 59 #include "third_party/skia/include/core/SkBitmap.h" |
| 60 #include "third_party/skia/include/core/SkColor.h" | 60 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 WebContents* web_contents = browser->GetSelectedWebContents(); | 307 WebContents* web_contents = browser->GetSelectedWebContents(); |
| 308 if (!web_contents) | 308 if (!web_contents) |
| 309 return false; | 309 return false; |
| 310 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); | 310 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); |
| 311 if (!last_entry) | 311 if (!last_entry) |
| 312 return false; | 312 return false; |
| 313 title->assign(last_entry->GetTitleForDisplay("")); | 313 title->assign(last_entry->GetTitleForDisplay("")); |
| 314 return true; | 314 return true; |
| 315 } | 315 } |
| 316 | 316 |
| 317 void WaitForNavigations(NavigationController* controller, | 317 void WaitForNavigations(content::NavigationController* controller, |
| 318 int number_of_navigations) { | 318 int number_of_navigations) { |
| 319 TestNavigationObserver observer( | 319 TestNavigationObserver observer( |
| 320 content::Source<content::NavigationController>(controller), NULL, | 320 content::Source<content::NavigationController>(controller), NULL, |
| 321 number_of_navigations); | 321 number_of_navigations); |
| 322 observer.WaitForObservation( | 322 observer.WaitForObservation( |
| 323 base::Bind(&ui_test_utils::RunMessageLoop), | 323 base::Bind(&ui_test_utils::RunMessageLoop), |
| 324 base::Bind(&MessageLoop::Quit, | 324 base::Bind(&MessageLoop::Quit, |
| 325 base::Unretained(MessageLoopForUI::current()))); | 325 base::Unretained(MessageLoopForUI::current()))); |
| 326 } | 326 } |
| 327 | 327 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 // The currently selected tab is the right one. | 443 // The currently selected tab is the right one. |
| 444 web_contents = browser->GetSelectedWebContents(); | 444 web_contents = browser->GetSelectedWebContents(); |
| 445 } | 445 } |
| 446 if (disposition == CURRENT_TAB) { | 446 if (disposition == CURRENT_TAB) { |
| 447 same_tab_observer.WaitForObservation( | 447 same_tab_observer.WaitForObservation( |
| 448 base::Bind(&ui_test_utils::RunMessageLoop), | 448 base::Bind(&ui_test_utils::RunMessageLoop), |
| 449 base::Bind(&MessageLoop::Quit, | 449 base::Bind(&MessageLoop::Quit, |
| 450 base::Unretained(MessageLoopForUI::current()))); | 450 base::Unretained(MessageLoopForUI::current()))); |
| 451 return; | 451 return; |
| 452 } else if (web_contents) { | 452 } else if (web_contents) { |
| 453 NavigationController* controller = &web_contents->GetController(); | 453 content::NavigationController* controller = &web_contents->GetController(); |
| 454 WaitForNavigations(controller, number_of_navigations); | 454 WaitForNavigations(controller, number_of_navigations); |
| 455 return; | 455 return; |
| 456 } | 456 } |
| 457 EXPECT_TRUE(NULL != web_contents) << " Unable to wait for navigation to \"" | 457 EXPECT_TRUE(NULL != web_contents) << " Unable to wait for navigation to \"" |
| 458 << url.spec() << "\"" | 458 << url.spec() << "\"" |
| 459 << " because we can't get the tab contents"; | 459 << " because we can't get the tab contents"; |
| 460 } | 460 } |
| 461 | 461 |
| 462 void NavigateToURLWithDisposition(Browser* browser, | 462 void NavigateToURLWithDisposition(Browser* browser, |
| 463 const GURL& url, | 463 const GURL& url, |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); | 1079 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); |
| 1080 } | 1080 } |
| 1081 | 1081 |
| 1082 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { | 1082 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { |
| 1083 DCHECK(bitmap); | 1083 DCHECK(bitmap); |
| 1084 SnapshotTaker taker; | 1084 SnapshotTaker taker; |
| 1085 return taker.TakeEntirePageSnapshot(rvh, bitmap); | 1085 return taker.TakeEntirePageSnapshot(rvh, bitmap); |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 } // namespace ui_test_utils | 1088 } // namespace ui_test_utils |
| OLD | NEW |