OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 scoped_refptr<Extension> ext1(CreateTestExtension( | 52 scoped_refptr<Extension> ext1(CreateTestExtension( |
53 "a", "https://chrome.google.com/launch", "https://chrome.google.com/")); | 53 "a", "https://chrome.google.com/launch", "https://chrome.google.com/")); |
54 | 54 |
55 scoped_refptr<Extension> ext2(CreateTestExtension( | 55 scoped_refptr<Extension> ext2(CreateTestExtension( |
56 "a", "http://code.google.com/p/chromium", | 56 "a", "http://code.google.com/p/chromium", |
57 "http://code.google.com/p/chromium/")); | 57 "http://code.google.com/p/chromium/")); |
58 | 58 |
59 scoped_refptr<Extension> ext3(CreateTestExtension( | 59 scoped_refptr<Extension> ext3(CreateTestExtension( |
60 "b", "http://dev.chromium.org/", "http://dev.chromium.org/")); | 60 "b", "http://dev.chromium.org/", "http://dev.chromium.org/")); |
61 | 61 |
62 scoped_refptr<Extension> ext4(CreateTestExtension("c", "", "")); | 62 scoped_refptr<Extension> ext4( |
| 63 CreateTestExtension("c", std::string(), std::string())); |
63 | 64 |
64 ASSERT_TRUE(ext1 && ext2 && ext3 && ext4); | 65 ASSERT_TRUE(ext1 && ext2 && ext3 && ext4); |
65 | 66 |
66 ExtensionSet extensions; | 67 ExtensionSet extensions; |
67 | 68 |
68 // Add an extension. | 69 // Add an extension. |
69 extensions.Insert(ext1); | 70 extensions.Insert(ext1); |
70 EXPECT_EQ(1u, extensions.size()); | 71 EXPECT_EQ(1u, extensions.size()); |
71 EXPECT_EQ(ext1, extensions.GetByID(ext1->id())); | 72 EXPECT_EQ(ext1, extensions.GetByID(ext1->id())); |
72 | 73 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 EXPECT_TRUE(extensions.InSameExtent( | 112 EXPECT_TRUE(extensions.InSameExtent( |
112 GURL("http://www.google.com/"), | 113 GURL("http://www.google.com/"), |
113 GURL("http://blog.chromium.org/"))); | 114 GURL("http://blog.chromium.org/"))); |
114 | 115 |
115 // Remove one of the extensions. | 116 // Remove one of the extensions. |
116 extensions.Remove(ext2->id()); | 117 extensions.Remove(ext2->id()); |
117 EXPECT_EQ(2u, extensions.size()); | 118 EXPECT_EQ(2u, extensions.size()); |
118 EXPECT_FALSE(extensions.GetByID(ext2->id())); | 119 EXPECT_FALSE(extensions.GetByID(ext2->id())); |
119 | 120 |
120 // Make a union of a set with 3 more extensions (only 2 are new). | 121 // Make a union of a set with 3 more extensions (only 2 are new). |
121 scoped_refptr<Extension> ext5(CreateTestExtension("d", "", "")); | 122 scoped_refptr<Extension> ext5( |
122 scoped_refptr<Extension> ext6(CreateTestExtension("e", "", "")); | 123 CreateTestExtension("d", std::string(), std::string())); |
| 124 scoped_refptr<Extension> ext6( |
| 125 CreateTestExtension("e", std::string(), std::string())); |
123 ASSERT_TRUE(ext5 && ext6); | 126 ASSERT_TRUE(ext5 && ext6); |
124 | 127 |
125 scoped_ptr<ExtensionSet> to_add(new ExtensionSet()); | 128 scoped_ptr<ExtensionSet> to_add(new ExtensionSet()); |
126 to_add->Insert(ext3); // Already in |extensions|, should not affect size. | 129 to_add->Insert(ext3); // Already in |extensions|, should not affect size. |
127 to_add->Insert(ext5); | 130 to_add->Insert(ext5); |
128 to_add->Insert(ext6); | 131 to_add->Insert(ext6); |
129 | 132 |
130 ASSERT_TRUE(extensions.Contains(ext3->id())); | 133 ASSERT_TRUE(extensions.Contains(ext3->id())); |
131 ASSERT_TRUE(extensions.InsertAll(*to_add)); | 134 ASSERT_TRUE(extensions.InsertAll(*to_add)); |
132 EXPECT_EQ(4u, extensions.size()); | 135 EXPECT_EQ(4u, extensions.size()); |
133 | 136 |
134 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. | 137 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. |
135 EXPECT_EQ(4u, extensions.size()); | 138 EXPECT_EQ(4u, extensions.size()); |
136 } | 139 } |
OLD | NEW |