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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void VerifyColorMap(const std::map<int, SkColor>& color_map) { | 72 void VerifyColorMap(const std::map<int, SkColor>& color_map) { |
73 for (std::map<int, SkColor>::const_iterator it = color_map.begin(); | 73 for (std::map<int, SkColor>::const_iterator it = color_map.begin(); |
74 it != color_map.end(); ++it) { | 74 it != color_map.end(); ++it) { |
75 SkColor color = ThemeService::GetDefaultColor(it->first); | 75 SkColor color = ThemeService::GetDefaultColor(it->first); |
76 theme_pack_->GetColor(it->first, &color); | 76 theme_pack_->GetColor(it->first, &color); |
77 EXPECT_EQ(it->second, color) << "Color id = " << it->first; | 77 EXPECT_EQ(it->second, color) << "Color id = " << it->first; |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 void LoadColorJSON(const std::string& json) { | 81 void LoadColorJSON(const std::string& json) { |
82 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 82 scoped_ptr<Value> value(base::JSONReader::Read(json)); |
83 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 83 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); |
84 LoadColorDictionary(static_cast<DictionaryValue*>(value.get())); | 84 LoadColorDictionary(static_cast<DictionaryValue*>(value.get())); |
85 } | 85 } |
86 | 86 |
87 void LoadColorDictionary(DictionaryValue* value) { | 87 void LoadColorDictionary(DictionaryValue* value) { |
88 theme_pack_->BuildColorsFromJSON(value); | 88 theme_pack_->BuildColorsFromJSON(value); |
89 } | 89 } |
90 | 90 |
91 void LoadTintJSON(const std::string& json) { | 91 void LoadTintJSON(const std::string& json) { |
92 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 92 scoped_ptr<Value> value(base::JSONReader::Read(json)); |
93 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 93 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); |
94 LoadTintDictionary(static_cast<DictionaryValue*>(value.get())); | 94 LoadTintDictionary(static_cast<DictionaryValue*>(value.get())); |
95 } | 95 } |
96 | 96 |
97 void LoadTintDictionary(DictionaryValue* value) { | 97 void LoadTintDictionary(DictionaryValue* value) { |
98 theme_pack_->BuildTintsFromJSON(value); | 98 theme_pack_->BuildTintsFromJSON(value); |
99 } | 99 } |
100 | 100 |
101 void LoadDisplayPropertiesJSON(const std::string& json) { | 101 void LoadDisplayPropertiesJSON(const std::string& json) { |
102 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 102 scoped_ptr<Value> value(base::JSONReader::Read(json)); |
103 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 103 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); |
104 LoadDisplayPropertiesDictionary(static_cast<DictionaryValue*>(value.get())); | 104 LoadDisplayPropertiesDictionary(static_cast<DictionaryValue*>(value.get())); |
105 } | 105 } |
106 | 106 |
107 void LoadDisplayPropertiesDictionary(DictionaryValue* value) { | 107 void LoadDisplayPropertiesDictionary(DictionaryValue* value) { |
108 theme_pack_->BuildDisplayPropertiesFromJSON(value); | 108 theme_pack_->BuildDisplayPropertiesFromJSON(value); |
109 } | 109 } |
110 | 110 |
111 void ParseImageNamesJSON(const std::string& json, | 111 void ParseImageNamesJSON(const std::string& json, |
112 std::map<int, FilePath>* out_file_paths) { | 112 std::map<int, FilePath>* out_file_paths) { |
113 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); | 113 scoped_ptr<Value> value(base::JSONReader::Read(json)); |
114 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); | 114 ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); |
115 ParseImageNamesDictionary(static_cast<DictionaryValue*>(value.get()), | 115 ParseImageNamesDictionary(static_cast<DictionaryValue*>(value.get()), |
116 out_file_paths); | 116 out_file_paths); |
117 } | 117 } |
118 | 118 |
119 void ParseImageNamesDictionary(DictionaryValue* value, | 119 void ParseImageNamesDictionary(DictionaryValue* value, |
120 std::map<int, FilePath>* out_file_paths) { | 120 std::map<int, FilePath>* out_file_paths) { |
121 theme_pack_->ParseImageNamesFromJSON(value, FilePath(), out_file_paths); | 121 theme_pack_->ParseImageNamesFromJSON(value, FilePath(), out_file_paths); |
122 | 122 |
123 // Build the source image list for HasCustomImage(). | 123 // Build the source image list for HasCustomImage(). |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 423 |
424 // Part 2: Try to read back the data pack that we just wrote to disk. | 424 // Part 2: Try to read back the data pack that we just wrote to disk. |
425 { | 425 { |
426 scoped_refptr<BrowserThemePack> pack = | 426 scoped_refptr<BrowserThemePack> pack = |
427 BrowserThemePack::BuildFromDataPack( | 427 BrowserThemePack::BuildFromDataPack( |
428 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); | 428 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); |
429 ASSERT_TRUE(pack.get()); | 429 ASSERT_TRUE(pack.get()); |
430 VerifyStarGazing(pack.get()); | 430 VerifyStarGazing(pack.get()); |
431 } | 431 } |
432 } | 432 } |
OLD | NEW |