5#import <XCTest/XCTest.h>
7#import "flutter/shell/platform/darwin/ios/platform_message_handler_ios.h"
9#import "flutter/common/task_runners.h"
10#import "flutter/fml/message_loop.h"
11#import "flutter/fml/thread.h"
12#import "flutter/lib/ui/window/platform_message.h"
13#import "flutter/lib/ui/window/platform_message_response.h"
14#import "flutter/shell/common/thread_host.h"
15#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
22 auto thread = std::make_unique<fml::Thread>(
name);
23 auto runner = thread->GetTaskRunner();
37 void Complete(std::unique_ptr<fml::Mapping>
data)
override { is_complete_ =
true; }
50 XCTAssertTrue(handler);
54 ThreadHost thread_host(
"io.flutter.test." + std::string(
self.name.UTF8String),
61 std::string channel =
"foo";
62 XCTestExpectation* didCallReply = [
self expectationWithDescription:@"didCallReply"];
63 handler->SetMessageHandler(
67 [didCallReply fulfill];
72 auto platform_message = std::make_unique<flutter::PlatformMessage>(channel, response);
73 handler->HandlePlatformMessage(std::move(platform_message));
75 [
self waitForExpectationsWithTimeout:1.0 handler:nil];
76 XCTAssertTrue(response->is_complete());
80 ThreadHost thread_host(
"io.flutter.test." + std::string(
self.name.UTF8String),
87 std::string channel =
"foo";
88 XCTestExpectation* didCallMessage = [
self expectationWithDescription:@"didCallMessage"];
89 handler->SetMessageHandler(
92 XCTFail(
@"This shouldn't be called");
96 handler->SetMessageHandler(channel, nil, nil);
99 auto platform_message = std::make_unique<flutter::PlatformMessage>(channel, response);
100 handler->HandlePlatformMessage(std::move(platform_message));
101 [didCallMessage fulfill];
103 [
self waitForExpectationsWithTimeout:1.0 handler:nil];
104 XCTAssertTrue(response->is_complete());
108 ThreadHost thread_host(
"io.flutter.test." + std::string(
self.name.UTF8String),
115 std::string channel =
"foo";
116 XCTestExpectation* didCallReply = [
self expectationWithDescription:@"didCallReply"];
117 NSObject<FlutterTaskQueue>* taskQueue = PlatformMessageHandlerIos::MakeBackgroundTaskQueue();
118 handler->SetMessageHandler(
121 XCTAssertFalse([NSThread isMainThread]);
123 [didCallReply fulfill];
128 auto platform_message = std::make_unique<flutter::PlatformMessage>(channel, response);
129 handler->HandlePlatformMessage(std::move(platform_message));
131 [
self waitForExpectationsWithTimeout:1.0 handler:nil];
132 XCTAssertTrue(response->is_complete());
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
static sk_sp< Effect > Create()
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
fml::RefPtr< fml::TaskRunner > GetPlatformTaskRunner() const
static void EnsureInitializedForCurrentThread()
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
virtual void PostTask(const fml::closure &task) override
@ kRaster
Suitable for thread which raster data.
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name)
fml::RefPtr< fml::TaskRunner > GetCurrentTaskRunner()
DEF_SWITCHES_START aot vmservice shared library name
RefPtr< T > AdoptRef(T *ptr)
The collection of all the threads used by the engine.
std::unique_ptr< fml::Thread > io_thread
std::unique_ptr< fml::Thread > raster_thread
std::unique_ptr< fml::Thread > ui_thread
std::shared_ptr< const fml::Mapping > data