summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_theme_pack_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/browser_theme_pack_unittest.cc')
-rw-r--r--chrome/browser/browser_theme_pack_unittest.cc33
1 files changed, 27 insertions, 6 deletions
diff --git a/chrome/browser/browser_theme_pack_unittest.cc b/chrome/browser/browser_theme_pack_unittest.cc
index fdaea84..3068248 100644
--- a/chrome/browser/browser_theme_pack_unittest.cc
+++ b/chrome/browser/browser_theme_pack_unittest.cc
@@ -118,6 +118,9 @@ class BrowserThemePackTest : public ::testing::Test {
void ParseImageNamesDictionary(DictionaryValue* value,
std::map<int, FilePath>* out_file_paths) {
theme_pack_->ParseImageNamesFromJSON(value, FilePath(), out_file_paths);
+
+ // Build the source image list for HasCustomImage().
+ theme_pack_->BuildSourceImagesArray(*out_file_paths);
}
bool LoadRawBitmapsTo(const std::map<int, FilePath>& out_file_paths) {
@@ -167,14 +170,21 @@ class BrowserThemePackTest : public ::testing::Test {
BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &val));
EXPECT_EQ(BrowserThemeProvider::ALIGN_TOP, val);
- // Every theme should have the following images, because they need to be
- // tinted.
+ // The stargazing theme defines the following images:
+ EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_BUTTON_BACKGROUND));
EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME));
- EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INACTIVE));
- EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO));
- EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO_INACTIVE));
+ EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_NTP_BACKGROUND));
EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_TAB_BACKGROUND));
- EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_TAB_BACKGROUND_INCOGNITO));
+ EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_TOOLBAR));
+ EXPECT_TRUE(pack->HasCustomImage(IDR_THEME_WINDOW_CONTROL_BACKGROUND));
+
+ // Here are a few images that we shouldn't expect because even though
+ // they're included in the theme pack, they were autogenerated and
+ // therefore shouldn't show up when calling HasCustomImage().
+ EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INACTIVE));
+ EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO));
+ EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_FRAME_INCOGNITO_INACTIVE));
+ EXPECT_FALSE(pack->HasCustomImage(IDR_THEME_TAB_BACKGROUND_INCOGNITO));
// Make sure we don't have phantom data.
EXPECT_FALSE(pack->GetColor(BrowserThemeProvider::COLOR_CONTROL_BACKGROUND,
@@ -359,6 +369,17 @@ TEST_F(BrowserThemePackTest, NullDisplayProperties) {
LoadDisplayPropertiesDictionary(NULL);
}
+TEST_F(BrowserThemePackTest, TestHasCustomImage) {
+ // HasCustomImage should only return true for images that exist in the
+ // extension and not for autogenerated images.
+ std::string images = "{ \"theme_frame\": \"one\" }";
+ std::map<int, FilePath> out_file_paths;
+ ParseImageNamesJSON(images, &out_file_paths);
+
+ EXPECT_TRUE(theme_pack_->HasCustomImage(IDR_THEME_FRAME));
+ EXPECT_FALSE(theme_pack_->HasCustomImage(IDR_THEME_FRAME_INCOGNITO));
+}
+
TEST_F(BrowserThemePackTest, TestNonExistantImages) {
std::string images = "{ \"theme_frame\": \"does_not_exist\" }";
std::map<int, FilePath> out_file_paths;