@@ -744,3 +744,36 @@ TEST(FlMethodChannelTest, DisposeAReplacedMethodChannel) {
744744 EXPECT_EQ (user_data1.count , 101 );
745745 EXPECT_EQ (user_data2.count , 102 );
746746}
747+
748+ // Called when the method call response is received in the CustomType
749+ // test.
750+ static void custom_type_response_cb (GObject* object,
751+ GAsyncResult* result,
752+ gpointer user_data) {
753+ g_autoptr (GError) error = nullptr ;
754+ g_autoptr (FlMethodResponse) response = fl_method_channel_invoke_method_finish (
755+ FL_METHOD_CHANNEL (object), result, &error);
756+ EXPECT_EQ (response, nullptr );
757+ EXPECT_NE (error, nullptr );
758+ EXPECT_STREQ (error->message , " Custom value not implemented" );
759+
760+ g_main_loop_quit (static_cast <GMainLoop*>(user_data));
761+ }
762+
763+ // Checks invoking a method with a custom type generates an error.
764+ TEST (FlMethodChannelTest, CustomType) {
765+ g_autoptr (GMainLoop) loop = g_main_loop_new (nullptr , 0 );
766+
767+ g_autoptr (FlEngine) engine = make_mock_engine ();
768+ g_autoptr (FlBinaryMessenger) messenger = fl_binary_messenger_new (engine);
769+ g_autoptr (FlStandardMethodCodec) codec = fl_standard_method_codec_new ();
770+ g_autoptr (FlMethodChannel) channel = fl_method_channel_new (
771+ messenger, " test/standard-method" , FL_METHOD_CODEC (codec));
772+
773+ g_autoptr (FlValue) args = fl_value_new_custom (42 , nullptr , nullptr );
774+ fl_method_channel_invoke_method (channel, " Echo" , args, nullptr ,
775+ custom_type_response_cb, loop);
776+
777+ // Blocks here until custom_type_response_cb is called.
778+ g_main_loop_run (loop);
779+ }
0 commit comments