OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 // foo.emit("hello"); | 33 // foo.emit("hello"); |
34 // EXPECT_EQ(1, slot.callback_count()); | 34 // EXPECT_EQ(1, slot.callback_count()); |
35 // EXPECT_EQ("hello", capture); | 35 // EXPECT_EQ("hello", capture); |
36 // /* See unit-tests for more examples */ | 36 // /* See unit-tests for more examples */ |
37 | 37 |
38 #include "webrtc/base/constructormagic.h" | 38 #include "webrtc/base/constructormagic.h" |
39 #include "webrtc/base/sigslot.h" | 39 #include "webrtc/base/sigslot.h" |
40 | 40 |
41 namespace rtc { | 41 namespace rtc { |
42 | 42 |
43 // For all the templates below: | 43 // Base version for testing signals that passes no arguments. |
| 44 class SigslotTester0 : public sigslot::has_slots<> { |
| 45 public: |
| 46 explicit SigslotTester0(sigslot::signal0<>* signal) : callback_count_(0) { |
| 47 signal->connect(this, &SigslotTester0::OnSignalCallback); |
| 48 } |
| 49 |
| 50 int callback_count() const { return callback_count_; } |
| 51 |
| 52 private: |
| 53 void OnSignalCallback() { callback_count_++; } |
| 54 int callback_count_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(SigslotTester0); |
| 57 }; |
| 58 |
| 59 // Versions below are for testing signals that pass arguments. For all the |
| 60 // templates below: |
44 // - A1-A5 is the type of the argument i in the callback. Signals may and often | 61 // - A1-A5 is the type of the argument i in the callback. Signals may and often |
45 // do use const-references here for efficiency. | 62 // do use const-references here for efficiency. |
46 // - C1-C5 is the type of the variable to capture argument i. These should be | 63 // - C1-C5 is the type of the variable to capture argument i. These should be |
47 // non-const value types suitable for use as lvalues. | 64 // non-const value types suitable for use as lvalues. |
48 | 65 |
49 $var n = 5 | 66 $var n = 5 |
50 $range i 1..n | 67 $range i 1..n |
51 $for i [[ | 68 $for i [[ |
52 $range j 1..i | 69 $range j 1..i |
53 | 70 |
(...skipping 22 matching lines...) Expand all Loading... |
76 C$j* capture$j[[]]_;]] | 93 C$j* capture$j[[]]_;]] |
77 | 94 |
78 | 95 |
79 RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester$i); | 96 RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester$i); |
80 }; | 97 }; |
81 | 98 |
82 ]] | 99 ]] |
83 } // namespace rtc | 100 } // namespace rtc |
84 | 101 |
85 #endif // WEBRTC_BASE_SIGSLOTTESTER_H_ | 102 #endif // WEBRTC_BASE_SIGSLOTTESTER_H_ |
OLD | NEW |