| 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/api/themes/theme_handler.h" | 16 #include "chrome/common/extensions/api/themes/theme_handler.h" |
| 17 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 18 #include "chrome/common/extensions/manifest_handler.h" | 17 #include "chrome/common/extensions/manifest_handler.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 20 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/gfx/color_utils.h" | 21 #include "ui/gfx/color_utils.h" |
| 23 | 22 |
| 24 using content::BrowserThread; | 23 using content::BrowserThread; |
| 25 using extensions::Extension; | 24 using extensions::Extension; |
| 26 | 25 |
| 27 class BrowserThemePackTest : public ::testing::Test { | 26 class BrowserThemePackTest : public ::testing::Test { |
| 28 public: | 27 public: |
| 29 BrowserThemePackTest() | 28 BrowserThemePackTest() |
| 30 : message_loop(), | 29 : message_loop(), |
| 31 fake_ui_thread(BrowserThread::UI, &message_loop), | 30 fake_ui_thread(BrowserThread::UI, &message_loop), |
| 32 fake_file_thread(BrowserThread::FILE, &message_loop), | 31 fake_file_thread(BrowserThread::FILE, &message_loop), |
| 33 theme_pack_(new BrowserThemePack) { | 32 theme_pack_(new BrowserThemePack) { |
| 34 } | 33 } |
| 35 | 34 |
| 36 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() OVERRIDE { |
| 37 testing::Test::SetUp(); | 36 testing::Test::SetUp(); |
| 38 extensions::ManifestHandler::Register( | 37 (new extensions::ThemeHandler)->Register(); |
| 39 extension_manifest_keys::kTheme, | 38 } |
| 40 make_linked_ptr(new extensions::ThemeHandler)); | 39 |
| 40 virtual void TearDown() OVERRIDE { |
| 41 extensions::ManifestHandler::ClearRegistryForTesting(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 // Transformation for link underline colors. | 44 // Transformation for link underline colors. |
| 44 SkColor BuildThirdOpacity(SkColor color_link) { | 45 SkColor BuildThirdOpacity(SkColor color_link) { |
| 45 return SkColorSetA(color_link, SkColorGetA(color_link) / 3); | 46 return SkColorSetA(color_link, SkColorGetA(color_link) / 3); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void GenerateDefaultFrameColor(std::map<int, SkColor>* colors, | 49 void GenerateDefaultFrameColor(std::map<int, SkColor>* colors, |
| 49 int color, int tint) { | 50 int color, int tint) { |
| 50 (*colors)[color] = HSLShift( | 51 (*colors)[color] = HSLShift( |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 441 |
| 441 // Part 2: Try to read back the data pack that we just wrote to disk. | 442 // Part 2: Try to read back the data pack that we just wrote to disk. |
| 442 { | 443 { |
| 443 scoped_refptr<BrowserThemePack> pack = | 444 scoped_refptr<BrowserThemePack> pack = |
| 444 BrowserThemePack::BuildFromDataPack( | 445 BrowserThemePack::BuildFromDataPack( |
| 445 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); | 446 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); |
| 446 ASSERT_TRUE(pack.get()); | 447 ASSERT_TRUE(pack.get()); |
| 447 VerifyStarGazing(pack.get()); | 448 VerifyStarGazing(pack.get()); |
| 448 } | 449 } |
| 449 } | 450 } |
| OLD | NEW |