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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_icons_unittest.cc

Issue 1537473003: Change extension icon load errors to warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ultimate weirdness Created 5 years 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/linked_ptr.h" 5 #include "base/memory/linked_ptr.h"
6 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" 6 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
7 #include "extensions/common/constants.h" 7 #include "extensions/common/constants.h"
8 #include "extensions/common/extension.h" 8 #include "extensions/common/extension.h"
9 #include "extensions/common/extension_icon_set.h" 9 #include "extensions/common/extension_icon_set.h"
10 #include "extensions/common/manifest_handlers/icons_handler.h" 10 #include "extensions/common/manifest_handlers/icons_handler.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace extensions { 13 namespace extensions {
14 14
15 class IconsManifestTest : public ChromeManifestTest { 15 class IconsManifestTest : public ChromeManifestTest {
16 }; 16 };
17 17
18 // Icons that don't exist on disk should be ignored (for most manifest
19 // locations).
20 TEST_F(IconsManifestTest, IgnoreNonExistentIcons) {
21 scoped_refptr<extensions::Extension> extension(
22 LoadAndExpectSuccess("normalize_icon_paths.json", Manifest::INTERNAL));
23 const ExtensionIconSet& icons = IconsInfo::GetIcons(extension.get());
24
25 EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_BITTY,
26 ExtensionIconSet::MATCH_EXACTLY));
27 EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
28 ExtensionIconSet::MATCH_EXACTLY));
29 }
30
18 TEST_F(IconsManifestTest, NormalizeIconPaths) { 31 TEST_F(IconsManifestTest, NormalizeIconPaths) {
19 scoped_refptr<extensions::Extension> extension( 32 scoped_refptr<extensions::Extension> extension(
20 LoadAndExpectSuccess("normalize_icon_paths.json")); 33 LoadAndExpectSuccess("normalize_icon_paths.json", Manifest::UNPACKED));
21 const ExtensionIconSet& icons = IconsInfo::GetIcons(extension.get()); 34 const ExtensionIconSet& icons = IconsInfo::GetIcons(extension.get());
22 35
23 EXPECT_EQ("16.png", icons.Get(extension_misc::EXTENSION_ICON_BITTY, 36 EXPECT_EQ("16.png", icons.Get(extension_misc::EXTENSION_ICON_BITTY,
24 ExtensionIconSet::MATCH_EXACTLY)); 37 ExtensionIconSet::MATCH_EXACTLY));
25 EXPECT_EQ("48.png", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM, 38 EXPECT_EQ("48.png", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
26 ExtensionIconSet::MATCH_EXACTLY)); 39 ExtensionIconSet::MATCH_EXACTLY));
27 } 40 }
28 41
29 TEST_F(IconsManifestTest, IconSizes) { 42 TEST_F(IconsManifestTest, IconSizes) {
30 scoped_refptr<extensions::Extension> extension( 43 scoped_refptr<extensions::Extension> extension(
31 LoadAndExpectSuccess("init_icon_size.json")); 44 LoadAndExpectSuccess("init_icon_size.json", Manifest::UNPACKED));
32 const ExtensionIconSet& icons = IconsInfo::GetIcons(extension.get()); 45 const ExtensionIconSet& icons = IconsInfo::GetIcons(extension.get());
33 46
34 EXPECT_EQ("16.png", icons.Get(extension_misc::EXTENSION_ICON_BITTY, 47 EXPECT_EQ("16.png", icons.Get(extension_misc::EXTENSION_ICON_BITTY,
35 ExtensionIconSet::MATCH_EXACTLY)); 48 ExtensionIconSet::MATCH_EXACTLY));
36 EXPECT_EQ("24.png", icons.Get(extension_misc::EXTENSION_ICON_SMALLISH, 49 EXPECT_EQ("24.png", icons.Get(extension_misc::EXTENSION_ICON_SMALLISH,
37 ExtensionIconSet::MATCH_EXACTLY)); 50 ExtensionIconSet::MATCH_EXACTLY));
38 EXPECT_EQ("32.png", icons.Get(extension_misc::EXTENSION_ICON_SMALL, 51 EXPECT_EQ("32.png", icons.Get(extension_misc::EXTENSION_ICON_SMALL,
39 ExtensionIconSet::MATCH_EXACTLY)); 52 ExtensionIconSet::MATCH_EXACTLY));
40 EXPECT_EQ("48.png", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM, 53 EXPECT_EQ("48.png", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
41 ExtensionIconSet::MATCH_EXACTLY)); 54 ExtensionIconSet::MATCH_EXACTLY));
42 EXPECT_EQ("128.png", icons.Get(extension_misc::EXTENSION_ICON_LARGE, 55 EXPECT_EQ("128.png", icons.Get(extension_misc::EXTENSION_ICON_LARGE,
43 ExtensionIconSet::MATCH_EXACTLY)); 56 ExtensionIconSet::MATCH_EXACTLY));
44 EXPECT_EQ("256.png", icons.Get(extension_misc::EXTENSION_ICON_EXTRA_LARGE, 57 EXPECT_EQ("256.png", icons.Get(extension_misc::EXTENSION_ICON_EXTRA_LARGE,
45 ExtensionIconSet::MATCH_EXACTLY)); 58 ExtensionIconSet::MATCH_EXACTLY));
46 EXPECT_EQ("512.png", icons.Get(extension_misc::EXTENSION_ICON_GIGANTOR, 59 EXPECT_EQ("512.png", icons.Get(extension_misc::EXTENSION_ICON_GIGANTOR,
47 ExtensionIconSet::MATCH_EXACTLY)); 60 ExtensionIconSet::MATCH_EXACTLY));
48 61
49 // Any old size will be accepted. 62 // Any old size will be accepted.
50 EXPECT_EQ("300.png", IconsInfo::GetIcons(extension.get()) 63 EXPECT_EQ("300.png", IconsInfo::GetIcons(extension.get())
51 .Get(300, ExtensionIconSet::MATCH_EXACTLY)); 64 .Get(300, ExtensionIconSet::MATCH_EXACTLY));
52 } 65 }
53 66
54 } // namespace extensions 67 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698