| Index: chrome/browser/themes/browser_theme_pack_unittest.cc
|
| diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc
|
| index 22e9d2f905d3f21a714956123c8b34a2a67905bd..1180081f35311306a2f6d63683986c4aaac65bf9 100644
|
| --- a/chrome/browser/themes/browser_theme_pack_unittest.cc
|
| +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc
|
| @@ -10,7 +10,6 @@
|
| #include "base/json/json_file_value_serializer.h"
|
| #include "base/json/json_reader.h"
|
| #include "base/path_service.h"
|
| -#include "base/synchronization/waitable_event.h"
|
| #include "base/values.h"
|
| #include "build/build_config.h"
|
| #include "chrome/browser/themes/theme_properties.h"
|
| @@ -35,16 +34,14 @@
|
|
|
| class BrowserThemePackTest : public ::testing::Test {
|
| public:
|
| - BrowserThemePackTest()
|
| - : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD),
|
| - theme_pack_(new BrowserThemePack()) {
|
| + BrowserThemePackTest() {
|
| std::vector<ui::ScaleFactor> scale_factors;
|
| scale_factors.push_back(ui::SCALE_FACTOR_100P);
|
| scale_factors.push_back(ui::SCALE_FACTOR_200P);
|
| scoped_set_supported_scale_factors_.reset(
|
| - new ui::test::ScopedSetSupportedScaleFactors(scale_factors));
|
| - }
|
| - ~BrowserThemePackTest() override {}
|
| + new ui::test::ScopedSetSupportedScaleFactors(scale_factors));
|
| + theme_pack_ = new BrowserThemePack();
|
| + }
|
|
|
| // Transformation for link underline colors.
|
| SkColor BuildThirdOpacity(SkColor color_link) {
|
| @@ -145,22 +142,33 @@
|
| }
|
|
|
| bool LoadRawBitmapsTo(const TestFilePathMap& out_file_paths) {
|
| - return theme_pack_->LoadRawBitmapsTo(out_file_paths, &theme_pack_->images_);
|
| + return theme_pack_->LoadRawBitmapsTo(out_file_paths,
|
| + &theme_pack_->images_on_ui_thread_);
|
| }
|
|
|
| // This function returns void in order to be able use ASSERT_...
|
| // The BrowserThemePack is returned in |pack|.
|
| void BuildFromUnpackedExtension(const base::FilePath& extension_path,
|
| - scoped_refptr<BrowserThemePack>* pack) {
|
| - io_waiter_.reset(new base::WaitableEvent(
|
| - base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
| - base::WaitableEvent::InitialState::NOT_SIGNALED));
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::IO, FROM_HERE,
|
| - base::Bind(&BrowserThemePackTest::DoBuildFromUnpackedExtension,
|
| - base::Unretained(this), extension_path, pack));
|
| - io_waiter_->Wait();
|
| - ASSERT_TRUE((*pack)->is_valid());
|
| + scoped_refptr<BrowserThemePack>& pack) {
|
| + base::FilePath manifest_path =
|
| + extension_path.AppendASCII("manifest.json");
|
| + std::string error;
|
| + JSONFileValueDeserializer deserializer(manifest_path);
|
| + std::unique_ptr<base::DictionaryValue> valid_value =
|
| + base::DictionaryValue::From(deserializer.Deserialize(NULL, &error));
|
| + EXPECT_EQ("", error);
|
| + ASSERT_TRUE(valid_value.get());
|
| + scoped_refptr<Extension> extension(
|
| + Extension::Create(
|
| + extension_path,
|
| + extensions::Manifest::INVALID_LOCATION,
|
| + *valid_value,
|
| + Extension::REQUIRE_KEY,
|
| + &error));
|
| + ASSERT_TRUE(extension.get());
|
| + ASSERT_EQ("", error);
|
| + pack = BrowserThemePack::BuildFromExtension(extension.get());
|
| + ASSERT_TRUE(pack.get());
|
| }
|
|
|
| base::FilePath GetStarGazingPath() {
|
| @@ -339,33 +347,12 @@
|
| }
|
| }
|
|
|
| - protected:
|
| + content::TestBrowserThreadBundle test_browser_thread_bundle_;
|
| +
|
| typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors>
|
| ScopedSetSupportedScaleFactors;
|
| ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_;
|
| -
|
| - void DoBuildFromUnpackedExtension(const base::FilePath& extension_path,
|
| - scoped_refptr<BrowserThemePack>* pack) {
|
| - base::FilePath manifest_path = extension_path.AppendASCII("manifest.json");
|
| - std::string error;
|
| - JSONFileValueDeserializer deserializer(manifest_path);
|
| - std::unique_ptr<base::DictionaryValue> valid_value =
|
| - base::DictionaryValue::From(deserializer.Deserialize(NULL, &error));
|
| - EXPECT_EQ("", error);
|
| - ASSERT_TRUE(valid_value.get());
|
| - scoped_refptr<Extension> extension(Extension::Create(
|
| - extension_path, extensions::Manifest::INVALID_LOCATION, *valid_value,
|
| - Extension::REQUIRE_KEY, &error));
|
| - ASSERT_TRUE(extension.get());
|
| - ASSERT_EQ("", error);
|
| - *pack = new BrowserThemePack;
|
| - BrowserThemePack::BuildFromExtension(extension.get(), *pack);
|
| - io_waiter_->Signal();
|
| - }
|
| -
|
| - content::TestBrowserThreadBundle thread_bundle_;
|
| scoped_refptr<BrowserThemePack> theme_pack_;
|
| - std::unique_ptr<base::WaitableEvent> io_waiter_;
|
| };
|
|
|
| // 'ntp_section' used to correspond to ThemeProperties::COLOR_NTP_SECTION,
|
| @@ -582,7 +569,7 @@
|
| {
|
| base::FilePath star_gazing_path = GetStarGazingPath();
|
| scoped_refptr<BrowserThemePack> pack;
|
| - BuildFromUnpackedExtension(star_gazing_path, &pack);
|
| + BuildFromUnpackedExtension(star_gazing_path, pack);
|
| ASSERT_TRUE(pack->WriteToDisk(file));
|
| VerifyStarGazing(pack.get());
|
| }
|
| @@ -606,7 +593,7 @@
|
| {
|
| base::FilePath hidpi_path = GetHiDpiThemePath();
|
| scoped_refptr<BrowserThemePack> pack;
|
| - BuildFromUnpackedExtension(hidpi_path, &pack);
|
| + BuildFromUnpackedExtension(hidpi_path, pack);
|
| ASSERT_TRUE(pack->WriteToDisk(file));
|
| VerifyHiDpiTheme(pack.get());
|
| }
|
|
|