| 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 "chrome/browser/themes/browser_theme_pack.h" | 5 #include "chrome/browser/themes/browser_theme_pack.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 it != color_map.end(); ++it) { | 92 it != color_map.end(); ++it) { |
| 93 SkColor color; | 93 SkColor color; |
| 94 if (!theme_pack_->GetColor(it->first, &color)) | 94 if (!theme_pack_->GetColor(it->first, &color)) |
| 95 color = ThemeProperties::GetDefaultColor(it->first, false); | 95 color = ThemeProperties::GetDefaultColor(it->first, false); |
| 96 EXPECT_EQ(it->second, color) << "Color id = " << it->first; | 96 EXPECT_EQ(it->second, color) << "Color id = " << it->first; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 void LoadColorJSON(const std::string& json) { | 100 void LoadColorJSON(const std::string& json) { |
| 101 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 101 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
| 102 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 102 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
| 103 LoadColorDictionary(static_cast<base::DictionaryValue*>(value.get())); | 103 LoadColorDictionary(static_cast<base::DictionaryValue*>(value.get())); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void LoadColorDictionary(base::DictionaryValue* value) { | 106 void LoadColorDictionary(base::DictionaryValue* value) { |
| 107 theme_pack_->BuildColorsFromJSON(value); | 107 theme_pack_->BuildColorsFromJSON(value); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void LoadTintJSON(const std::string& json) { | 110 void LoadTintJSON(const std::string& json) { |
| 111 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 111 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
| 112 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 112 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
| 113 LoadTintDictionary(static_cast<base::DictionaryValue*>(value.get())); | 113 LoadTintDictionary(static_cast<base::DictionaryValue*>(value.get())); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void LoadTintDictionary(base::DictionaryValue* value) { | 116 void LoadTintDictionary(base::DictionaryValue* value) { |
| 117 theme_pack_->BuildTintsFromJSON(value); | 117 theme_pack_->BuildTintsFromJSON(value); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void LoadDisplayPropertiesJSON(const std::string& json) { | 120 void LoadDisplayPropertiesJSON(const std::string& json) { |
| 121 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 121 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
| 122 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 122 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
| 123 LoadDisplayPropertiesDictionary( | 123 LoadDisplayPropertiesDictionary( |
| 124 static_cast<base::DictionaryValue*>(value.get())); | 124 static_cast<base::DictionaryValue*>(value.get())); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void LoadDisplayPropertiesDictionary(base::DictionaryValue* value) { | 127 void LoadDisplayPropertiesDictionary(base::DictionaryValue* value) { |
| 128 theme_pack_->BuildDisplayPropertiesFromJSON(value); | 128 theme_pack_->BuildDisplayPropertiesFromJSON(value); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void ParseImageNamesJSON(const std::string& json, | 131 void ParseImageNamesJSON(const std::string& json, |
| 132 TestFilePathMap* out_file_paths) { | 132 TestFilePathMap* out_file_paths) { |
| 133 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 133 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
| 134 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 134 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
| 135 ParseImageNamesDictionary(static_cast<base::DictionaryValue*>(value.get()), | 135 ParseImageNamesDictionary(static_cast<base::DictionaryValue*>(value.get()), |
| 136 out_file_paths); | 136 out_file_paths); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void ParseImageNamesDictionary( | 139 void ParseImageNamesDictionary( |
| 140 base::DictionaryValue* value, | 140 base::DictionaryValue* value, |
| 141 TestFilePathMap* out_file_paths) { | 141 TestFilePathMap* out_file_paths) { |
| 142 theme_pack_->ParseImageNamesFromJSON(value, base::FilePath(), | 142 theme_pack_->ParseImageNamesFromJSON(value, base::FilePath(), |
| 143 out_file_paths); | 143 out_file_paths); |
| 144 | 144 |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 652 } |
| 653 | 653 |
| 654 // Part 2: Try to read back the data pack that we just wrote to disk. | 654 // Part 2: Try to read back the data pack that we just wrote to disk. |
| 655 { | 655 { |
| 656 scoped_refptr<BrowserThemePack> pack = | 656 scoped_refptr<BrowserThemePack> pack = |
| 657 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); | 657 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); |
| 658 ASSERT_TRUE(pack.get()); | 658 ASSERT_TRUE(pack.get()); |
| 659 VerifyHiDpiTheme(pack.get()); | 659 VerifyHiDpiTheme(pack.get()); |
| 660 } | 660 } |
| 661 } | 661 } |
| OLD | NEW |