| 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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
| 15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/extensions/manifest_handler.h" | |
| 17 #include "chrome/common/extensions/manifest_handlers/theme_handler.h" | |
| 18 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 19 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/gfx/color_utils.h" | 19 #include "ui/gfx/color_utils.h" |
| 22 | 20 |
| 23 using content::BrowserThread; | 21 using content::BrowserThread; |
| 24 using extensions::Extension; | 22 using extensions::Extension; |
| 25 | 23 |
| 26 class BrowserThemePackTest : public ::testing::Test { | 24 class BrowserThemePackTest : public ::testing::Test { |
| 27 public: | 25 public: |
| 28 BrowserThemePackTest() | 26 BrowserThemePackTest() |
| 29 : message_loop(), | 27 : message_loop(), |
| 30 fake_ui_thread(BrowserThread::UI, &message_loop), | 28 fake_ui_thread(BrowserThread::UI, &message_loop), |
| 31 fake_file_thread(BrowserThread::FILE, &message_loop), | 29 fake_file_thread(BrowserThread::FILE, &message_loop), |
| 32 theme_pack_(new BrowserThemePack) { | 30 theme_pack_(new BrowserThemePack) { |
| 33 } | 31 } |
| 34 | 32 |
| 35 virtual void SetUp() OVERRIDE { | |
| 36 testing::Test::SetUp(); | |
| 37 (new extensions::ThemeHandler)->Register(); | |
| 38 } | |
| 39 | |
| 40 virtual void TearDown() OVERRIDE { | |
| 41 extensions::ManifestHandler::ClearRegistryForTesting(); | |
| 42 } | |
| 43 | |
| 44 // Transformation for link underline colors. | 33 // Transformation for link underline colors. |
| 45 SkColor BuildThirdOpacity(SkColor color_link) { | 34 SkColor BuildThirdOpacity(SkColor color_link) { |
| 46 return SkColorSetA(color_link, SkColorGetA(color_link) / 3); | 35 return SkColorSetA(color_link, SkColorGetA(color_link) / 3); |
| 47 } | 36 } |
| 48 | 37 |
| 49 void GenerateDefaultFrameColor(std::map<int, SkColor>* colors, | 38 void GenerateDefaultFrameColor(std::map<int, SkColor>* colors, |
| 50 int color, int tint) { | 39 int color, int tint) { |
| 51 (*colors)[color] = HSLShift( | 40 (*colors)[color] = HSLShift( |
| 52 ThemeProperties::GetDefaultColor( | 41 ThemeProperties::GetDefaultColor( |
| 53 ThemeProperties::COLOR_FRAME), | 42 ThemeProperties::COLOR_FRAME), |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 430 |
| 442 // Part 2: Try to read back the data pack that we just wrote to disk. | 431 // Part 2: Try to read back the data pack that we just wrote to disk. |
| 443 { | 432 { |
| 444 scoped_refptr<BrowserThemePack> pack = | 433 scoped_refptr<BrowserThemePack> pack = |
| 445 BrowserThemePack::BuildFromDataPack( | 434 BrowserThemePack::BuildFromDataPack( |
| 446 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); | 435 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); |
| 447 ASSERT_TRUE(pack.get()); | 436 ASSERT_TRUE(pack.get()); |
| 448 VerifyStarGazing(pack.get()); | 437 VerifyStarGazing(pack.get()); |
| 449 } | 438 } |
| 450 } | 439 } |
| OLD | NEW |