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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 // Verifies the data in star gazing. We do this multiple times for different | 206 // Verifies the data in star gazing. We do this multiple times for different |
207 // BrowserThemePack objects to make sure it works in generated and mmapped | 207 // BrowserThemePack objects to make sure it works in generated and mmapped |
208 // mode correctly. | 208 // mode correctly. |
209 void VerifyStarGazing(BrowserThemePack* pack) { | 209 void VerifyStarGazing(BrowserThemePack* pack) { |
210 // First check that values we know exist, exist. | 210 // First check that values we know exist, exist. |
211 SkColor color; | 211 SkColor color; |
212 EXPECT_TRUE(pack->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT, | 212 EXPECT_TRUE(pack->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT, |
213 &color)); | 213 &color)); |
214 EXPECT_EQ(SK_ColorBLACK, color); | 214 EXPECT_EQ(SK_ColorBLACK, color); |
215 | 215 |
216 EXPECT_TRUE( | |
217 pack->GetColor(ThemeProperties::COLOR_CONTROL_BACKGROUND, &color)); | |
218 EXPECT_EQ(SkColorSetRGB(10, 234, 123), color); | |
219 | |
216 EXPECT_TRUE(pack->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND, | 220 EXPECT_TRUE(pack->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND, |
217 &color)); | 221 &color)); |
218 EXPECT_EQ(SkColorSetRGB(57, 137, 194), color); | 222 EXPECT_EQ(SkColorSetRGB(57, 137, 194), color); |
219 | 223 |
220 color_utils::HSL expected = { 0.6, 0.553, 0.5 }; | 224 color_utils::HSL expected = { 0.6, 0.553, 0.5 }; |
221 color_utils::HSL actual; | 225 color_utils::HSL actual; |
222 EXPECT_TRUE(pack->GetTint(ThemeProperties::TINT_BUTTONS, &actual)); | 226 EXPECT_TRUE(pack->GetTint(ThemeProperties::TINT_BUTTONS, &actual)); |
223 EXPECT_DOUBLE_EQ(expected.h, actual.h); | 227 EXPECT_DOUBLE_EQ(expected.h, actual.h); |
224 EXPECT_DOUBLE_EQ(expected.s, actual.s); | 228 EXPECT_DOUBLE_EQ(expected.s, actual.s); |
225 EXPECT_DOUBLE_EQ(expected.l, actual.l); | 229 EXPECT_DOUBLE_EQ(expected.l, actual.l); |
(...skipping 14 matching lines...) Expand all Loading... | |
240 // Here are a few images that we shouldn't expect because even though | 244 // Here are a few images that we shouldn't expect because even though |
241 // they're included in the theme pack, they were autogenerated and | 245 // they're included in the theme pack, they were autogenerated and |
242 // therefore shouldn't show up when calling HasCustomImage(). | 246 // therefore shouldn't show up when calling HasCustomImage(). |
243 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INACTIVE)); | 247 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INACTIVE)); |
244 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO)); | 248 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO)); |
245 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO_INACTIVE)); | 249 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO_INACTIVE)); |
246 #if !defined(OS_MACOSX) | 250 #if !defined(OS_MACOSX) |
247 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_TAB_BACKGROUND_INCOGNITO)); | 251 EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_TAB_BACKGROUND_INCOGNITO)); |
248 #endif | 252 #endif |
249 | 253 |
250 // Make sure we don't have phantom data. | |
Peter Kasting
2016/06/10 01:12:24
Why did this comment disappear?
Julien Isorce Samsung
2016/06/10 09:51:37
Oups, I'll add it back. Thx
| |
251 EXPECT_FALSE(pack->GetColor(ThemeProperties::COLOR_CONTROL_BACKGROUND, | |
252 &color)); | |
253 EXPECT_FALSE(pack->GetTint(ThemeProperties::TINT_FRAME, &actual)); | 254 EXPECT_FALSE(pack->GetTint(ThemeProperties::TINT_FRAME, &actual)); |
254 } | 255 } |
255 | 256 |
256 void VerifyHiDpiTheme(BrowserThemePack* pack) { | 257 void VerifyHiDpiTheme(BrowserThemePack* pack) { |
257 // The high DPI theme defines the following images: | 258 // The high DPI theme defines the following images: |
258 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME)); | 259 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME)); |
259 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INACTIVE)); | 260 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INACTIVE)); |
260 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO)); | 261 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO)); |
261 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO_INACTIVE)); | 262 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO_INACTIVE)); |
262 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_TOOLBAR)); | 263 EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_TOOLBAR)); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 } | 651 } |
651 | 652 |
652 // Part 2: Try to read back the data pack that we just wrote to disk. | 653 // Part 2: Try to read back the data pack that we just wrote to disk. |
653 { | 654 { |
654 scoped_refptr<BrowserThemePack> pack = | 655 scoped_refptr<BrowserThemePack> pack = |
655 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); | 656 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); |
656 ASSERT_TRUE(pack.get()); | 657 ASSERT_TRUE(pack.get()); |
657 VerifyHiDpiTheme(pack.get()); | 658 VerifyHiDpiTheme(pack.get()); |
658 } | 659 } |
659 } | 660 } |
OLD | NEW |