Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ce1eb37

Browse files
Fix the mapping from exit response strings to the FlPlatformChannelExitResponse enum (#56769)
1 parent 0ced389 commit ce1eb37

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45060,6 +45060,7 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h
4506045060
ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_test.cc + ../../../flutter/LICENSE
4506145061
ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_channel.cc + ../../../flutter/LICENSE
4506245062
ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_channel.h + ../../../flutter/LICENSE
45063+
ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_channel_test.cc + ../../../flutter/LICENSE
4506345064
ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_handler.cc + ../../../flutter/LICENSE
4506445065
ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_handler.h + ../../../flutter/LICENSE
4506545066
ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_handler_test.cc + ../../../flutter/LICENSE
@@ -48008,6 +48009,7 @@ FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h
4800848009
FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_test.cc
4800948010
FILE: ../../../flutter/shell/platform/linux/fl_platform_channel.cc
4801048011
FILE: ../../../flutter/shell/platform/linux/fl_platform_channel.h
48012+
FILE: ../../../flutter/shell/platform/linux/fl_platform_channel_test.cc
4801148013
FILE: ../../../flutter/shell/platform/linux/fl_platform_handler.cc
4801248014
FILE: ../../../flutter/shell/platform/linux/fl_platform_handler.h
4801348015
FILE: ../../../flutter/shell/platform/linux/fl_platform_handler_test.cc

shell/platform/linux/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ executable("flutter_linux_unittests") {
230230
"fl_method_codec_test.cc",
231231
"fl_method_response_test.cc",
232232
"fl_pixel_buffer_texture_test.cc",
233+
"fl_platform_channel_test.cc",
233234
"fl_platform_handler_test.cc",
234235
"fl_plugin_registrar_test.cc",
235236
"fl_pointer_manager_test.cc",

shell/platform/linux/fl_platform_channel.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ FlPlatformChannelExitResponse get_exit_response(FlMethodResponse* response) {
110110
if (strcmp(response_string, kExitResponseCancel) == 0) {
111111
return FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL;
112112
} else if (strcmp(response_string, kExitResponseExit) == 0) {
113-
return FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL;
113+
return FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT;
114114
}
115115

116116
// If something went wrong, then just exit.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "flutter/shell/platform/linux/fl_platform_channel.h"
6+
#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"
7+
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
8+
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
9+
#include "flutter/shell/platform/linux/testing/fl_test.h"
10+
#include "gtest/gtest.h"
11+
12+
static void exit_method_response_cb(GObject* object,
13+
GAsyncResult* result,
14+
gpointer user_data) {
15+
g_autoptr(GError) error = nullptr;
16+
FlPlatformChannelExitResponse response;
17+
gboolean success = fl_platform_channel_system_request_app_exit_finish(
18+
object, result, &response, &error);
19+
20+
EXPECT_TRUE(success);
21+
EXPECT_EQ(response, FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT);
22+
23+
g_main_loop_quit(static_cast<GMainLoop*>(user_data));
24+
}
25+
26+
TEST(FlPlatformChannelTest, ExitResponse) {
27+
g_autoptr(GMainLoop) loop = g_main_loop_new(nullptr, 0);
28+
29+
g_autoptr(FlEngine) engine = make_mock_engine();
30+
g_autoptr(FlBinaryMessenger) messenger = fl_binary_messenger_new(engine);
31+
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
32+
g_autoptr(FlMethodChannel) channel = fl_method_channel_new(
33+
messenger, "test/standard-method", FL_METHOD_CODEC(codec));
34+
35+
g_autoptr(FlValue) args = fl_value_new_map();
36+
fl_value_set_string_take(args, "response", fl_value_new_string("exit"));
37+
38+
fl_method_channel_invoke_method(channel, "Echo", args, nullptr,
39+
exit_method_response_cb, loop);
40+
41+
// Blocks here until method_response_cb is called.
42+
g_main_loop_run(loop);
43+
}

0 commit comments

Comments
 (0)