| 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 13 matching lines...) Expand all Loading... |
| 24 #include "content/public/browser/readback_types.h" | 24 #include "content/public/browser/readback_types.h" |
| 25 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
| 26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/render_widget_host.h" | 27 #include "content/public/browser/render_widget_host.h" |
| 28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/test/browser_test_utils.h" | 29 #include "content/public/test/browser_test_utils.h" |
| 30 #include "content/public/test/ppapi_test_utils.h" | 30 #include "content/public/test/ppapi_test_utils.h" |
| 31 #include "net/test/embedded_test_server/embedded_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 32 #include "net/test/embedded_test_server/http_request.h" | 32 #include "net/test/embedded_test_server/http_request.h" |
| 33 #include "net/test/embedded_test_server/http_response.h" | 33 #include "net/test/embedded_test_server/http_response.h" |
| 34 #include "ppapi/shared_impl/ppapi_switches.h" | |
| 35 #include "third_party/WebKit/public/web/WebInputEvent.h" | 34 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 36 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
| 37 #include "ui/base/window_open_disposition.h" | 36 #include "ui/base/window_open_disposition.h" |
| 38 #include "ui/display/display.h" | 37 #include "ui/display/display.h" |
| 39 #include "ui/display/display_switches.h" | 38 #include "ui/display/display_switches.h" |
| 40 #include "ui/display/screen.h" | 39 #include "ui/display/screen.h" |
| 41 #include "ui/gfx/codec/png_codec.h" | 40 #include "ui/gfx/codec/png_codec.h" |
| 42 #include "ui/gfx/geometry/point.h" | 41 #include "ui/gfx/geometry/point.h" |
| 43 | 42 |
| 44 namespace { | 43 namespace { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 InProcessBrowserTest::SetUpOnMainThread(); | 266 InProcessBrowserTest::SetUpOnMainThread(); |
| 268 ASSERT_TRUE(embedded_test_server()->Start()); | 267 ASSERT_TRUE(embedded_test_server()->Start()); |
| 269 | 268 |
| 270 embedded_test_server()->ServeFilesFromDirectory( | 269 embedded_test_server()->ServeFilesFromDirectory( |
| 271 ui_test_utils::GetTestFilePath( | 270 ui_test_utils::GetTestFilePath( |
| 272 base::FilePath(FILE_PATH_LITERAL("plugin_power_saver")), | 271 base::FilePath(FILE_PATH_LITERAL("plugin_power_saver")), |
| 273 base::FilePath())); | 272 base::FilePath())); |
| 274 } | 273 } |
| 275 | 274 |
| 276 void SetUpCommandLine(base::CommandLine* command_line) override { | 275 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 277 command_line->AppendSwitch(switches::kEnablePepperTesting); | |
| 278 command_line->AppendSwitch(switches::kEnablePluginPlaceholderTesting); | 276 command_line->AppendSwitch(switches::kEnablePluginPlaceholderTesting); |
| 279 command_line->AppendSwitchASCII( | |
| 280 switches::kOverridePluginPowerSaverForTesting, "ignore-list"); | |
| 281 | |
| 282 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); | 277 ASSERT_TRUE(ppapi::RegisterPowerSaverTestPlugin(command_line)); |
| 283 | 278 |
| 284 // Allows us to use the same reference image on HiDPI/Retina displays. | 279 // Allows us to use the same reference image on HiDPI/Retina displays. |
| 285 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); | 280 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); |
| 286 | 281 |
| 287 // The pixel tests run more reliably in software mode. | 282 // The pixel tests run more reliably in software mode. |
| 288 if (PixelTestsEnabled()) | 283 if (PixelTestsEnabled()) |
| 289 command_line->AppendSwitch(switches::kDisableGpu); | 284 command_line->AppendSwitch(switches::kDisableGpu); |
| 290 } | 285 } |
| 291 | 286 |
| 292 void SetUpInProcessBrowserTestFixture() override { | 287 void SetUpInProcessBrowserTestFixture() override { |
| 293 // Although this is redundant with the Field Trial testing configuration, | 288 // Although this is redundant with the Field Trial testing configuration, |
| 294 // the official builders don't use those, so we also enable it here. | 289 // the official builders don't use those, so we also enable it here. |
| 295 feature_list.InitAndEnableFeature(features::kBlockSmallContent); | 290 feature_list.InitAndEnableFeature(features::kBlockSmallContent); |
| 291 |
| 292 // Disable HTML5 By Default feature to test Plugin Power Saver specifically. |
| 293 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); |
| 296 } | 294 } |
| 297 | 295 |
| 298 protected: | 296 protected: |
| 299 void LoadHTML(const std::string& html) { | 297 void LoadHTML(const std::string& html) { |
| 300 if (PixelTestsEnabled()) { | 298 if (PixelTestsEnabled()) { |
| 301 gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight)); | 299 gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight)); |
| 302 gfx::Rect screen_bounds = | 300 gfx::Rect screen_bounds = |
| 303 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 301 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 304 ASSERT_GT(screen_bounds.width(), kBrowserWidth); | 302 ASSERT_GT(screen_bounds.width(), kBrowserWidth); |
| 305 ASSERT_GT(screen_bounds.height(), kBrowserHeight); | 303 ASSERT_GT(screen_bounds.height(), kBrowserHeight); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential"); | 717 VerifyPluginMarkedEssential(GetActiveWebContents(), "expand_to_essential"); |
| 720 } | 718 } |
| 721 | 719 |
| 722 // Separate test case that allows tiny plugins. This requires a separate test | 720 // Separate test case that allows tiny plugins. This requires a separate test |
| 723 // case, because we need to initialize the renderer with a different feature | 721 // case, because we need to initialize the renderer with a different feature |
| 724 // setting. | 722 // setting. |
| 725 class PluginPowerSaverAllowTinyBrowserTest | 723 class PluginPowerSaverAllowTinyBrowserTest |
| 726 : public PluginPowerSaverBrowserTest { | 724 : public PluginPowerSaverBrowserTest { |
| 727 public: | 725 public: |
| 728 void SetUpInProcessBrowserTestFixture() override { | 726 void SetUpInProcessBrowserTestFixture() override { |
| 727 PluginPowerSaverBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 729 feature_list.InitAndDisableFeature(features::kBlockSmallContent); | 728 feature_list.InitAndDisableFeature(features::kBlockSmallContent); |
| 730 } | 729 } |
| 731 | 730 |
| 732 private: | 731 private: |
| 733 base::test::ScopedFeatureList feature_list; | 732 base::test::ScopedFeatureList feature_list; |
| 734 }; | 733 }; |
| 735 | 734 |
| 736 IN_PROC_BROWSER_TEST_F(PluginPowerSaverAllowTinyBrowserTest, | 735 IN_PROC_BROWSER_TEST_F(PluginPowerSaverAllowTinyBrowserTest, |
| 737 EssentialTinyPlugins) { | 736 EssentialTinyPlugins) { |
| 738 LoadHTML( | 737 LoadHTML( |
| 739 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' " | 738 "<object id='tiny_cross_origin_1' data='http://a.com/fake.swf' " |
| 740 " type='application/x-ppapi-tests' width='3' height='3'>" | 739 " type='application/x-ppapi-tests' width='3' height='3'>" |
| 741 "</object>" | 740 "</object>" |
| 742 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' " | 741 "<object id='tiny_cross_origin_2' data='http://a.com/fake.swf' " |
| 743 " type='application/x-ppapi-tests' width='1' height='1'>" | 742 " type='application/x-ppapi-tests' width='1' height='1'>" |
| 744 "</object>"); | 743 "</object>"); |
| 745 | 744 |
| 746 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_1"); | 745 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_1"); |
| 747 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_2"); | 746 VerifyPluginMarkedEssential(GetActiveWebContents(), "tiny_cross_origin_2"); |
| 748 } | 747 } |
| OLD | NEW |