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

Unified Diff: base/callback_list_unittest.cc

Issue 24648002: Rename CallbackRegistry to CallbackList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Doc fix Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/callback_list.h.pump ('k') | base/callback_list_unittest.nc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_list_unittest.cc
diff --git a/base/callback_registry_unittest.cc b/base/callback_list_unittest.cc
similarity index 70%
rename from base/callback_registry_unittest.cc
rename to base/callback_list_unittest.cc
index 826aa0da6f133b297b9932c0aaf978942dffec6e..4607129a0ae5a16d0c8f1528c395e98aff295944 100644
--- a/base/callback_registry_unittest.cc
+++ b/base/callback_list_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/callback_registry.h"
+#include "base/callback_list.h"
#include "base/basictypes.h"
#include "base/bind.h"
@@ -35,20 +35,20 @@ class Remover {
removal_subscription_.reset();
}
void SetSubscriptionToRemove(
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> sub) {
+ scoped_ptr<CallbackList<void(void)>::Subscription> sub) {
removal_subscription_ = sub.Pass();
}
int total_;
private:
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> removal_subscription_;
+ scoped_ptr<CallbackList<void(void)>::Subscription> removal_subscription_;
DISALLOW_COPY_AND_ASSIGN(Remover);
};
class Adder {
public:
- explicit Adder(CallbackRegistry<void(void)>* cb_reg)
+ explicit Adder(CallbackList<void(void)>* cb_reg)
: added_(false),
total_(0),
cb_reg_(cb_reg) {}
@@ -65,8 +65,8 @@ class Adder {
int total_;
private:
- CallbackRegistry<void(void)>* cb_reg_;
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> subscription_;
+ CallbackList<void(void)>* cb_reg_;
+ scoped_ptr<CallbackList<void(void)>::Subscription> subscription_;
DISALLOW_COPY_AND_ASSIGN(Adder);
};
@@ -91,47 +91,47 @@ class Summer {
DISALLOW_COPY_AND_ASSIGN(Summer);
};
-// Sanity check that we can instantiate a CallbackRegistry for each arity.
-TEST(CallbackRegistryTest, ArityTest) {
+// Sanity check that we can instantiate a CallbackList for each arity.
+TEST(CallbackListTest, ArityTest) {
Summer s;
- CallbackRegistry<void(int)> c1;
- scoped_ptr<CallbackRegistry<void(int)>::Subscription> subscription1 =
+ CallbackList<void(int)> c1;
+ scoped_ptr<CallbackList<void(int)>::Subscription> subscription1 =
c1.Add(Bind(&Summer::AddOneParam, Unretained(&s)));
c1.Notify(1);
EXPECT_EQ(1, s.value_);
- CallbackRegistry<void(int, int)> c2;
- scoped_ptr<CallbackRegistry<void(int, int)>::Subscription> subscription2 =
+ CallbackList<void(int, int)> c2;
+ scoped_ptr<CallbackList<void(int, int)>::Subscription> subscription2 =
c2.Add(Bind(&Summer::AddTwoParam, Unretained(&s)));
c2.Notify(1, 2);
EXPECT_EQ(3, s.value_);
- CallbackRegistry<void(int, int, int)> c3;
- scoped_ptr<CallbackRegistry<void(int, int, int)>::Subscription>
+ CallbackList<void(int, int, int)> c3;
+ scoped_ptr<CallbackList<void(int, int, int)>::Subscription>
subscription3 = c3.Add(Bind(&Summer::AddThreeParam, Unretained(&s)));
c3.Notify(1, 2, 3);
EXPECT_EQ(6, s.value_);
- CallbackRegistry<void(int, int, int, int)> c4;
- scoped_ptr<CallbackRegistry<void(int, int, int, int)>::Subscription>
+ CallbackList<void(int, int, int, int)> c4;
+ scoped_ptr<CallbackList<void(int, int, int, int)>::Subscription>
subscription4 = c4.Add(Bind(&Summer::AddFourParam, Unretained(&s)));
c4.Notify(1, 2, 3, 4);
EXPECT_EQ(10, s.value_);
- CallbackRegistry<void(int, int, int, int, int)> c5;
- scoped_ptr<CallbackRegistry<void(int, int, int, int, int)>::Subscription>
+ CallbackList<void(int, int, int, int, int)> c5;
+ scoped_ptr<CallbackList<void(int, int, int, int, int)>::Subscription>
subscription5 = c5.Add(Bind(&Summer::AddFiveParam, Unretained(&s)));
c5.Notify(1, 2, 3, 4, 5);
EXPECT_EQ(15, s.value_);
- CallbackRegistry<void(int, int, int, int, int, int)> c6;
- scoped_ptr<CallbackRegistry<void(int, int, int, int, int, int)>::Subscription>
+ CallbackList<void(int, int, int, int, int, int)> c6;
+ scoped_ptr<CallbackList<void(int, int, int, int, int, int)>::Subscription>
subscription6 = c6.Add(Bind(&Summer::AddSixParam, Unretained(&s)));
c6.Notify(1, 2, 3, 4, 5, 6);
@@ -140,13 +140,13 @@ TEST(CallbackRegistryTest, ArityTest) {
// Sanity check that closures added to the list will be run, and those removed
// from the list will not be run.
-TEST(CallbackRegistryTest, BasicTest) {
- CallbackRegistry<void(void)> cb_reg;
+TEST(CallbackListTest, BasicTest) {
+ CallbackList<void(void)> cb_reg;
Listener a, b, c;
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> a_subscription =
+ scoped_ptr<CallbackList<void(void)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&a)));
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> b_subscription =
+ scoped_ptr<CallbackList<void(void)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&b)));
EXPECT_TRUE(a_subscription.get());
@@ -159,7 +159,7 @@ TEST(CallbackRegistryTest, BasicTest) {
b_subscription.reset();
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> c_subscription =
+ scoped_ptr<CallbackList<void(void)>::Subscription> c_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&c)));
cb_reg.Notify();
@@ -175,13 +175,13 @@ TEST(CallbackRegistryTest, BasicTest) {
// Sanity check that callbacks with details added to the list will be run, with
// the correct details, and those removed from the list will not be run.
-TEST(CallbackRegistryTest, BasicTestWithParams) {
- CallbackRegistry<void(int)> cb_reg;
+TEST(CallbackListTest, BasicTestWithParams) {
+ CallbackList<void(int)> cb_reg;
Listener a(1), b(-1), c(1);
- scoped_ptr<CallbackRegistry<void(int)>::Subscription> a_subscription =
+ scoped_ptr<CallbackList<void(int)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Listener::IncrementByMultipleOfScaler, Unretained(&a)));
- scoped_ptr<CallbackRegistry<void(int)>::Subscription> b_subscription =
+ scoped_ptr<CallbackList<void(int)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementByMultipleOfScaler, Unretained(&b)));
EXPECT_TRUE(a_subscription.get());
@@ -194,7 +194,7 @@ TEST(CallbackRegistryTest, BasicTestWithParams) {
b_subscription.reset();
- scoped_ptr<CallbackRegistry<void(int)>::Subscription> c_subscription =
+ scoped_ptr<CallbackList<void(int)>::Subscription> c_subscription =
cb_reg.Add(Bind(&Listener::IncrementByMultipleOfScaler, Unretained(&c)));
cb_reg.Notify(10);
@@ -210,20 +210,20 @@ TEST(CallbackRegistryTest, BasicTestWithParams) {
// Test the a callback can remove itself or a different callback from the list
// during iteration without invalidating the iterator.
-TEST(CallbackRegistryTest, RemoveCallbacksDuringIteration) {
- CallbackRegistry<void(void)> cb_reg;
+TEST(CallbackListTest, RemoveCallbacksDuringIteration) {
+ CallbackList<void(void)> cb_reg;
Listener a, b;
Remover remover_1, remover_2;
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> remover_1_sub =
+ scoped_ptr<CallbackList<void(void)>::Subscription> remover_1_sub =
cb_reg.Add(Bind(&Remover::IncrementTotalAndRemove,
Unretained(&remover_1)));
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> remover_2_sub =
+ scoped_ptr<CallbackList<void(void)>::Subscription> remover_2_sub =
cb_reg.Add(Bind(&Remover::IncrementTotalAndRemove,
Unretained(&remover_2)));
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> a_subscription =
+ scoped_ptr<CallbackList<void(void)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&a)));
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> b_subscription =
+ scoped_ptr<CallbackList<void(void)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&b)));
// |remover_1| will remove itself.
@@ -252,13 +252,13 @@ TEST(CallbackRegistryTest, RemoveCallbacksDuringIteration) {
// Test that a callback can add another callback to the list durning iteration
// without invalidating the iterator. The newly added callback should be run on
// the current iteration as will all other callbacks in the list.
-TEST(CallbackRegistryTest, AddCallbacksDuringIteration) {
- CallbackRegistry<void(void)> cb_reg;
+TEST(CallbackListTest, AddCallbacksDuringIteration) {
+ CallbackList<void(void)> cb_reg;
Adder a(&cb_reg);
Listener b;
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> a_subscription =
+ scoped_ptr<CallbackList<void(void)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Adder::AddCallback, Unretained(&a)));
- scoped_ptr<CallbackRegistry<void(void)>::Subscription> b_subscription =
+ scoped_ptr<CallbackList<void(void)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&b)));
cb_reg.Notify();
@@ -274,8 +274,8 @@ TEST(CallbackRegistryTest, AddCallbacksDuringIteration) {
}
// Sanity check: notifying an empty list is a no-op.
-TEST(CallbackRegistryTest, EmptyList) {
- CallbackRegistry<void(void)> cb_reg;
+TEST(CallbackListTest, EmptyList) {
+ CallbackList<void(void)> cb_reg;
cb_reg.Notify();
}
« no previous file with comments | « base/callback_list.h.pump ('k') | base/callback_list_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698