• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 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 "chrome/common/extensions/extension_icon_set.h"
6 
7 #include "testing/gtest/include/gtest/gtest.h"
8 
TEST(ExtensionIconSet,Basic)9 TEST(ExtensionIconSet, Basic) {
10   ExtensionIconSet icons;
11   EXPECT_EQ("", icons.Get(42, ExtensionIconSet::MATCH_EXACTLY));
12   EXPECT_EQ("", icons.Get(42, ExtensionIconSet::MATCH_BIGGER));
13   EXPECT_EQ("", icons.Get(42, ExtensionIconSet::MATCH_SMALLER));
14   EXPECT_TRUE(icons.map().empty());
15 
16   icons.Add(42, "42.png");
17   EXPECT_EQ("42.png", icons.Get(42, ExtensionIconSet::MATCH_EXACTLY));
18   EXPECT_EQ("42.png", icons.Get(42, ExtensionIconSet::MATCH_BIGGER));
19   EXPECT_EQ("42.png", icons.Get(42, ExtensionIconSet::MATCH_SMALLER));
20   EXPECT_EQ("42.png", icons.Get(41, ExtensionIconSet::MATCH_BIGGER));
21   EXPECT_EQ("42.png", icons.Get(43, ExtensionIconSet::MATCH_SMALLER));
22   EXPECT_EQ("", icons.Get(41, ExtensionIconSet::MATCH_SMALLER));
23   EXPECT_EQ("", icons.Get(43, ExtensionIconSet::MATCH_BIGGER));
24 
25   icons.Add(38, "38.png");
26   icons.Add(40, "40.png");
27   icons.Add(44, "44.png");
28   icons.Add(46, "46.png");
29 
30   EXPECT_EQ("", icons.Get(41, ExtensionIconSet::MATCH_EXACTLY));
31   EXPECT_EQ("40.png", icons.Get(41, ExtensionIconSet::MATCH_SMALLER));
32   EXPECT_EQ("42.png", icons.Get(41, ExtensionIconSet::MATCH_BIGGER));
33   EXPECT_EQ("", icons.Get(37, ExtensionIconSet::MATCH_SMALLER));
34   EXPECT_EQ("", icons.Get(47, ExtensionIconSet::MATCH_BIGGER));
35 }
36 
TEST(ExtensionIconSet,Values)37 TEST(ExtensionIconSet, Values) {
38   ExtensionIconSet icons;
39   EXPECT_FALSE(icons.ContainsPath("foo"));
40 
41   icons.Add(1, "foo");
42   icons.Add(2, "bar");
43 
44   EXPECT_TRUE(icons.ContainsPath("foo"));
45   EXPECT_TRUE(icons.ContainsPath("bar"));
46   EXPECT_FALSE(icons.ContainsPath("baz"));
47   EXPECT_FALSE(icons.ContainsPath(""));
48 
49   icons.Clear();
50   EXPECT_FALSE(icons.ContainsPath("foo"));
51 }
52