commit afd1dcce0c2fcc7f581e83a47f0c8677afb2b011 parent 928c13ac528c9788299e9d6d43d5986c13eface3 Author: Dan Baker <dbaker@mozilla.com> Date: Mon, 27 Oct 2025 15:19:21 -0600 Bug 1995393 - Vendor libwebrtc from 2b75d76830 Upstream commit: https://webrtc.googlesource.com/src/+/2b75d768301a4937194493b681363d957625b78c Expand SignalTrampoline to cover signal1..signal4 Bug: webrtc:42222066 Change-Id: Ia789a78f97b47444aadb65a50d0429e9baf21aec Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/406720 Reviewed-by: Evan Shrubsole <eshr@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45485} Diffstat:
21 files changed, 162 insertions(+), 52 deletions(-)
diff --git a/third_party/libwebrtc/BUILD.gn b/third_party/libwebrtc/BUILD.gn @@ -724,6 +724,7 @@ if (rtc_include_tests && !build_with_chromium) { "rtc_base:rtc_numerics_unittests", "rtc_base:rtc_operations_chain_unittests", "rtc_base:rtc_task_queue_unittests", + "rtc_base:sigslot_trampoline_unittest", "rtc_base:sigslot_unittest", "rtc_base:task_queue_stdlib_unittest", "rtc_base:untyped_function_unittest", diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-27T21:16:10.421066+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-27T21:19:08.604271+00:00. # base of lastest vendoring -eb0e81786a +2b75d76830 diff --git a/third_party/libwebrtc/moz-patch-stack/s0001.patch b/third_party/libwebrtc/moz-patch-stack/s0001.patch @@ -1383,7 +1383,7 @@ index 5ccc3d7d38..cd957416bc 100644 const bool enable_svc_for_simulcast_; std::optional<SimulcastToSvcConverter> simulcast_to_svc_converter_; diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 14e7e51e68..429afac7cc 100644 +index 27cf292d16..8f22065957 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -449,6 +449,12 @@ rtc_library("logging") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -116,7 +116,7 @@ index e8484bfad5..ffafaf0a4a 100644 # TODO(https://bugs.webrtc.org/14437): Remove this section if general # Chromium fix resolves the problem. diff --git a/BUILD.gn b/BUILD.gn -index ef07265bf3..348be89bb9 100644 +index 3efce2dd19..cbfc05f243 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -33,7 +33,7 @@ if (is_android) { @@ -1008,7 +1008,7 @@ index 39aa39a41c..b26e30e8bb 100644 "/config/external/nspr", "/nsprpub/lib/ds", diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 429afac7cc..7da246c703 100644 +index 8f22065957..447feb99f8 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -326,6 +326,7 @@ rtc_library("sample_counter") { @@ -1053,7 +1053,7 @@ index 429afac7cc..7da246c703 100644 rtc_source_set("sigslot_trampoline") { sources = [ "sigslot_trampoline.h" ] -@@ -1234,14 +1240,17 @@ rtc_source_set("sigslot_trampoline") { +@@ -1245,14 +1251,17 @@ rtc_library("sigslot_trampoline_unittest") { } rtc_library("socket_address_pair") { @@ -1071,7 +1071,7 @@ index 429afac7cc..7da246c703 100644 visibility = [ "*" ] sources = [ "net_helper.cc", -@@ -1252,8 +1261,10 @@ rtc_library("net_helper") { +@@ -1263,8 +1272,10 @@ rtc_library("net_helper") { "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -1082,7 +1082,7 @@ index 429afac7cc..7da246c703 100644 visibility = [ "*" ] sources = [ "socket_adapters.cc", -@@ -1274,6 +1285,7 @@ rtc_library("socket_adapters") { +@@ -1285,6 +1296,7 @@ rtc_library("socket_adapters") { "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -1090,7 +1090,7 @@ index 429afac7cc..7da246c703 100644 rtc_library("network_route") { sources = [ -@@ -1288,6 +1300,7 @@ rtc_library("network_route") { +@@ -1299,6 +1311,7 @@ rtc_library("network_route") { } rtc_library("async_tcp_socket") { @@ -1098,7 +1098,7 @@ index 429afac7cc..7da246c703 100644 sources = [ "async_tcp_socket.cc", "async_tcp_socket.h", -@@ -1307,8 +1320,10 @@ rtc_library("async_tcp_socket") { +@@ -1318,8 +1331,10 @@ rtc_library("async_tcp_socket") { "network:sent_packet", ] } @@ -1109,7 +1109,7 @@ index 429afac7cc..7da246c703 100644 visibility = [ "*" ] sources = [ "async_udp_socket.cc", -@@ -1332,8 +1347,10 @@ rtc_library("async_udp_socket") { +@@ -1343,8 +1358,10 @@ rtc_library("async_udp_socket") { "system:no_unique_address", ] } @@ -1120,7 +1120,7 @@ index 429afac7cc..7da246c703 100644 visibility = [ "*" ] sources = [ "async_packet_socket.cc", -@@ -1356,6 +1373,7 @@ rtc_library("async_packet_socket") { +@@ -1367,6 +1384,7 @@ rtc_library("async_packet_socket") { "//third_party/abseil-cpp/absl/functional:any_invocable", ] } @@ -1128,7 +1128,7 @@ index 429afac7cc..7da246c703 100644 if (rtc_include_tests) { rtc_library("async_packet_socket_unittest") { -@@ -1441,6 +1459,7 @@ rtc_library("data_rate_limiter") { +@@ -1452,6 +1470,7 @@ rtc_library("data_rate_limiter") { } rtc_library("unique_id_generator") { @@ -1136,7 +1136,7 @@ index 429afac7cc..7da246c703 100644 sources = [ "unique_id_generator.cc", "unique_id_generator.h", -@@ -1458,6 +1477,7 @@ rtc_library("unique_id_generator") { +@@ -1469,6 +1488,7 @@ rtc_library("unique_id_generator") { "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -1144,7 +1144,7 @@ index 429afac7cc..7da246c703 100644 rtc_library("crc32") { sources = [ -@@ -1489,6 +1509,7 @@ rtc_library("stream") { +@@ -1500,6 +1520,7 @@ rtc_library("stream") { } rtc_library("rtc_certificate_generator") { @@ -1152,7 +1152,7 @@ index 429afac7cc..7da246c703 100644 visibility = [ "*" ] sources = [ "rtc_certificate_generator.cc", -@@ -1503,6 +1524,7 @@ rtc_library("rtc_certificate_generator") { +@@ -1514,6 +1535,7 @@ rtc_library("rtc_certificate_generator") { "//third_party/abseil-cpp/absl/functional:any_invocable", ] } @@ -1160,7 +1160,7 @@ index 429afac7cc..7da246c703 100644 rtc_source_set("ssl_header") { visibility = [ "*" ] -@@ -1559,6 +1581,7 @@ rtc_library("crypto_random") { +@@ -1570,6 +1592,7 @@ rtc_library("crypto_random") { } rtc_library("ssl") { @@ -1168,7 +1168,7 @@ index 429afac7cc..7da246c703 100644 visibility = [ "*" ] sources = [ "openssl_key_pair.cc", -@@ -1631,6 +1654,7 @@ rtc_library("ssl") { +@@ -1642,6 +1665,7 @@ rtc_library("ssl") { deps += [ ":win32" ] } } @@ -1176,7 +1176,7 @@ index 429afac7cc..7da246c703 100644 rtc_library("ssl_adapter") { visibility = [ "*" ] -@@ -2355,7 +2379,7 @@ if (rtc_include_tests) { +@@ -2366,7 +2390,7 @@ if (rtc_include_tests) { } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0034.patch b/third_party/libwebrtc/moz-patch-stack/s0034.patch @@ -20,7 +20,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e2 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index 348be89bb9..19ff7e3f98 100644 +index cbfc05f243..ba0be681c7 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -444,12 +444,12 @@ config("common_config") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0045.patch b/third_party/libwebrtc/moz-patch-stack/s0045.patch @@ -18,7 +18,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb89 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index 19ff7e3f98..ff01d30f95 100644 +index ba0be681c7..bcf71680dc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -224,6 +224,9 @@ config("common_inherited_config") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0053.patch b/third_party/libwebrtc/moz-patch-stack/s0053.patch @@ -29,7 +29,7 @@ index 7db75d5fd3..d0feb5007c 100644 rtc_library("task_queue_test") { visibility = [ "*" ] diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 7da246c703..694a99017c 100644 +index 447feb99f8..48d7a173fe 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -664,10 +664,14 @@ if (is_mac || is_ios) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0055.patch b/third_party/libwebrtc/moz-patch-stack/s0055.patch @@ -11,7 +11,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca 2 files changed, 10 insertions(+) diff --git a/BUILD.gn b/BUILD.gn -index ff01d30f95..2a5381ec09 100644 +index bcf71680dc..33ed200085 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -628,6 +628,10 @@ if (!build_with_chromium) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0084.patch b/third_party/libwebrtc/moz-patch-stack/s0084.patch @@ -11,7 +11,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2185cab977988fd4a 3 files changed, 16 insertions(+) diff --git a/BUILD.gn b/BUILD.gn -index 2a5381ec09..82aede5e28 100644 +index 33ed200085..a1010e5e9a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -613,6 +613,7 @@ if (!build_with_chromium) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0091.patch b/third_party/libwebrtc/moz-patch-stack/s0091.patch @@ -13,7 +13,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4e7b3c485e549e7e3 1 file changed, 6 insertions(+) diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 694a99017c..2e662a5d41 100644 +index 48d7a173fe..37c41c2c68 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -992,6 +992,12 @@ rtc_library("threading") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0093.patch b/third_party/libwebrtc/moz-patch-stack/s0093.patch @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b050c455caa1d24a0 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index 82aede5e28..b602b8d2ce 100644 +index a1010e5e9a..771e0b196a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -280,6 +280,7 @@ config("rtc_prod_config") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0094.patch b/third_party/libwebrtc/moz-patch-stack/s0094.patch @@ -9,10 +9,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee2f06666bcc6d22c 1 file changed, 2 insertions(+) diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 2e662a5d41..fea1177742 100644 +index 37c41c2c68..ec8f58e606 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn -@@ -1667,6 +1667,7 @@ if (!build_with_mozilla) { +@@ -1678,6 +1678,7 @@ if (!build_with_mozilla) { } rtc_library("ssl_adapter") { @@ -20,7 +20,7 @@ index 2e662a5d41..fea1177742 100644 visibility = [ "*" ] sources = [ "openssl_adapter.cc", -@@ -1715,6 +1716,7 @@ rtc_library("ssl_adapter") { +@@ -1726,6 +1727,7 @@ rtc_library("ssl_adapter") { configs += [ "..:external_ssl_library" ] } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch @@ -75,7 +75,7 @@ index 4df8681a9b..269ca2f5a7 100644 # The python interpreter to use by default. On Windows, this will look # for vpython3.exe and vpython3.bat. diff --git a/BUILD.gn b/BUILD.gn -index b602b8d2ce..4603ed3cfd 100644 +index 771e0b196a..7e1e8353ab 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,15 +21,15 @@ @@ -107,7 +107,7 @@ index b602b8d2ce..4603ed3cfd 100644 defines = [] deps = [ -@@ -856,7 +856,7 @@ rtc_static_library("dcsctp") { +@@ -857,7 +857,7 @@ rtc_static_library("dcsctp") { visibility = [ "//:default" ] sources = [] complete_static_lib = true @@ -116,7 +116,7 @@ index b602b8d2ce..4603ed3cfd 100644 defines = [] deps = [ "net/dcsctp/public:factory", -@@ -891,7 +891,7 @@ group("poison_software_video_codecs") { +@@ -892,7 +892,7 @@ group("poison_software_video_codecs") { if (!build_with_chromium) { # Write debug logs to gn_logs.txt. # This is also required for Siso builds. @@ -616,7 +616,7 @@ index 696829d6ca..81bd2a6215 100644 if (rtc_build_libsrtp) { diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index fea1177742..15e24ce17e 100644 +index ec8f58e606..aa626933d5 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -9,8 +9,8 @@ @@ -630,7 +630,7 @@ index fea1177742..15e24ce17e 100644 } rtc_source_set("protobuf_utils") { -@@ -1908,8 +1908,8 @@ if (!rtc_rusty_base64) { +@@ -1919,8 +1919,8 @@ if (!rtc_rusty_base64) { ] } } else { diff --git a/third_party/libwebrtc/moz-patch-stack/s0105.patch b/third_party/libwebrtc/moz-patch-stack/s0105.patch @@ -9,7 +9,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/90a33b06e51017d25 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn -index 4603ed3cfd..6bfae033a3 100644 +index 7e1e8353ab..c73a7287bf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -569,6 +569,7 @@ if (!build_with_chromium) { @@ -20,7 +20,7 @@ index 4603ed3cfd..6bfae033a3 100644 "logging:rtc_event_log_api", "media", "modules", -@@ -853,7 +854,7 @@ if (rtc_include_tests && !build_with_chromium) { +@@ -854,7 +855,7 @@ if (rtc_include_tests && !build_with_chromium) { # Build target for standalone dcsctp rtc_static_library("dcsctp") { # Only the root target should depend on this. diff --git a/third_party/libwebrtc/moz-patch-stack/s0107.patch b/third_party/libwebrtc/moz-patch-stack/s0107.patch @@ -16,7 +16,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4527c41ef71d7683c 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index 6bfae033a3..2a6c14f35b 100644 +index c73a7287bf..246f9f9a1c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -525,6 +525,9 @@ if (!rtc_build_ssl) { @@ -116,10 +116,10 @@ index ecbb7eae7e..a13fe19324 100644 public_configs = [] if (!build_with_chromium) { diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 15e24ce17e..8545ddf16f 100644 +index aa626933d5..ad1ce1383a 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn -@@ -1546,6 +1546,7 @@ rtc_source_set("ssl_header") { +@@ -1557,6 +1557,7 @@ rtc_source_set("ssl_header") { } rtc_library("digest") { @@ -127,7 +127,7 @@ index 15e24ce17e..8545ddf16f 100644 visibility = [ "*" ] sources = [ "message_digest.cc", -@@ -1567,8 +1568,10 @@ rtc_library("digest") { +@@ -1578,8 +1579,10 @@ rtc_library("digest") { configs += [ "..:external_ssl_library" ] } } @@ -138,7 +138,7 @@ index 15e24ce17e..8545ddf16f 100644 visibility = [ "*" ] sources = [ "crypto_random.cc", -@@ -1589,6 +1592,7 @@ rtc_library("crypto_random") { +@@ -1600,6 +1603,7 @@ rtc_library("crypto_random") { configs += [ "..:external_ssl_library" ] } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0111.patch b/third_party/libwebrtc/moz-patch-stack/s0111.patch @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/27c29807e6f46562d 1 file changed, 1 insertion(+) diff --git a/BUILD.gn b/BUILD.gn -index 2a6c14f35b..8fb557c9fc 100644 +index 246f9f9a1c..8240fc84d6 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -619,6 +619,7 @@ if (!build_with_chromium) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0128.patch b/third_party/libwebrtc/moz-patch-stack/s0128.patch @@ -9,7 +9,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/43de54a6e52daf0a0 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn -index 8fb557c9fc..9674052831 100644 +index 8240fc84d6..a3b738a7e1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -315,6 +315,16 @@ config("common_config") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0130.patch b/third_party/libwebrtc/moz-patch-stack/s0130.patch @@ -9,7 +9,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8e7778c59894c284b 1 file changed, 1 insertion(+) diff --git a/BUILD.gn b/BUILD.gn -index 9674052831..058f756169 100644 +index a3b738a7e1..2b3e510f76 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -629,6 +629,7 @@ if (!build_with_chromium) { diff --git a/third_party/libwebrtc/rtc_base/BUILD.gn b/third_party/libwebrtc/rtc_base/BUILD.gn @@ -1249,6 +1249,17 @@ rtc_source_set("sigslot_trampoline") { ] } +rtc_library("sigslot_trampoline_unittest") { + testonly = true + sources = [ "sigslot_trampoline_unittest.cc" ] + deps = [ + ":sigslot_trampoline", + "../test:test_support", + "third_party/sigslot", + "//third_party/abseil-cpp/absl/functional:any_invocable", + ] +} + rtc_library("socket_address_pair") { if (!build_with_mozilla) { sources = [ diff --git a/third_party/libwebrtc/rtc_base/sigslot_trampoline.h b/third_party/libwebrtc/rtc_base/sigslot_trampoline.h @@ -51,20 +51,49 @@ namespace webrtc { // my_class_object.SubscibeMyNamedEvent( // SafeInvocable(target.safety_flag_.flag(), // [target] { target.function(); } +namespace internal { +template <typename MemberPtrT> +struct member_pointer_traits; -template <class T, sigslot::signal0<> T::* member_signal> -class SignalTrampoline : public sigslot::has_slots<> { +// Used to find the type of ClassT::Member +template <typename ClassT, typename MemberT> +struct member_pointer_traits<MemberT ClassT::*> { + using member_type = MemberT; +}; + +template <typename SignalT> +class SignalTrampolineBase; + +template <typename... Args> +class SignalTrampolineBase<sigslot::signal<Args...>> + : public sigslot::has_slots<> { public: - explicit SignalTrampoline(T* that) { - (that->*member_signal).connect(this, &SignalTrampoline::Notify); - } - void Subscribe(absl::AnyInvocable<void()> callback) { + void Subscribe(absl::AnyInvocable<void(Args...)> callback) { callbacks_.AddReceiver(std::move(callback)); } + void Notify(Args... args) { callbacks_.Send(args...); } + + private: + CallbackList<Args...> callbacks_; +}; + +template <typename T, auto member_signal> +using SignalTrampolineMemberBase = + SignalTrampolineBase<typename internal::member_pointer_traits< + decltype(member_signal)>::member_type>; +} // namespace internal + +template <class T, auto member_signal> +class SignalTrampoline + : public internal::SignalTrampolineMemberBase<T, member_signal> { private: - void Notify() { callbacks_.Send(); } - CallbackList<> callbacks_; + using Base = internal::SignalTrampolineMemberBase<T, member_signal>; + + public: + explicit SignalTrampoline(T* that) { + (that->*member_signal).connect(static_cast<Base*>(this), &Base::Notify); + } }; } // namespace webrtc diff --git a/third_party/libwebrtc/rtc_base/sigslot_trampoline_unittest.cc b/third_party/libwebrtc/rtc_base/sigslot_trampoline_unittest.cc @@ -0,0 +1,69 @@ +/* + * Copyright 2025 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "rtc_base/sigslot_trampoline.h" + +#include <utility> + +#include "absl/functional/any_invocable.h" +#include "rtc_base/third_party/sigslot/sigslot.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { +namespace { + +using ::testing::Mock; +using ::testing::MockFunction; +using ::testing::StrictMock; + +class ClassWithSlots { + public: + ClassWithSlots() : signal_0_trampoline_(this), signal_1_trampoline_(this) {} + + sigslot::signal0<> Signal0; + void NotifySignal0() { Signal0(); } + void SubscribeSignal0(absl::AnyInvocable<void()> callback) { + signal_0_trampoline_.Subscribe(std::move(callback)); + } + sigslot::signal1<int> Signal1; + void NotifySignal1(int arg) { Signal1(arg); } + void SubscribeSignal1(absl::AnyInvocable<void(int)> callback) { + signal_1_trampoline_.Subscribe(std::move(callback)); + } + + private: + SignalTrampoline<ClassWithSlots, &ClassWithSlots::Signal0> + signal_0_trampoline_; + SignalTrampoline<ClassWithSlots, &ClassWithSlots::Signal1> + signal_1_trampoline_; +}; + +TEST(SigslotTrampolineTest, FireSignal0) { + ClassWithSlots item; + StrictMock<MockFunction<void()>> mock_slot; + item.SubscribeSignal0(mock_slot.AsStdFunction()); + Mock::VerifyAndClearExpectations(&mock_slot); // No call before Notify + EXPECT_CALL(mock_slot, Call()); + item.NotifySignal0(); +} + +TEST(SigslotTrampolineTest, FireSignal1) { + ClassWithSlots item; + StrictMock<MockFunction<void(int)>> mock_slot; + item.SubscribeSignal1(mock_slot.AsStdFunction()); + Mock::VerifyAndClearExpectations(&mock_slot); // No call before Notify + EXPECT_CALL(mock_slot, Call(7)); + item.NotifySignal1(7); +} + +} // namespace + +} // namespace webrtc