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
3 // found in the LICENSE file.
5 #include "base/memory/linked_ptr.h"
6 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
7 #include "extensions/common/constants.h"
8 #include "extensions/common/extension.h"
9 #include "extensions/common/extension_icon_set.h"
10 #include "extensions/common/manifest_handlers/icons_handler.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace extensions
{
15 class IconsManifestTest
: public ExtensionManifestTest
{
18 TEST_F(IconsManifestTest
, NormalizeIconPaths
) {
19 scoped_refptr
<extensions::Extension
> extension(
20 LoadAndExpectSuccess("normalize_icon_paths.json"));
21 const ExtensionIconSet
& icons
= IconsInfo::GetIcons(extension
.get());
23 EXPECT_EQ("16.png", icons
.Get(extension_misc::EXTENSION_ICON_BITTY
,
24 ExtensionIconSet::MATCH_EXACTLY
));
25 EXPECT_EQ("48.png", icons
.Get(extension_misc::EXTENSION_ICON_MEDIUM
,
26 ExtensionIconSet::MATCH_EXACTLY
));
29 TEST_F(IconsManifestTest
, InvalidIconSizes
) {
30 scoped_refptr
<extensions::Extension
> extension(
31 LoadAndExpectSuccess("init_ignored_icon_size.json"));
33 IconsInfo::GetIcons(extension
.get())
34 .Get(300, ExtensionIconSet::MATCH_EXACTLY
));
37 TEST_F(IconsManifestTest
, ValidIconSizes
) {
38 scoped_refptr
<extensions::Extension
> extension(
39 LoadAndExpectSuccess("init_valid_icon_size.json"));
40 const ExtensionIconSet
& icons
= IconsInfo::GetIcons(extension
.get());
42 EXPECT_EQ("16.png", icons
.Get(extension_misc::EXTENSION_ICON_BITTY
,
43 ExtensionIconSet::MATCH_EXACTLY
));
44 EXPECT_EQ("24.png", icons
.Get(extension_misc::EXTENSION_ICON_SMALLISH
,
45 ExtensionIconSet::MATCH_EXACTLY
));
46 EXPECT_EQ("32.png", icons
.Get(extension_misc::EXTENSION_ICON_SMALL
,
47 ExtensionIconSet::MATCH_EXACTLY
));
48 EXPECT_EQ("48.png", icons
.Get(extension_misc::EXTENSION_ICON_MEDIUM
,
49 ExtensionIconSet::MATCH_EXACTLY
));
50 EXPECT_EQ("128.png", icons
.Get(extension_misc::EXTENSION_ICON_LARGE
,
51 ExtensionIconSet::MATCH_EXACTLY
));
52 EXPECT_EQ("256.png", icons
.Get(extension_misc::EXTENSION_ICON_EXTRA_LARGE
,
53 ExtensionIconSet::MATCH_EXACTLY
));
54 EXPECT_EQ("512.png", icons
.Get(extension_misc::EXTENSION_ICON_GIGANTOR
,
55 ExtensionIconSet::MATCH_EXACTLY
));
58 } // namespace extensions