diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-14 20:48:07 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-14 20:48:07 +0000 |
commit | f017cc9f926a81638e324b51bd418ac7f7feeee0 (patch) | |
tree | 8db77306164b5d4498eac4ae729753095430a2e5 /chrome/browser/browser_theme_provider_unittest.cc | |
parent | 3396dc0d719aeca9d4593dfe0f1ab62cdac1629f (diff) | |
download | chromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.zip chromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.tar.gz chromium_src-f017cc9f926a81638e324b51bd418ac7f7feeee0.tar.bz2 |
Try 2: Completely redo how themes are stored on disk and processed at install time.
Same as previous patch, except we now have a
BrowserThemeProvider::GetDefaultDisplayProperty() so we don't have UMRs in
ntp_resource_cache.cc.
BUG=24493,21121
TEST=All the new unit tests pass. All the complex theme startup tests go faster.
Previous Review URL: http://codereview.chromium.org/460050
Review URL: http://codereview.chromium.org/499004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider_unittest.cc')
-rw-r--r-- | chrome/browser/browser_theme_provider_unittest.cc | 179 |
1 files changed, 2 insertions, 177 deletions
diff --git a/chrome/browser/browser_theme_provider_unittest.cc b/chrome/browser/browser_theme_provider_unittest.cc index 6556a56..533c7af 100644 --- a/chrome/browser/browser_theme_provider_unittest.cc +++ b/chrome/browser/browser_theme_provider_unittest.cc @@ -8,87 +8,7 @@ #include "base/values.h" #include "base/json/json_reader.h" -class BrowserThemeProviderTest : public ::testing::Test { - public: - // Transformation for link underline colors. - SkColor BuildThirdOpacity(SkColor color_link) { - return SkColorSetA(color_link, SkColorGetA(color_link) / 3); - } - - // Returns a mapping from each COLOR_* constant to the default value for this - // constant. Callers get this map, and then modify expected values and then - // run the resulting thing through VerifyColorMap(). - std::map<int, SkColor> GetDefaultColorMap() { - std::map<int, SkColor> colors; - colors[BrowserThemeProvider::COLOR_FRAME] = - BrowserThemeProvider::kDefaultColorFrame; - colors[BrowserThemeProvider::COLOR_FRAME_INACTIVE] = - BrowserThemeProvider::kDefaultColorFrameInactive; - colors[BrowserThemeProvider::COLOR_FRAME_INCOGNITO] = - BrowserThemeProvider::kDefaultColorFrameIncognito; - colors[BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE] = - BrowserThemeProvider::kDefaultColorFrameIncognitoInactive; - colors[BrowserThemeProvider::COLOR_TOOLBAR] = - BrowserThemeProvider::kDefaultColorToolbar; - colors[BrowserThemeProvider::COLOR_TAB_TEXT] = - BrowserThemeProvider::kDefaultColorTabText; - colors[BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT] = - BrowserThemeProvider::kDefaultColorBackgroundTabText; - colors[BrowserThemeProvider::COLOR_BOOKMARK_TEXT] = - BrowserThemeProvider::kDefaultColorBookmarkText; - colors[BrowserThemeProvider::COLOR_NTP_BACKGROUND] = - BrowserThemeProvider::kDefaultColorNTPBackground; - colors[BrowserThemeProvider::COLOR_NTP_TEXT] = - BrowserThemeProvider::kDefaultColorNTPText; - colors[BrowserThemeProvider::COLOR_NTP_LINK] = - BrowserThemeProvider::kDefaultColorNTPLink; - colors[BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE] = - BuildThirdOpacity(BrowserThemeProvider::kDefaultColorNTPLink); - colors[BrowserThemeProvider::COLOR_NTP_HEADER] = - BrowserThemeProvider::kDefaultColorNTPHeader; - colors[BrowserThemeProvider::COLOR_NTP_SECTION] = - BrowserThemeProvider::kDefaultColorNTPSection; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_TEXT] = - BrowserThemeProvider::kDefaultColorNTPSectionText; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK] = - BrowserThemeProvider::kDefaultColorNTPSectionLink; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE] = - BuildThirdOpacity(BrowserThemeProvider::kDefaultColorNTPSectionLink); - colors[BrowserThemeProvider::COLOR_CONTROL_BACKGROUND] = - BrowserThemeProvider::kDefaultColorControlBackground; - colors[BrowserThemeProvider::COLOR_BUTTON_BACKGROUND] = - BrowserThemeProvider::kDefaultColorButtonBackground; - - return colors; - } - - void VerifyColorMap(const std::map<int, SkColor>& color_map) { - for (std::map<int, SkColor>::const_iterator it = color_map.begin(); - it != color_map.end(); ++it) { - EXPECT_EQ(it->second, provider_.GetColor(it->first)); - } - } - - void LoadColorJSON(const std::string& json) { - scoped_ptr<Value> value(base::JSONReader::Read(json, false)); - ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); - provider_.SetColorData(static_cast<DictionaryValue*>(value.get())); - } - - void LoadTintJSON(const std::string& json) { - scoped_ptr<Value> value(base::JSONReader::Read(json, false)); - ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); - provider_.SetTintData(static_cast<DictionaryValue*>(value.get())); - } - - void GenerateFrameColors() { - provider_.GenerateFrameColors(); - } - - BrowserThemeProvider provider_; -}; - -TEST_F(BrowserThemeProviderTest, AlignmentConversion) { +TEST(BrowserThemeProviderTest, AlignmentConversion) { // Verify that we get out what we put in. std::string top_left = "top left"; int alignment = BrowserThemeProvider::StringToAlignment(top_left); @@ -113,7 +33,7 @@ TEST_F(BrowserThemeProviderTest, AlignmentConversion) { EXPECT_EQ("", BrowserThemeProvider::AlignmentToString(alignment)); } -TEST_F(BrowserThemeProviderTest, AlignmentConversionInput) { +TEST(BrowserThemeProviderTest, AlignmentConversionInput) { // Verify that we output in an expected format. int alignment = BrowserThemeProvider::StringToAlignment("right bottom"); EXPECT_EQ("bottom right", BrowserThemeProvider::AlignmentToString(alignment)); @@ -130,98 +50,3 @@ TEST_F(BrowserThemeProviderTest, AlignmentConversionInput) { alignment = BrowserThemeProvider::StringToAlignment("new zealandtop"); EXPECT_EQ("", BrowserThemeProvider::AlignmentToString(alignment)); } - -TEST_F(BrowserThemeProviderTest, ColorSanityCheck) { - // Make sure that BrowserThemeProvider returns all the default colors if it - // isn't provided any color overrides. - std::map<int, SkColor> colors = GetDefaultColorMap(); - VerifyColorMap(colors); -} - -TEST_F(BrowserThemeProviderTest, DeriveUnderlineLinkColor) { - // If we specify a link color, but don't specify the underline color, the - // theme provider should create one. - std::string color_json = "{ \"ntp_link\": [128, 128, 128, 1]," - " \"ntp_section_link\": [128, 128, 128, 1] }"; - LoadColorJSON(color_json); - - std::map<int, SkColor> colors = GetDefaultColorMap(); - SkColor link_color = SkColorSetARGB(255, 128, 128, 128); - colors[BrowserThemeProvider::COLOR_NTP_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE] = - BuildThirdOpacity(link_color); - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE] = - BuildThirdOpacity(link_color); - - VerifyColorMap(colors); -} - -TEST_F(BrowserThemeProviderTest, ProvideUnderlineLinkColor) { - // If we specify the underline color, it shouldn't try to generate one.x - std::string color_json = "{ \"ntp_link\": [128, 128, 128]," - " \"ntp_link_underline\": [255, 255, 255]," - " \"ntp_section_link\": [128, 128, 128]," - " \"ntp_section_link_underline\": [255, 255, 255]" - "}"; - LoadColorJSON(color_json); - - std::map<int, SkColor> colors = GetDefaultColorMap(); - SkColor link_color = SkColorSetRGB(128, 128, 128); - SkColor underline_color = SkColorSetRGB(255, 255, 255); - colors[BrowserThemeProvider::COLOR_NTP_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE] = underline_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK] = link_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE] = - underline_color; - - VerifyColorMap(colors); -} - -TEST_F(BrowserThemeProviderTest, UseSectionColorAsNTPHeader) { - std::string color_json = "{ \"ntp_section\": [190, 190, 190] }"; - LoadColorJSON(color_json); - - std::map<int, SkColor> colors = GetDefaultColorMap(); - SkColor ntp_color = SkColorSetRGB(190, 190, 190); - colors[BrowserThemeProvider::COLOR_NTP_HEADER] = ntp_color; - colors[BrowserThemeProvider::COLOR_NTP_SECTION] = ntp_color; - VerifyColorMap(colors); -} - -TEST_F(BrowserThemeProviderTest, ProvideNtpHeaderColor) { - std::string color_json = "{ \"ntp_header\": [120, 120, 120], " - " \"ntp_section\": [190, 190, 190] }"; - LoadColorJSON(color_json); - - std::map<int, SkColor> colors = GetDefaultColorMap(); - SkColor ntp_header = SkColorSetRGB(120, 120, 120); - SkColor ntp_section = SkColorSetRGB(190, 190, 190); - colors[BrowserThemeProvider::COLOR_NTP_HEADER] = ntp_header; - colors[BrowserThemeProvider::COLOR_NTP_SECTION] = ntp_section; - VerifyColorMap(colors); -} - -TEST_F(BrowserThemeProviderTest, DefaultTintingDefaultColors) { - // Default tints for buttons and frames...are no tints! So make sure that - // when we try to generate frame colors, we end up with the same. - GenerateFrameColors(); - - std::map<int, SkColor> colors = GetDefaultColorMap(); - colors[BrowserThemeProvider::COLOR_FRAME] = - HSLShift(BrowserThemeProvider::kDefaultColorFrame, - BrowserThemeProvider::kDefaultTintFrame); - colors[BrowserThemeProvider::COLOR_FRAME_INACTIVE] = - HSLShift(BrowserThemeProvider::kDefaultColorFrame, - BrowserThemeProvider::kDefaultTintFrameInactive); - colors[BrowserThemeProvider::COLOR_FRAME_INCOGNITO] = - HSLShift(BrowserThemeProvider::kDefaultColorFrame, - BrowserThemeProvider::kDefaultTintFrameIncognito); - colors[BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE] = - HSLShift(BrowserThemeProvider::kDefaultColorFrame, - BrowserThemeProvider::kDefaultTintFrameIncognitoInactive); - VerifyColorMap(colors); -} - -// TODO(erg): Test more tinting combinations. For example, with non-default -// colors or when providing tints. |