1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
TEST(ExtensionIconSet, Basic) {
ExtensionIconSet icons;
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_EXACTLY));
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_BIGGER));
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_SMALLER));
EXPECT_TRUE(icons.map().empty());
icons.Add(extension_misc::EXTENSION_ICON_LARGE, "large.png");
EXPECT_EQ("large.png", icons.Get(extension_misc::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_EXACTLY));
EXPECT_EQ("large.png", icons.Get(extension_misc::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_BIGGER));
EXPECT_EQ("large.png", icons.Get(extension_misc::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_SMALLER));
EXPECT_EQ("large.png", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
ExtensionIconSet::MATCH_BIGGER));
EXPECT_EQ("large.png", icons.Get(extension_misc::EXTENSION_ICON_EXTRA_LARGE,
ExtensionIconSet::MATCH_SMALLER));
EXPECT_EQ("large.png", icons.Get(0, ExtensionIconSet::MATCH_BIGGER));
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
ExtensionIconSet::MATCH_SMALLER));
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_EXTRA_LARGE,
ExtensionIconSet::MATCH_BIGGER));
icons.Add(extension_misc::EXTENSION_ICON_SMALLISH, "smallish.png");
icons.Add(extension_misc::EXTENSION_ICON_SMALL, "small.png");
icons.Add(extension_misc::EXTENSION_ICON_EXTRA_LARGE, "extra_large.png");
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
ExtensionIconSet::MATCH_EXACTLY));
EXPECT_EQ("small.png", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
ExtensionIconSet::MATCH_SMALLER));
EXPECT_EQ("large.png", icons.Get(extension_misc::EXTENSION_ICON_MEDIUM,
ExtensionIconSet::MATCH_BIGGER));
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_BITTY,
ExtensionIconSet::MATCH_SMALLER));
EXPECT_EQ("", icons.Get(extension_misc::EXTENSION_ICON_GIGANTOR,
ExtensionIconSet::MATCH_BIGGER));
}
TEST(ExtensionIconSet, Values) {
ExtensionIconSet icons;
EXPECT_FALSE(icons.ContainsPath("foo"));
icons.Add(extension_misc::EXTENSION_ICON_BITTY, "foo");
icons.Add(extension_misc::EXTENSION_ICON_GIGANTOR, "bar");
EXPECT_TRUE(icons.ContainsPath("foo"));
EXPECT_TRUE(icons.ContainsPath("bar"));
EXPECT_FALSE(icons.ContainsPath("baz"));
EXPECT_FALSE(icons.ContainsPath(""));
icons.Clear();
EXPECT_FALSE(icons.ContainsPath("foo"));
}
TEST(ExtensionIconSet, FindSize) {
ExtensionIconSet icons;
EXPECT_EQ(extension_misc::EXTENSION_ICON_INVALID,
icons.GetIconSizeFromPath("foo"));
icons.Add(extension_misc::EXTENSION_ICON_BITTY, "foo");
icons.Add(extension_misc::EXTENSION_ICON_GIGANTOR, "bar");
EXPECT_EQ(extension_misc::EXTENSION_ICON_BITTY,
icons.GetIconSizeFromPath("foo"));
EXPECT_EQ(extension_misc::EXTENSION_ICON_GIGANTOR,
icons.GetIconSizeFromPath("bar"));
EXPECT_EQ(extension_misc::EXTENSION_ICON_INVALID,
icons.GetIconSizeFromPath("baz"));
EXPECT_EQ(extension_misc::EXTENSION_ICON_INVALID,
icons.GetIconSizeFromPath(""));
icons.Clear();
EXPECT_EQ(extension_misc::EXTENSION_ICON_INVALID,
icons.GetIconSizeFromPath("foo"));
}
} // namespace
|