| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_tabstrip.h" | 11 #include "chrome/browser/ui/browser_tabstrip.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/snapshot_tab_helper.h" | 13 #include "chrome/browser/ui/snapshot_tab_helper.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
| 19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/test/browser_test_utils.h" |
| 23 #include "net/test/test_server.h" | 24 #include "net/test/test_server.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| 25 #include "ui/base/clipboard/clipboard.h" | 26 #include "ui/base/clipboard/clipboard.h" |
| 26 #include "ui/gfx/codec/png_codec.h" | 27 #include "ui/gfx/codec/png_codec.h" |
| 27 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
| 28 | 29 |
| 29 using content::NavigationController; | 30 using content::NavigationController; |
| 30 using content::WebContents; | 31 using content::WebContents; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // the moment. | 235 // the moment. |
| 235 WebKit::WebMouseWheelEvent wheel_event; | 236 WebKit::WebMouseWheelEvent wheel_event; |
| 236 wheel_event.type = WebKit::WebInputEvent::MouseWheel; | 237 wheel_event.type = WebKit::WebInputEvent::MouseWheel; |
| 237 wheel_event.deltaY = -200; | 238 wheel_event.deltaY = -200; |
| 238 wheel_event.wheelTicksY = -2; | 239 wheel_event.wheelTicksY = -2; |
| 239 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 240 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
| 240 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event); | 241 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event); |
| 241 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); | 242 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); |
| 242 | 243 |
| 243 int y_offset = 0; | 244 int y_offset = 0; |
| 244 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 245 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractInt( |
| 245 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 246 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 246 std::wstring(), | 247 std::wstring(), |
| 247 L"window.domAutomationController.send(plugin.pageYOffset())", | 248 L"window.domAutomationController.send(plugin.pageYOffset())", |
| 248 &y_offset)); | 249 &y_offset)); |
| 249 ASSERT_GT(y_offset, 0); | 250 ASSERT_GT(y_offset, 0); |
| 250 } | 251 } |
| 251 | 252 |
| 252 #if defined(OS_CHROMEOS) | 253 #if defined(OS_CHROMEOS) |
| 253 // TODO(sanjeevr): http://crbug.com/79837 | 254 // TODO(sanjeevr): http://crbug.com/79837 |
| 254 #define MAYBE_FindAndCopy DISABLED_FindAndCopy | 255 #define MAYBE_FindAndCopy DISABLED_FindAndCopy |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 315 |
| 315 GURL url = pdf_test_server()->GetURL(base_url + filename); | 316 GURL url = pdf_test_server()->GetURL(base_url + filename); |
| 316 ui_test_utils::NavigateToURL(browser(), url); | 317 ui_test_utils::NavigateToURL(browser(), url); |
| 317 | 318 |
| 318 while (true) { | 319 while (true) { |
| 319 int last_count = load_stop_notification_count(); | 320 int last_count = load_stop_notification_count(); |
| 320 // We might get extraneous chrome::LOAD_STOP notifications when | 321 // We might get extraneous chrome::LOAD_STOP notifications when |
| 321 // doing async loading. This happens when the first loader is cancelled | 322 // doing async loading. This happens when the first loader is cancelled |
| 322 // and before creating a byte-range request loader. | 323 // and before creating a byte-range request loader. |
| 323 bool complete = false; | 324 bool complete = false; |
| 324 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 325 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 325 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 326 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 326 std::wstring(), | 327 std::wstring(), |
| 327 L"window.domAutomationController.send(plugin.documentLoadComplete())", | 328 L"window.domAutomationController.send(plugin.documentLoadComplete())", |
| 328 &complete)); | 329 &complete)); |
| 329 if (complete) | 330 if (complete) |
| 330 break; | 331 break; |
| 331 | 332 |
| 332 // Check if the LOAD_STOP notification could have come while we run a | 333 // Check if the LOAD_STOP notification could have come while we run a |
| 333 // nested message loop for the JS call. | 334 // nested message loop for the JS call. |
| 334 if (last_count != load_stop_notification_count()) | 335 if (last_count != load_stop_notification_count()) |
| 335 continue; | 336 continue; |
| 336 ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser())); | 337 ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser())); |
| 337 } | 338 } |
| 338 } | 339 } |
| 339 } | 340 } |
| 340 | 341 |
| 341 // Flaky as per http://crbug.com/74549. | 342 // Flaky as per http://crbug.com/74549. |
| 342 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, DISABLED_OnLoadAndReload) { | 343 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, DISABLED_OnLoadAndReload) { |
| 343 ASSERT_TRUE(pdf_test_server()->Start()); | 344 ASSERT_TRUE(pdf_test_server()->Start()); |
| 344 | 345 |
| 345 GURL url = pdf_test_server()->GetURL("files/onload_reload.html"); | 346 GURL url = pdf_test_server()->GetURL("files/onload_reload.html"); |
| 346 ui_test_utils::NavigateToURL(browser(), url); | 347 ui_test_utils::NavigateToURL(browser(), url); |
| 347 | 348 |
| 348 content::WindowedNotificationObserver observer( | 349 content::WindowedNotificationObserver observer( |
| 349 content::NOTIFICATION_LOAD_STOP, | 350 content::NOTIFICATION_LOAD_STOP, |
| 350 content::Source<NavigationController>( | 351 content::Source<NavigationController>( |
| 351 &chrome::GetActiveWebContents(browser())->GetController())); | 352 &chrome::GetActiveWebContents(browser())->GetController())); |
| 352 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( | 353 ASSERT_TRUE(content::ExecuteJavaScript( |
| 353 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 354 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 354 std::wstring(), | 355 std::wstring(), |
| 355 L"reloadPDF();")); | 356 L"reloadPDF();")); |
| 356 observer.Wait(); | 357 observer.Wait(); |
| 357 | 358 |
| 358 ASSERT_EQ("success", | 359 ASSERT_EQ("success", |
| 359 chrome::GetActiveWebContents(browser())->GetURL().query()); | 360 chrome::GetActiveWebContents(browser())->GetURL().query()); |
| 360 } | 361 } |
| 361 | 362 |
| 362 } // namespace | 363 } // namespace |
| OLD | NEW |