Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: extensions/common/manifest_handlers/icons_handler_unittest.cc

Issue 1618073002: Extensions - Check for too big or too small product icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/manifest_handler_helpers.cc ('k') | extensions/extensions_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_handlers/icons_handler.h"
7 #include "extensions/common/manifest_test.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace extensions {
11
12 class ProductIconManifestTest : public ManifestTest {
13 public:
14 ProductIconManifestTest() {}
15
16 protected:
17 scoped_ptr<base::DictionaryValue> CreateManifest(
18 const std::string& extra_icons) {
19 scoped_ptr<base::DictionaryValue> manifest = base::DictionaryValue::From(
20 base::test::ParseJson("{ \n"
21 " \"name\": \"test\", \n"
22 " \"version\": \"0.1\", \n"
23 " \"manifest_version\": 2, \n"
24 " \"icons\": { \n" +
25 extra_icons + " \"16\": \"icon1.png\", \n"
26 " \"32\": \"icon2.png\" \n"
27 " } \n"
28 "} \n"));
29 EXPECT_TRUE(manifest);
30 return manifest;
31 }
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(ProductIconManifestTest);
35 };
36
37 TEST_F(ProductIconManifestTest, Sizes) {
38 // Too big.
39 {
40 scoped_ptr<base::DictionaryValue> ext_manifest =
41 CreateManifest("\"100000\": \"icon3.png\", \n");
42 ManifestData manifest(std::move(ext_manifest), "test");
43 LoadAndExpectError(manifest, "Invalid key in icons: \"100000\".");
44 }
45 // Too small.
46 {
47 scoped_ptr<base::DictionaryValue> ext_manifest =
48 CreateManifest("\"0\": \"icon3.png\", \n");
49 ManifestData manifest(std::move(ext_manifest), "test");
50 LoadAndExpectError(manifest, "Invalid key in icons: \"0\".");
51 }
52 // NaN.
53 {
54 scoped_ptr<base::DictionaryValue> ext_manifest =
55 CreateManifest("\"sixteen\": \"icon3.png\", \n");
56 ManifestData manifest(std::move(ext_manifest), "test");
57 LoadAndExpectError(manifest, "Invalid key in icons: \"sixteen\".");
58 }
59 // Just right.
60 {
61 scoped_ptr<base::DictionaryValue> ext_manifest =
62 CreateManifest("\"512\": \"icon3.png\", \n");
63 ManifestData manifest(std::move(ext_manifest), "test");
64 scoped_refptr<extensions::Extension> extension =
65 LoadAndExpectSuccess(manifest);
66 }
67 }
68
69 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_handler_helpers.cc ('k') | extensions/extensions_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698