Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 base::Bind(&CompareSnapshotToReference, reference, &snapshot_matches, | 375 base::Bind(&CompareSnapshotToReference, reference, &snapshot_matches, |
| 376 base::MessageLoop::QuitWhenIdleClosure()), | 376 base::MessageLoop::QuitWhenIdleClosure()), |
| 377 kN32_SkColorType); | 377 kN32_SkColorType); |
| 378 | 378 |
| 379 content::RunMessageLoop(); | 379 content::RunMessageLoop(); |
| 380 | 380 |
| 381 return snapshot_matches; | 381 return snapshot_matches; |
| 382 } | 382 } |
| 383 | 383 |
| 384 // TODO(tommycli): Remove this once all flakiness resolved. | 384 // TODO(tommycli): Remove this once all flakiness resolved. |
| 385 bool PixelTestsEnabled() { | 385 bool PixelTestsEnabled() { |
|
tommycli
2016/12/15 20:32:36
Can you disable the test here? (i.e. does disablin
| |
| 386 #if defined(OS_WIN) || defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) | 386 #if defined(OS_WIN) || defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) |
| 387 // Flaky on Windows, Asan, and Msan bots. | 387 // Flaky on Windows, Asan, and Msan bots. |
| 388 // See crbug.com/549285 and crbug.com/512140. | 388 // See crbug.com/549285 and crbug.com/512140. |
| 389 return false; | 389 return false; |
| 390 #elif defined(OS_CHROMEOS) | 390 #elif defined(OS_CHROMEOS) |
| 391 // Because ChromeOS cannot use software rendering and the pixel tests | 391 // Because ChromeOS cannot use software rendering and the pixel tests |
| 392 // continue to flake with hardware acceleration, disable these on ChromeOS. | 392 // continue to flake with hardware acceleration, disable these on ChromeOS. |
| 393 return false; | 393 return false; |
| 394 #else | 394 #else |
| 395 return true; | 395 return true; |
| 396 #endif | 396 #endif |
| 397 } | 397 } |
| 398 | 398 |
| 399 private: | 399 private: |
| 400 base::test::ScopedFeatureList feature_list; | 400 base::test::ScopedFeatureList feature_list; |
| 401 }; | 401 }; |
| 402 | 402 |
| 403 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, EssentialPlugins) { | 403 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, EssentialPlugins) { |
| 404 LoadHTML("/essential_plugins.html"); | 404 LoadHTML("/essential_plugins.html"); |
| 405 | 405 |
| 406 VerifyPluginMarkedEssential(GetActiveWebContents(), "small_same_origin"); | 406 VerifyPluginMarkedEssential(GetActiveWebContents(), "small_same_origin"); |
| 407 VerifyPluginMarkedEssential(GetActiveWebContents(), | 407 VerifyPluginMarkedEssential(GetActiveWebContents(), |
| 408 "small_same_origin_poster"); | 408 "small_same_origin_poster"); |
| 409 VerifyPluginMarkedEssential(GetActiveWebContents(), "large_cross_origin"); | 409 VerifyPluginMarkedEssential(GetActiveWebContents(), "large_cross_origin"); |
| 410 VerifyPluginMarkedEssential(GetActiveWebContents(), | 410 VerifyPluginMarkedEssential(GetActiveWebContents(), |
| 411 "medium_16_9_cross_origin"); | 411 "medium_16_9_cross_origin"); |
| 412 } | 412 } |
| 413 | 413 |
| 414 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, SmallCrossOrigin) { | 414 // This test fail on macOS 10.12. https://crbug.com/599484. |
| 415 #if defined(OS_MACOSX) | |
| 416 #define MAYBE_SmallCrossOrigin DISABLED_SmallCrossOrigin | |
| 417 #else | |
| 418 #define MAYBE_SmallCrossOrigin SmallCrossOrigin | |
| 419 #endif | |
| 420 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_SmallCrossOrigin) { | |
| 415 LoadHTML("/small_cross_origin.html"); | 421 LoadHTML("/small_cross_origin.html"); |
| 416 | 422 |
| 417 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 423 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 418 VerifyPluginIsPlaceholderOnly("plugin_poster"); | 424 VerifyPluginIsPlaceholderOnly("plugin_poster"); |
| 419 | 425 |
| 420 EXPECT_TRUE( | 426 EXPECT_TRUE( |
| 421 VerifySnapshot(FILE_PATH_LITERAL("small_cross_origin_expected.png"))); | 427 VerifySnapshot(FILE_PATH_LITERAL("small_cross_origin_expected.png"))); |
| 422 | 428 |
| 423 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50)); | 429 SimulateClickAndAwaitMarkedEssential("plugin", gfx::Point(50, 50)); |
| 424 SimulateClickAndAwaitMarkedEssential("plugin_poster", gfx::Point(50, 150)); | 430 SimulateClickAndAwaitMarkedEssential("plugin_poster", gfx::Point(50, 150)); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 446 | 452 |
| 447 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16"); | 453 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16"); |
| 448 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_32"); | 454 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_32"); |
| 449 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16_64"); | 455 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_16_64"); |
| 450 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_64_16"); | 456 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin_64_16"); |
| 451 | 457 |
| 452 EXPECT_TRUE( | 458 EXPECT_TRUE( |
| 453 VerifySnapshot(FILE_PATH_LITERAL("smaller_than_play_icon_expected.png"))); | 459 VerifySnapshot(FILE_PATH_LITERAL("smaller_than_play_icon_expected.png"))); |
| 454 } | 460 } |
| 455 | 461 |
| 456 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, PosterTests) { | 462 // This test fail on macOS 10.12. https://crbug.com/599484. |
| 463 #if defined(OS_MACOSX) | |
| 464 #define MAYBE_PosterTests DISABLED_PosterTests | |
| 465 #else | |
| 466 #define MAYBE_PosterTests PosterTests | |
| 467 #endif | |
| 468 IN_PROC_BROWSER_TEST_F(PluginPowerSaverBrowserTest, MAYBE_PosterTests) { | |
| 457 // This test simultaneously verifies the varied supported poster syntaxes, | 469 // This test simultaneously verifies the varied supported poster syntaxes, |
| 458 // as well as verifies that the poster is rendered correctly with various | 470 // as well as verifies that the poster is rendered correctly with various |
| 459 // mismatched aspect ratios and sizes, following the same rules as VIDEO. | 471 // mismatched aspect ratios and sizes, following the same rules as VIDEO. |
| 460 LoadHTML("/poster_tests.html"); | 472 LoadHTML("/poster_tests.html"); |
| 461 | 473 |
| 462 VerifyPluginIsPlaceholderOnly("plugin_src"); | 474 VerifyPluginIsPlaceholderOnly("plugin_src"); |
| 463 VerifyPluginIsPlaceholderOnly("plugin_srcset"); | 475 VerifyPluginIsPlaceholderOnly("plugin_srcset"); |
| 464 | 476 |
| 465 VerifyPluginIsPlaceholderOnly("plugin_poster_param"); | 477 VerifyPluginIsPlaceholderOnly("plugin_poster_param"); |
| 466 VerifyPluginIsPlaceholderOnly("plugin_embed_src"); | 478 VerifyPluginIsPlaceholderOnly("plugin_embed_src"); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, | 611 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, |
| 600 ThrottlePluginsOnAllowContentSetting) { | 612 ThrottlePluginsOnAllowContentSetting) { |
| 601 HostContentSettingsMap* content_settings_map = | 613 HostContentSettingsMap* content_settings_map = |
| 602 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); | 614 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); |
| 603 | 615 |
| 604 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 616 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 605 CONTENT_SETTING_ALLOW); | 617 CONTENT_SETTING_ALLOW); |
| 606 LoadPeripheralPlugin(); | 618 LoadPeripheralPlugin(); |
| 607 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 619 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 608 } | 620 } |
| OLD | NEW |