Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/common/extensions/extension_set_unittest.cc

Issue 15836003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 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 && ext2 && ext3 && ext4); 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, 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));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // Remove one of the extensions. 116 // Remove one of the extensions.
117 EXPECT_TRUE(extensions.Remove(ext2->id())); 117 EXPECT_TRUE(extensions.Remove(ext2->id()));
118 EXPECT_EQ(2u, extensions.size()); 118 EXPECT_EQ(2u, extensions.size());
119 EXPECT_FALSE(extensions.GetByID(ext2->id())); 119 EXPECT_FALSE(extensions.GetByID(ext2->id()));
120 120
121 // 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).
122 scoped_refptr<Extension> ext5( 122 scoped_refptr<Extension> ext5(
123 CreateTestExtension("d", std::string(), std::string())); 123 CreateTestExtension("d", std::string(), std::string()));
124 scoped_refptr<Extension> ext6( 124 scoped_refptr<Extension> ext6(
125 CreateTestExtension("e", std::string(), std::string())); 125 CreateTestExtension("e", std::string(), std::string()));
126 ASSERT_TRUE(ext5 && ext6); 126 ASSERT_TRUE(ext5.get() && ext6.get());
127 127
128 scoped_ptr<ExtensionSet> to_add(new ExtensionSet()); 128 scoped_ptr<ExtensionSet> to_add(new ExtensionSet());
129 // |ext3| is already in |extensions|, should not affect size. 129 // |ext3| is already in |extensions|, should not affect size.
130 EXPECT_TRUE(to_add->Insert(ext3)); 130 EXPECT_TRUE(to_add->Insert(ext3));
131 EXPECT_TRUE(to_add->Insert(ext5)); 131 EXPECT_TRUE(to_add->Insert(ext5));
132 EXPECT_TRUE(to_add->Insert(ext6)); 132 EXPECT_TRUE(to_add->Insert(ext6));
133 133
134 ASSERT_TRUE(extensions.Contains(ext3->id())); 134 ASSERT_TRUE(extensions.Contains(ext3->id()));
135 ASSERT_TRUE(extensions.InsertAll(*to_add)); 135 ASSERT_TRUE(extensions.InsertAll(*to_add));
136 EXPECT_EQ(4u, extensions.size()); 136 EXPECT_EQ(4u, extensions.size());
137 137
138 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. 138 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops.
139 EXPECT_EQ(4u, extensions.size()); 139 EXPECT_EQ(4u, extensions.size());
140 } 140 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_messages.cc ('k') | chrome/common/extensions/extension_sync_type_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698