summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_theme_pack_unittest.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-15 20:56:28 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-15 20:56:28 +0000
commit7a01ffa50af11c9565e269e8ce7aad7e373ce266 (patch)
tree57f0f96386127bc4114b830dd04820cab0ca859d /chrome/browser/browser_theme_pack_unittest.cc
parent727103380ef03a912b76d784e071f3777347fae1 (diff)
downloadchromium_src-7a01ffa50af11c9565e269e8ce7aad7e373ce266.zip
chromium_src-7a01ffa50af11c9565e269e8ce7aad7e373ce266.tar.gz
chromium_src-7a01ffa50af11c9565e269e8ce7aad7e373ce266.tar.bz2
Deal with themes that don't provide certain sections. Fixes crasher in new themes system.
BUG=30453 TEST=Installing https://chrome.google.com/extensions/detail/immljcnndlfdiajkpggdjbikmnibdhhi doesn't crash chrome. Review URL: http://codereview.chromium.org/506014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34602 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_pack_unittest.cc')
-rw-r--r--chrome/browser/browser_theme_pack_unittest.cc34
1 files changed, 28 insertions, 6 deletions
diff --git a/chrome/browser/browser_theme_pack_unittest.cc b/chrome/browser/browser_theme_pack_unittest.cc
index b8e5425..77da71b 100644
--- a/chrome/browser/browser_theme_pack_unittest.cc
+++ b/chrome/browser/browser_theme_pack_unittest.cc
@@ -73,22 +73,31 @@ class BrowserThemePackTest : public ::testing::Test {
void LoadColorJSON(const std::string& json) {
scoped_ptr<Value> value(base::JSONReader::Read(json, false));
ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY));
- theme_pack_->BuildColorsFromJSON(
- static_cast<DictionaryValue*>(value.get()));
+ LoadColorDictionary(static_cast<DictionaryValue*>(value.get()));
+ }
+
+ void LoadColorDictionary(DictionaryValue* value) {
+ theme_pack_->BuildColorsFromJSON(value);
}
void LoadTintJSON(const std::string& json) {
scoped_ptr<Value> value(base::JSONReader::Read(json, false));
ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY));
- theme_pack_->BuildTintsFromJSON(
- static_cast<DictionaryValue*>(value.get()));
+ LoadTintDictionary(static_cast<DictionaryValue*>(value.get()));
+ }
+
+ void LoadTintDictionary(DictionaryValue* value) {
+ theme_pack_->BuildTintsFromJSON(value);
}
void LoadDisplayPropertiesJSON(const std::string& json) {
scoped_ptr<Value> value(base::JSONReader::Read(json, false));
ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY));
- theme_pack_->BuildDisplayPropertiesFromJSON(
- static_cast<DictionaryValue*>(value.get()));
+ LoadDisplayPropertiesDictionary(static_cast<DictionaryValue*>(value.get()));
+ }
+
+ void LoadDisplayPropertiesDictionary(DictionaryValue* value) {
+ theme_pack_->BuildDisplayPropertiesFromJSON(value);
}
void ParseImageNames(const std::string& json,
@@ -293,6 +302,19 @@ TEST_F(BrowserThemePackTest, InvalidDisplayProperties) {
BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, &out_val));
}
+// These three tests should just not cause a segmentation fault.
+TEST_F(BrowserThemePackTest, NullTints) {
+ LoadTintDictionary(NULL);
+}
+
+TEST_F(BrowserThemePackTest, NullColors) {
+ LoadColorDictionary(NULL);
+}
+
+TEST_F(BrowserThemePackTest, NullDisplayProperties) {
+ LoadDisplayPropertiesDictionary(NULL);
+}
+
// TODO(erg): This test should actually test more of the built resources from
// the extension data, but for now, exists so valgrind can test some of the
// tricky memory stuff that BrowserThemePack does.