// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/callback_list.h" #include <memory> #include <utility> #include "base/functional/bind.h" #include "base/functional/callback_helpers.h" #include "base/memory/raw_ptr.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { namespace { class Listener { … }; class Remover { … }; class Adder { … }; class Summer { … }; class Counter { … }; // Sanity check that we can instantiate a CallbackList for each arity. TEST(CallbackListTest, ArityTest) { … } // Sanity check that closures added to the list will be run, and those removed // from the list will not be run. TEST(CallbackListTest, BasicTest) { … } // Similar to BasicTest but with OnceCallbacks instead of Repeating. TEST(CallbackListTest, OnceCallbacks) { … } // 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(CallbackListTest, BasicTestWithParams) { … } // Test the a callback can remove itself or a different callback from the list // during iteration without invalidating the iterator. TEST(CallbackListTest, RemoveCallbacksDuringIteration) { … } // Similar to RemoveCallbacksDuringIteration but with OnceCallbacks instead of // Repeating. TEST(CallbackListTest, RemoveOnceCallbacksDuringIteration) { … } // 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(CallbackListTest, AddCallbacksDuringIteration) { … } // Sanity check: notifying an empty list is a no-op. TEST(CallbackListTest, EmptyList) { … } // empty() should be callable during iteration, and return false if not all the // remaining callbacks in the list are null. TEST(CallbackListTest, NonEmptyListDuringIteration) { … } // empty() should be callable during iteration, and return true if all the // remaining callbacks in the list are null. TEST(CallbackListTest, EmptyListDuringIteration) { … } TEST(CallbackListTest, RemovalCallback) { … } TEST(CallbackListTest, AbandonSubscriptions) { … } // Subscriptions should be movable. TEST(CallbackListTest, MoveSubscription) { … } TEST(CallbackListTest, CancelBeforeRunning) { … } // Verifies Notify() can be called reentrantly and what its expected effects // are. TEST(CallbackListTest, ReentrantNotify) { … } } // namespace } // namespace base