| 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/files/file_enumerator.h" | 6 #include "base/files/file_enumerator.h" |
| 7 #include "base/hash.h" | 7 #include "base/hash.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // The filename of the bitmap to compare the snapshot to. | 203 // The filename of the bitmap to compare the snapshot to. |
| 204 std::string expected_filename_; | 204 std::string expected_filename_; |
| 205 // If the snapshot is different, holds the location where it's saved. | 205 // If the snapshot is different, holds the location where it's saved. |
| 206 base::FilePath snapshot_filename_; | 206 base::FilePath snapshot_filename_; |
| 207 // How many times we've seen chrome::LOAD_STOP. | 207 // How many times we've seen chrome::LOAD_STOP. |
| 208 int load_stop_notification_count_; | 208 int load_stop_notification_count_; |
| 209 | 209 |
| 210 net::test_server::EmbeddedTestServer pdf_test_server_; | 210 net::test_server::EmbeddedTestServer pdf_test_server_; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 #if defined(OS_CHROMEOS) | 213 // Failing on official Windows bot. http://crbug.com/152330 |
| 214 #if defined(OS_CHROMEOS) || (defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| 214 // TODO(sanjeevr): http://crbug.com/79837 | 215 // TODO(sanjeevr): http://crbug.com/79837 |
| 215 #define MAYBE_Basic DISABLED_Basic | 216 #define MAYBE_Basic DISABLED_Basic |
| 216 #else | 217 #else |
| 217 #define MAYBE_Basic Basic | 218 #define MAYBE_Basic Basic |
| 218 #endif | 219 #endif |
| 219 // Tests basic PDF rendering. This can be broken depending on bad merges with | 220 // Tests basic PDF rendering. This can be broken depending on bad merges with |
| 220 // the vendor, so it's important that we have basic sanity checking. | 221 // the vendor, so it's important that we have basic sanity checking. |
| 221 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Basic) { | 222 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Basic) { |
| 222 ASSERT_NO_FATAL_FAILURE(Load()); | 223 ASSERT_NO_FATAL_FAILURE(Load()); |
| 223 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); | 224 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); |
| 224 // OS X uses CoreText, and FreeType renders slightly different on Linux and | 225 // OS X uses CoreText, and FreeType renders slightly different on Linux and |
| 225 // Win. | 226 // Win. |
| 226 #if defined(OS_MACOSX) | 227 #if defined(OS_MACOSX) |
| 227 // The bots render differently than locally, see http://crbug.com/142531. | 228 // The bots render differently than locally, see http://crbug.com/142531. |
| 228 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_mac.png") || | 229 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_mac.png") || |
| 229 VerifySnapshot("pdf_browsertest_mac2.png")); | 230 VerifySnapshot("pdf_browsertest_mac2.png")); |
| 230 #elif defined(OS_LINUX) | 231 #elif defined(OS_LINUX) |
| 231 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_linux.png")); | 232 ASSERT_TRUE(VerifySnapshot("pdf_browsertest_linux.png")); |
| 232 #else | 233 #else |
| 233 ASSERT_TRUE(VerifySnapshot("pdf_browsertest.png")); | 234 ASSERT_TRUE(VerifySnapshot("pdf_browsertest.png")); |
| 234 #endif | 235 #endif |
| 235 } | 236 } |
| 236 | 237 |
| 237 #if defined(OS_CHROMEOS) | 238 #if defined(OS_CHROMEOS) || (defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| 238 // TODO(sanjeevr): http://crbug.com/79837 | 239 // TODO(sanjeevr): http://crbug.com/79837 |
| 239 #define MAYBE_Scroll DISABLED_Scroll | 240 #define MAYBE_Scroll DISABLED_Scroll |
| 240 #else | 241 #else |
| 241 #define MAYBE_Scroll Scroll | 242 #define MAYBE_Scroll Scroll |
| 242 #endif | 243 #endif |
| 243 // Tests that scrolling works. | 244 // Tests that scrolling works. |
| 244 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Scroll) { | 245 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_Scroll) { |
| 245 ASSERT_NO_FATAL_FAILURE(Load()); | 246 ASSERT_NO_FATAL_FAILURE(Load()); |
| 246 | 247 |
| 247 // We use wheel mouse event since that's the only one we can easily push to | 248 // We use wheel mouse event since that's the only one we can easily push to |
| 248 // the renderer. There's no way to push a cross-platform keyboard event at | 249 // the renderer. There's no way to push a cross-platform keyboard event at |
| 249 // the moment. | 250 // the moment. |
| 250 blink::WebMouseWheelEvent wheel_event; | 251 blink::WebMouseWheelEvent wheel_event; |
| 251 wheel_event.type = blink::WebInputEvent::MouseWheel; | 252 wheel_event.type = blink::WebInputEvent::MouseWheel; |
| 252 wheel_event.deltaY = -200; | 253 wheel_event.deltaY = -200; |
| 253 wheel_event.wheelTicksY = -2; | 254 wheel_event.wheelTicksY = -2; |
| 254 WebContents* web_contents = | 255 WebContents* web_contents = |
| 255 browser()->tab_strip_model()->GetActiveWebContents(); | 256 browser()->tab_strip_model()->GetActiveWebContents(); |
| 256 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event); | 257 web_contents->GetRenderViewHost()->ForwardWheelEvent(wheel_event); |
| 257 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); | 258 ASSERT_NO_FATAL_FAILURE(WaitForResponse()); |
| 258 | 259 |
| 259 int y_offset = 0; | 260 int y_offset = 0; |
| 260 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 261 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 261 browser()->tab_strip_model()->GetActiveWebContents(), | 262 browser()->tab_strip_model()->GetActiveWebContents(), |
| 262 "window.domAutomationController.send(plugin.pageYOffset())", | 263 "window.domAutomationController.send(plugin.pageYOffset())", |
| 263 &y_offset)); | 264 &y_offset)); |
| 264 ASSERT_GT(y_offset, 0); | 265 ASSERT_GT(y_offset, 0); |
| 265 } | 266 } |
| 266 | 267 |
| 267 #if defined(OS_CHROMEOS) | 268 #if defined(OS_CHROMEOS) || (defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| 268 // TODO(sanjeevr): http://crbug.com/79837 | 269 // TODO(sanjeevr): http://crbug.com/79837 |
| 269 #define MAYBE_FindAndCopy DISABLED_FindAndCopy | 270 #define MAYBE_FindAndCopy DISABLED_FindAndCopy |
| 270 #else | 271 #else |
| 271 #define MAYBE_FindAndCopy FindAndCopy | 272 #define MAYBE_FindAndCopy FindAndCopy |
| 272 #endif | 273 #endif |
| 273 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_FindAndCopy) { | 274 IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_FindAndCopy) { |
| 274 ASSERT_NO_FATAL_FAILURE(Load()); | 275 ASSERT_NO_FATAL_FAILURE(Load()); |
| 275 // Verifies that find in page works. | 276 // Verifies that find in page works. |
| 276 ASSERT_EQ(3, ui_test_utils::FindInPage( | 277 ASSERT_EQ(3, ui_test_utils::FindInPage( |
| 277 browser()->tab_strip_model()->GetActiveWebContents(), | 278 browser()->tab_strip_model()->GetActiveWebContents(), |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 browser()->tab_strip_model()->GetActiveWebContents(), | 417 browser()->tab_strip_model()->GetActiveWebContents(), |
| 417 "reloadPDF();")); | 418 "reloadPDF();")); |
| 418 observer.Wait(); | 419 observer.Wait(); |
| 419 | 420 |
| 420 ASSERT_EQ("success", | 421 ASSERT_EQ("success", |
| 421 browser()->tab_strip_model()->GetActiveWebContents()-> | 422 browser()->tab_strip_model()->GetActiveWebContents()-> |
| 422 GetURL().query()); | 423 GetURL().query()); |
| 423 } | 424 } |
| 424 | 425 |
| 425 } // namespace | 426 } // namespace |
| OLD | NEW |