22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- #include " flutter/shell/platform/common/cpp/client_wrapper/include/flutter/event_channel.h"
6-
75#include < memory>
86#include < string>
97
108#include " flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h"
9+ #include " flutter/shell/platform/common/cpp/client_wrapper/include/flutter/event_channel.h"
1110#include " flutter/shell/platform/common/cpp/client_wrapper/include/flutter/event_stream_handler_functions.h"
1211#include " flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h"
1312#include " gtest/gtest.h"
@@ -51,25 +50,21 @@ TEST(EventChannelTest, Registration) {
5150 EventChannel channel (&messenger, channel_name, &codec);
5251
5352 bool on_listen_called = false ;
54- auto handler = std::make_unique<
55- flutter::StreamHandlerFunctions<flutter::EncodableValue>>(
56- [&on_listen_called](
57- const flutter::EncodableValue* arguments,
58- std::unique_ptr<flutter::EventSink<flutter::EncodableValue>>&& events)
59- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue>> {
53+ auto handler = std::make_unique<StreamHandlerFunctions<>>(
54+ [&on_listen_called](const EncodableValue* arguments,
55+ std::unique_ptr<EventSink<>>&& events)
56+ -> std::unique_ptr<StreamHandlerError<>> {
6057 on_listen_called = true ;
6158 return nullptr ;
6259 },
63- [](const flutter::EncodableValue* arguments)
64- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue>> {
65- return nullptr ;
66- });
60+ [](const EncodableValue* arguments)
61+ -> std::unique_ptr<StreamHandlerError<>> { return nullptr ; });
6762 channel.SetStreamHandler (std::move (handler));
6863 EXPECT_EQ (messenger.last_message_handler_channel (), channel_name);
6964 EXPECT_NE (messenger.last_message_handler (), nullptr );
7065
7166 // Send dummy listen message.
72- MethodCall<flutter::EncodableValue > call (" listen" , nullptr );
67+ MethodCall<> call (" listen" , nullptr );
7368 auto message = codec.EncodeMethodCall (call);
7469 messenger.last_message_handler ()(
7570 message->data (), message->size (),
@@ -86,17 +81,11 @@ TEST(EventChannelTest, Unregistration) {
8681 const StandardMethodCodec& codec = StandardMethodCodec::GetInstance ();
8782 EventChannel channel (&messenger, channel_name, &codec);
8883
89- auto handler = std::make_unique<
90- flutter::StreamHandlerFunctions<flutter::EncodableValue>>(
91- [](const flutter::EncodableValue* arguments,
92- std::unique_ptr<flutter::EventSink<flutter::EncodableValue>>&& events)
93- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue>> {
94- return nullptr ;
95- },
96- [](const flutter::EncodableValue* arguments)
97- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue>> {
98- return nullptr ;
99- });
84+ auto handler = std::make_unique<StreamHandlerFunctions<>>(
85+ [](const EncodableValue* arguments, std::unique_ptr<EventSink<>>&& events)
86+ -> std::unique_ptr<StreamHandlerError<>> { return nullptr ; },
87+ [](const EncodableValue* arguments)
88+ -> std::unique_ptr<StreamHandlerError<>> { return nullptr ; });
10089 channel.SetStreamHandler (std::move (handler));
10190 EXPECT_EQ (messenger.last_message_handler_channel (), channel_name);
10291 EXPECT_NE (messenger.last_message_handler (), nullptr );
@@ -115,17 +104,15 @@ TEST(EventChannelTest, Cancel) {
115104
116105 bool on_listen_called = false ;
117106 bool on_cancel_called = false ;
118- auto handler = std::make_unique<
119- flutter::StreamHandlerFunctions<flutter::EncodableValue>>(
120- [&on_listen_called](
121- const flutter::EncodableValue* arguments,
122- std::unique_ptr<flutter::EventSink<flutter::EncodableValue>>&& events)
123- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue>> {
107+ auto handler = std::make_unique<StreamHandlerFunctions<>>(
108+ [&on_listen_called](const EncodableValue* arguments,
109+ std::unique_ptr<EventSink<>>&& events)
110+ -> std::unique_ptr<StreamHandlerError<>> {
124111 on_listen_called = true ;
125112 return nullptr ;
126113 },
127- [&on_cancel_called](const flutter:: EncodableValue* arguments)
128- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue >> {
114+ [&on_cancel_called](const EncodableValue* arguments)
115+ -> std::unique_ptr<StreamHandlerError<>> {
129116 on_cancel_called = true ;
130117 return nullptr ;
131118 });
@@ -134,15 +121,15 @@ TEST(EventChannelTest, Cancel) {
134121 EXPECT_NE (messenger.last_message_handler (), nullptr );
135122
136123 // Send dummy listen message.
137- MethodCall<flutter::EncodableValue > call_listen (" listen" , nullptr );
124+ MethodCall<> call_listen (" listen" , nullptr );
138125 auto message = codec.EncodeMethodCall (call_listen);
139126 messenger.last_message_handler ()(
140127 message->data (), message->size (),
141128 [](const uint8_t * reply, const size_t reply_size) {});
142129 EXPECT_EQ (on_listen_called, true );
143130
144131 // Send dummy cancel message.
145- MethodCall<flutter::EncodableValue > call_cancel (" cancel" , nullptr );
132+ MethodCall<> call_cancel (" cancel" , nullptr );
146133 message = codec.EncodeMethodCall (call_cancel);
147134 messenger.last_message_handler ()(
148135 message->data (), message->size (),
@@ -164,17 +151,15 @@ TEST(EventChannelTest, ReRegistration) {
164151
165152 bool on_listen_called = false ;
166153 bool on_cancel_called = false ;
167- auto handler = std::make_unique<
168- flutter::StreamHandlerFunctions<flutter::EncodableValue>>(
169- [&on_listen_called](
170- const flutter::EncodableValue* arguments,
171- std::unique_ptr<flutter::EventSink<flutter::EncodableValue>>&& events)
172- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue>> {
154+ auto handler = std::make_unique<StreamHandlerFunctions<>>(
155+ [&on_listen_called](const EncodableValue* arguments,
156+ std::unique_ptr<EventSink<>>&& events)
157+ -> std::unique_ptr<StreamHandlerError<>> {
173158 on_listen_called = true ;
174159 return nullptr ;
175160 },
176- [&on_cancel_called](const flutter:: EncodableValue* arguments)
177- -> std::unique_ptr<StreamHandlerError<flutter::EncodableValue >> {
161+ [&on_cancel_called](const EncodableValue* arguments)
162+ -> std::unique_ptr<StreamHandlerError<>> {
178163 on_cancel_called = true ;
179164 return nullptr ;
180165 });
@@ -183,7 +168,7 @@ TEST(EventChannelTest, ReRegistration) {
183168 EXPECT_NE (messenger.last_message_handler (), nullptr );
184169
185170 // Send dummy listen message.
186- MethodCall<flutter::EncodableValue > call (" listen" , nullptr );
171+ MethodCall<> call (" listen" , nullptr );
187172 auto message = codec.EncodeMethodCall (call);
188173 messenger.last_message_handler ()(
189174 message->data (), message->size (),
0 commit comments