| 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" |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/test/scoped_feature_list.h" | 13 #include "base/test/scoped_feature_list.h" |
| 14 #include "base/threading/thread_restrictions.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/common/chrome_features.h" | 20 #include "chrome/common/chrome_features.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "chrome/test/base/test_switches.h" | 23 #include "chrome/test/base/test_switches.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return success; | 214 return success; |
| 214 } | 215 } |
| 215 | 216 |
| 216 // |snapshot_matches| is set to true if the snapshot matches the reference and | 217 // |snapshot_matches| is set to true if the snapshot matches the reference and |
| 217 // the test passes. Otherwise, set to false. | 218 // the test passes. Otherwise, set to false. |
| 218 void CompareSnapshotToReference(const base::FilePath& reference, | 219 void CompareSnapshotToReference(const base::FilePath& reference, |
| 219 bool* snapshot_matches, | 220 bool* snapshot_matches, |
| 220 const base::Closure& done_cb, | 221 const base::Closure& done_cb, |
| 221 const SkBitmap& bitmap, | 222 const SkBitmap& bitmap, |
| 222 content::ReadbackResponse response) { | 223 content::ReadbackResponse response) { |
| 224 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 223 DCHECK(snapshot_matches); | 225 DCHECK(snapshot_matches); |
| 224 ASSERT_EQ(content::READBACK_SUCCESS, response); | 226 ASSERT_EQ(content::READBACK_SUCCESS, response); |
| 225 | 227 |
| 226 *snapshot_matches = SnapshotMatches(reference, bitmap); | 228 *snapshot_matches = SnapshotMatches(reference, bitmap); |
| 227 | 229 |
| 228 // When rebaselining the pixel test, the test may fail. However, the | 230 // When rebaselining the pixel test, the test may fail. However, the |
| 229 // reference file will still be overwritten. | 231 // reference file will still be overwritten. |
| 230 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 232 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 231 switches::kRebaselinePixelTests)) { | 233 switches::kRebaselinePixelTests)) { |
| 232 SkBitmap clipped_bitmap; | 234 SkBitmap clipped_bitmap; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, | 636 IN_PROC_BROWSER_TEST_F(PluginPowerSaverPreferHtmlBrowserTest, |
| 635 ThrottlePluginsOnAllowContentSetting) { | 637 ThrottlePluginsOnAllowContentSetting) { |
| 636 HostContentSettingsMap* content_settings_map = | 638 HostContentSettingsMap* content_settings_map = |
| 637 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); | 639 HostContentSettingsMapFactory::GetForProfile(browser()->profile()); |
| 638 | 640 |
| 639 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 641 content_settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 640 CONTENT_SETTING_ALLOW); | 642 CONTENT_SETTING_ALLOW); |
| 641 LoadPeripheralPlugin(); | 643 LoadPeripheralPlugin(); |
| 642 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); | 644 VerifyPluginIsThrottled(GetActiveWebContents(), "plugin"); |
| 643 } | 645 } |
| OLD | NEW |