Flutter Engine
The Flutter Engine
Instance Methods | List of all members
PlatformMessageHandlerIosTest Class Reference
Inheritance diagram for PlatformMessageHandlerIosTest:

Instance Methods

(void) - testCreate [implementation]
 
(void) - testSetAndCallHandler [implementation]
 
(void) - testSetClearAndCallHandler [implementation]
 
(void) - testSetAndCallHandlerTaskQueue [implementation]
 

Detailed Description

Definition at line 42 of file platform_message_handler_ios_test.mm.

Method Documentation

◆ testCreate

- (void) testCreate
implementation

Definition at line 38 of file platform_message_handler_ios_test.mm.

46 {
47 TaskRunners task_runners("test", GetCurrentTaskRunner(), CreateNewThread("raster"),
48 CreateNewThread("ui"), CreateNewThread("io"));
49 auto handler = std::make_unique<PlatformMessageHandlerIos>(task_runners.GetPlatformTaskRunner());
50 XCTAssertTrue(handler);
51}
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name)
fml::RefPtr< fml::TaskRunner > GetCurrentTaskRunner()

◆ testSetAndCallHandler

- (void) testSetAndCallHandler
implementation

Definition at line 38 of file platform_message_handler_ios_test.mm.

53 {
54 ThreadHost thread_host("io.flutter.test." + std::string(self.name.UTF8String),
55 ThreadHost::Type::kRaster | ThreadHost::Type::kIo | ThreadHost::Type::kUi);
56 TaskRunners task_runners(
57 "test", GetCurrentTaskRunner(), thread_host.raster_thread->GetTaskRunner(),
58 thread_host.ui_thread->GetTaskRunner(), thread_host.io_thread->GetTaskRunner());
59
60 auto handler = std::make_unique<PlatformMessageHandlerIos>(task_runners.GetPlatformTaskRunner());
61 std::string channel = "foo";
62 XCTestExpectation* didCallReply = [self expectationWithDescription:@"didCallReply"];
63 handler->SetMessageHandler(
64 channel,
65 ^(NSData* _Nullable data, FlutterBinaryReply _Nonnull reply) {
66 reply(nil);
67 [didCallReply fulfill];
68 },
69 nil);
71 task_runners.GetUITaskRunner()->PostTask([channel, response, &handler] {
72 auto platform_message = std::make_unique<flutter::PlatformMessage>(channel, response);
73 handler->HandlePlatformMessage(std::move(platform_message));
74 });
75 [self waitForExpectationsWithTimeout:1.0 handler:nil];
76 XCTAssertTrue(response->is_complete());
77}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
@ kRaster
Suitable for thread which raster data.
Definition: embedder.h:266
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ testSetAndCallHandlerTaskQueue

- (void) testSetAndCallHandlerTaskQueue
implementation

Definition at line 38 of file platform_message_handler_ios_test.mm.

107 {
108 ThreadHost thread_host("io.flutter.test." + std::string(self.name.UTF8String),
109 ThreadHost::Type::kRaster | ThreadHost::Type::kIo | ThreadHost::Type::kUi);
110 TaskRunners task_runners(
111 "test", GetCurrentTaskRunner(), thread_host.raster_thread->GetTaskRunner(),
112 thread_host.ui_thread->GetTaskRunner(), thread_host.io_thread->GetTaskRunner());
113
114 auto handler = std::make_unique<PlatformMessageHandlerIos>(task_runners.GetPlatformTaskRunner());
115 std::string channel = "foo";
116 XCTestExpectation* didCallReply = [self expectationWithDescription:@"didCallReply"];
117 NSObject<FlutterTaskQueue>* taskQueue = PlatformMessageHandlerIos::MakeBackgroundTaskQueue();
118 handler->SetMessageHandler(
119 channel,
120 ^(NSData* _Nullable data, FlutterBinaryReply _Nonnull reply) {
121 XCTAssertFalse([NSThread isMainThread]);
122 reply(nil);
123 [didCallReply fulfill];
124 },
125 taskQueue);
126 auto response = MockPlatformMessageResponse::Create();
127 task_runners.GetUITaskRunner()->PostTask([channel, response, &handler] {
128 auto platform_message = std::make_unique<flutter::PlatformMessage>(channel, response);
129 handler->HandlePlatformMessage(std::move(platform_message));
130 });
131 [self waitForExpectationsWithTimeout:1.0 handler:nil];
132 XCTAssertTrue(response->is_complete());
133}

◆ testSetClearAndCallHandler

- (void) testSetClearAndCallHandler
implementation

Definition at line 38 of file platform_message_handler_ios_test.mm.

79 {
80 ThreadHost thread_host("io.flutter.test." + std::string(self.name.UTF8String),
81 ThreadHost::Type::kRaster | ThreadHost::Type::kIo | ThreadHost::Type::kUi);
82 TaskRunners task_runners(
83 "test", GetCurrentTaskRunner(), thread_host.raster_thread->GetTaskRunner(),
84 thread_host.ui_thread->GetTaskRunner(), thread_host.io_thread->GetTaskRunner());
85
86 auto handler = std::make_unique<PlatformMessageHandlerIos>(task_runners.GetPlatformTaskRunner());
87 std::string channel = "foo";
88 XCTestExpectation* didCallMessage = [self expectationWithDescription:@"didCallMessage"];
89 handler->SetMessageHandler(
90 channel,
91 ^(NSData* _Nullable data, FlutterBinaryReply _Nonnull reply) {
92 XCTFail(@"This shouldn't be called");
93 reply(nil);
94 },
95 nil);
96 handler->SetMessageHandler(channel, nil, nil);
98 task_runners.GetUITaskRunner()->PostTask([channel, response, &handler, &didCallMessage] {
99 auto platform_message = std::make_unique<flutter::PlatformMessage>(channel, response);
100 handler->HandlePlatformMessage(std::move(platform_message));
101 [didCallMessage fulfill];
102 });
103 [self waitForExpectationsWithTimeout:1.0 handler:nil];
104 XCTAssertTrue(response->is_complete());
105}

The documentation for this class was generated from the following file: