| Index: webrtc/base/sigslot_unittest.cc
|
| diff --git a/webrtc/base/sigslot_unittest.cc b/webrtc/base/sigslot_unittest.cc
|
| index cb773363101b93e3f0ee05f3c3208ddbc7a69cea..e860fe33736da248646b40e475d92ccdf9b7d351 100644
|
| --- a/webrtc/base/sigslot_unittest.cc
|
| +++ b/webrtc/base/sigslot_unittest.cc
|
| @@ -36,6 +36,10 @@ class SigslotReceiver : public sigslot::has_slots<slot_policy> {
|
| ~SigslotReceiver() {
|
| }
|
|
|
| + // Provide copy constructor so that tests can exercise the has_slots copy
|
| + // constructor.
|
| + SigslotReceiver(const SigslotReceiver&) = default;
|
| +
|
| void Connect(sigslot::signal0<signal_policy>* signal) {
|
| if (!signal) return;
|
| Disconnect();
|
| @@ -222,7 +226,7 @@ TEST_F(SigslotMTLockTest, LockSanity) {
|
| }
|
|
|
| // Destroy signal and slot in different orders.
|
| -TEST(DestructionOrder, SignalFirst) {
|
| +TEST(SigslotDestructionOrder, SignalFirst) {
|
| sigslot::signal0<>* signal = new sigslot::signal0<>;
|
| SigslotReceiver<>* receiver = new SigslotReceiver<>();
|
| receiver->Connect(signal);
|
| @@ -232,7 +236,7 @@ TEST(DestructionOrder, SignalFirst) {
|
| delete receiver;
|
| }
|
|
|
| -TEST(DestructionOrder, SlotFirst) {
|
| +TEST(SigslotDestructionOrder, SlotFirst) {
|
| sigslot::signal0<>* signal = new sigslot::signal0<>;
|
| SigslotReceiver<>* receiver = new SigslotReceiver<>();
|
| receiver->Connect(signal);
|
| @@ -243,3 +247,28 @@ TEST(DestructionOrder, SlotFirst) {
|
| (*signal)();
|
| delete signal;
|
| }
|
| +
|
| +// Test that if a signal is copied, its slot connections are copied as well.
|
| +TEST(SigslotTest, CopyConnectedSignal) {
|
| + sigslot::signal<> signal;
|
| + SigslotReceiver<> receiver;
|
| + receiver.Connect(&signal);
|
| +
|
| + // Fire the copied signal, expecting the receiver to be notified.
|
| + sigslot::signal<> copied_signal(signal);
|
| + copied_signal();
|
| + EXPECT_EQ(1, receiver.signal_count());
|
| +}
|
| +
|
| +// Test that if a slot is copied, its signal connections are copied as well.
|
| +TEST(SigslotTest, CopyConnectedSlot) {
|
| + sigslot::signal<> signal;
|
| + SigslotReceiver<> receiver;
|
| + receiver.Connect(&signal);
|
| +
|
| + // Fire the signal after copying the receiver, expecting the copied receiver
|
| + // to be notified.
|
| + SigslotReceiver<> copied_receiver(receiver);
|
| + signal();
|
| + EXPECT_EQ(1, copied_receiver.signal_count());
|
| +}
|
|
|