| 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 "extensions/common/extension_set.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 6 #include "base/logging.h" | 10 #include "base/logging.h" |
| 7 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/values.h" | 12 #include "base/values.h" |
| 10 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 11 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/extension_set.h" | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 15 namespace extensions { | 17 namespace extensions { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 scoped_refptr<Extension> CreateTestExtension(const std::string& name, | 21 scoped_refptr<Extension> CreateTestExtension(const std::string& name, |
| 20 const std::string& launch_url, | 22 const std::string& launch_url, |
| 21 const std::string& extent) { | 23 const std::string& extent) { |
| 22 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 EXPECT_EQ(2u, extensions.size()); | 126 EXPECT_EQ(2u, extensions.size()); |
| 125 EXPECT_FALSE(extensions.GetByID(ext2->id())); | 127 EXPECT_FALSE(extensions.GetByID(ext2->id())); |
| 126 | 128 |
| 127 // Make a union of a set with 3 more extensions (only 2 are new). | 129 // Make a union of a set with 3 more extensions (only 2 are new). |
| 128 scoped_refptr<Extension> ext5( | 130 scoped_refptr<Extension> ext5( |
| 129 CreateTestExtension("d", std::string(), std::string())); | 131 CreateTestExtension("d", std::string(), std::string())); |
| 130 scoped_refptr<Extension> ext6( | 132 scoped_refptr<Extension> ext6( |
| 131 CreateTestExtension("e", std::string(), std::string())); | 133 CreateTestExtension("e", std::string(), std::string())); |
| 132 ASSERT_TRUE(ext5.get() && ext6.get()); | 134 ASSERT_TRUE(ext5.get() && ext6.get()); |
| 133 | 135 |
| 134 scoped_ptr<ExtensionSet> to_add(new ExtensionSet()); | 136 std::unique_ptr<ExtensionSet> to_add(new ExtensionSet()); |
| 135 // |ext3| is already in |extensions|, should not affect size. | 137 // |ext3| is already in |extensions|, should not affect size. |
| 136 EXPECT_TRUE(to_add->Insert(ext3)); | 138 EXPECT_TRUE(to_add->Insert(ext3)); |
| 137 EXPECT_TRUE(to_add->Insert(ext5)); | 139 EXPECT_TRUE(to_add->Insert(ext5)); |
| 138 EXPECT_TRUE(to_add->Insert(ext6)); | 140 EXPECT_TRUE(to_add->Insert(ext6)); |
| 139 | 141 |
| 140 ASSERT_TRUE(extensions.Contains(ext3->id())); | 142 ASSERT_TRUE(extensions.Contains(ext3->id())); |
| 141 ASSERT_TRUE(extensions.InsertAll(*to_add)); | 143 ASSERT_TRUE(extensions.InsertAll(*to_add)); |
| 142 EXPECT_EQ(4u, extensions.size()); | 144 EXPECT_EQ(4u, extensions.size()); |
| 143 | 145 |
| 144 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. | 146 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. |
| 145 EXPECT_EQ(4u, extensions.size()); | 147 EXPECT_EQ(4u, extensions.size()); |
| 146 } | 148 } |
| 147 | 149 |
| 148 } // namespace extensions | 150 } // namespace extensions |
| OLD | NEW |