OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 scoped_refptr<Extension> ext4( | 62 scoped_refptr<Extension> ext4( |
63 CreateTestExtension("c", std::string(), std::string())); | 63 CreateTestExtension("c", std::string(), std::string())); |
64 | 64 |
65 ASSERT_TRUE(ext1.get() && ext2.get() && ext3.get() && ext4.get()); | 65 ASSERT_TRUE(ext1.get() && ext2.get() && ext3.get() && ext4.get()); |
66 | 66 |
67 ExtensionSet extensions; | 67 ExtensionSet extensions; |
68 | 68 |
69 // Add an extension. | 69 // Add an extension. |
70 EXPECT_TRUE(extensions.Insert(ext1)); | 70 EXPECT_TRUE(extensions.Insert(ext1)); |
71 EXPECT_EQ(1u, extensions.size()); | 71 EXPECT_EQ(1u, extensions.size()); |
72 EXPECT_EQ(ext1, extensions.GetByID(ext1->id())); | 72 EXPECT_EQ(ext1.get(), extensions.GetByID(ext1->id())); |
73 | 73 |
74 // Since extension2 has same ID, it should overwrite extension1. | 74 // Since extension2 has same ID, it should overwrite extension1. |
75 EXPECT_FALSE(extensions.Insert(ext2)); | 75 EXPECT_FALSE(extensions.Insert(ext2)); |
76 EXPECT_EQ(1u, extensions.size()); | 76 EXPECT_EQ(1u, extensions.size()); |
77 EXPECT_EQ(ext2, extensions.GetByID(ext1->id())); | 77 EXPECT_EQ(ext2.get(), extensions.GetByID(ext1->id())); |
78 | 78 |
79 // Add the other extensions. | 79 // Add the other extensions. |
80 EXPECT_TRUE(extensions.Insert(ext3)); | 80 EXPECT_TRUE(extensions.Insert(ext3)); |
81 EXPECT_TRUE(extensions.Insert(ext4)); | 81 EXPECT_TRUE(extensions.Insert(ext4)); |
82 EXPECT_EQ(3u, extensions.size()); | 82 EXPECT_EQ(3u, extensions.size()); |
83 | 83 |
84 // Get extension by its chrome-extension:// URL | 84 // Get extension by its chrome-extension:// URL |
85 EXPECT_EQ(ext2, extensions.GetExtensionOrAppByURL( | 85 EXPECT_EQ( |
86 ext2->GetResourceURL("test.html"))); | 86 ext2.get(), |
87 EXPECT_EQ(ext3, extensions.GetExtensionOrAppByURL( | 87 extensions.GetExtensionOrAppByURL(ext2->GetResourceURL("test.html"))); |
88 ext3->GetResourceURL("test.html"))); | 88 EXPECT_EQ( |
89 EXPECT_EQ(ext4, extensions.GetExtensionOrAppByURL( | 89 ext3.get(), |
90 ext4->GetResourceURL("test.html"))); | 90 extensions.GetExtensionOrAppByURL(ext3->GetResourceURL("test.html"))); |
| 91 EXPECT_EQ( |
| 92 ext4.get(), |
| 93 extensions.GetExtensionOrAppByURL(ext4->GetResourceURL("test.html"))); |
91 | 94 |
92 // Get extension by web extent. | 95 // Get extension by web extent. |
93 EXPECT_EQ(ext2, extensions.GetExtensionOrAppByURL( | 96 EXPECT_EQ(ext2.get(), |
94 GURL("http://code.google.com/p/chromium/monkey"))); | 97 extensions.GetExtensionOrAppByURL( |
95 EXPECT_EQ(ext3, extensions.GetExtensionOrAppByURL( | 98 GURL("http://code.google.com/p/chromium/monkey"))); |
96 GURL("http://dev.chromium.org/design-docs/"))); | 99 EXPECT_EQ(ext3.get(), |
| 100 extensions.GetExtensionOrAppByURL( |
| 101 GURL("http://dev.chromium.org/design-docs/"))); |
97 EXPECT_FALSE(extensions.GetExtensionOrAppByURL( | 102 EXPECT_FALSE(extensions.GetExtensionOrAppByURL( |
98 GURL("http://blog.chromium.org/"))); | 103 GURL("http://blog.chromium.org/"))); |
99 | 104 |
100 // Test InSameExtent(). | 105 // Test InSameExtent(). |
101 EXPECT_TRUE(extensions.InSameExtent( | 106 EXPECT_TRUE(extensions.InSameExtent( |
102 GURL("http://code.google.com/p/chromium/monkey/"), | 107 GURL("http://code.google.com/p/chromium/monkey/"), |
103 GURL("http://code.google.com/p/chromium/"))); | 108 GURL("http://code.google.com/p/chromium/"))); |
104 EXPECT_FALSE(extensions.InSameExtent( | 109 EXPECT_FALSE(extensions.InSameExtent( |
105 GURL("http://code.google.com/p/chromium/"), | 110 GURL("http://code.google.com/p/chromium/"), |
106 GURL("https://code.google.com/p/chromium/"))); | 111 GURL("https://code.google.com/p/chromium/"))); |
(...skipping 26 matching lines...) Expand all Loading... |
133 | 138 |
134 ASSERT_TRUE(extensions.Contains(ext3->id())); | 139 ASSERT_TRUE(extensions.Contains(ext3->id())); |
135 ASSERT_TRUE(extensions.InsertAll(*to_add)); | 140 ASSERT_TRUE(extensions.InsertAll(*to_add)); |
136 EXPECT_EQ(4u, extensions.size()); | 141 EXPECT_EQ(4u, extensions.size()); |
137 | 142 |
138 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. | 143 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. |
139 EXPECT_EQ(4u, extensions.size()); | 144 EXPECT_EQ(4u, extensions.size()); |
140 } | 145 } |
141 | 146 |
142 } // namespace extensions | 147 } // namespace extensions |
OLD | NEW |