Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/test/values_test_util.h" | |
| 6 #include "extensions/common/manifest_constants.h" | |
| 7 #include "extensions/common/manifest_handlers/icons_handler.h" | |
| 8 #include "extensions/common/manifest_test.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace extensions { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 // Produces extension ID = "mdbihdcgjmagbcapkhhkjbbdlkflmbfo". | |
| 16 const char kExtensionKey[] = | |
| 17 "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCV9PlZjcTIXfnlB3HXo50OlM/CnIq0y7jm" | |
| 18 "KfPVyStaWsmFB7NaVnqUXoGb9swBDfVnZ6BrupwnxL76TWEJPo+KQMJ6uz0PPdJWi2jQfZiG" | |
| 19 "iheDiKH5Gv+dVd67qf7ly8QWW0o8qmFpqBZQpksm1hOGbfsupv9W4c42tMEIicDMLQIDAQAB"; | |
| 20 | |
| 21 } // namespace | |
| 22 | |
| 23 class ProductIconManifestTest : public ManifestTest { | |
| 24 public: | |
| 25 ProductIconManifestTest() {} | |
| 26 | |
| 27 protected: | |
| 28 scoped_ptr<base::DictionaryValue> CreateManifest( | |
| 29 const std::string& extra_icons) { | |
| 30 scoped_ptr<base::DictionaryValue> manifest = base::DictionaryValue::From( | |
|
Devlin
2016/01/22 23:41:56
IMO, extensions::DictionaryBuilder makes this clea
Evan Stade
2016/01/23 02:28:37
Acknowledged.
| |
| 31 base::test::ParseJson("{ \n" | |
| 32 " \"name\": \"test\", \n" | |
| 33 " \"version\": \"0.1\", \n" | |
| 34 " \"manifest_version\": 2, \n" | |
| 35 " \"icons\": { \n" + | |
| 36 extra_icons + " \"16\": \"icon1.png\", \n" | |
| 37 " \"32\": \"icon2.png\" \n" | |
| 38 " } \n" | |
| 39 "} \n")); | |
| 40 EXPECT_TRUE(manifest); | |
| 41 manifest->SetString(manifest_keys::kKey, kExtensionKey); | |
|
Devlin
2016/01/22 23:41:56
Is this needed for anything?
Evan Stade
2016/01/23 02:28:37
Done.
| |
| 42 return manifest; | |
| 43 } | |
| 44 | |
| 45 private: | |
| 46 DISALLOW_COPY_AND_ASSIGN(ProductIconManifestTest); | |
| 47 }; | |
| 48 | |
| 49 TEST_F(ProductIconManifestTest, Sizes) { | |
| 50 // Too big. | |
| 51 { | |
| 52 scoped_ptr<base::DictionaryValue> ext_manifest = | |
| 53 CreateManifest("\"100000\": \"icon3.png\", \n"); | |
| 54 ManifestData manifest(std::move(ext_manifest), "test"); | |
| 55 LoadAndExpectError(manifest, "Invalid value for 'icons[\"100000\"]'."); | |
| 56 } | |
| 57 // Too small. | |
| 58 { | |
| 59 scoped_ptr<base::DictionaryValue> ext_manifest = | |
| 60 CreateManifest("\"0\": \"icon3.png\", \n"); | |
| 61 ManifestData manifest(std::move(ext_manifest), "test"); | |
| 62 LoadAndExpectError(manifest, "Invalid value for 'icons[\"0\"]'."); | |
| 63 } | |
| 64 // NaN. | |
| 65 { | |
| 66 scoped_ptr<base::DictionaryValue> ext_manifest = | |
| 67 CreateManifest("\"sixteen\": \"icon3.png\", \n"); | |
| 68 ManifestData manifest(std::move(ext_manifest), "test"); | |
| 69 LoadAndExpectError(manifest, "Invalid value for 'icons[\"sixteen\"]'."); | |
| 70 } | |
| 71 // Just right. | |
| 72 { | |
| 73 scoped_ptr<base::DictionaryValue> ext_manifest = | |
| 74 CreateManifest("\"512\": \"icon3.png\", \n"); | |
| 75 ManifestData manifest(std::move(ext_manifest), "test"); | |
| 76 scoped_refptr<extensions::Extension> extension = | |
| 77 LoadAndExpectSuccess(manifest); | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 } // namespace extensions | |
| OLD | NEW |