6 #define FML_USED_ON_EMBEDDER
8 #import <OCMock/OCMock.h>
9 #import <XCTest/XCTest.h>
11 #include "flutter/fml/message_loop.h"
23 void OnPlatformViewCreated(std::unique_ptr<Surface> surface)
override {}
24 void OnPlatformViewDestroyed()
override {}
25 void OnPlatformViewScheduleFrame()
override {}
26 void OnPlatformViewSetNextFrameCallback(
const fml::closure& closure)
override {}
27 void OnPlatformViewSetViewportMetrics(int64_t view_id,
const ViewportMetrics& metrics)
override {}
28 const flutter::Settings& OnPlatformViewGetSettings()
const override {
return settings_; }
29 void OnPlatformViewDispatchPlatformMessage(std::unique_ptr<PlatformMessage> message)
override {}
30 void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr<PointerDataPacket> packet)
override {
32 void OnPlatformViewDispatchSemanticsAction(int32_t
id,
33 SemanticsAction action,
34 fml::MallocMapping args)
override {}
35 void OnPlatformViewSetSemanticsEnabled(
bool enabled)
override {}
36 void OnPlatformViewSetAccessibilityFeatures(int32_t flags)
override {}
37 void OnPlatformViewRegisterTexture(std::shared_ptr<Texture> texture)
override {}
38 void OnPlatformViewUnregisterTexture(int64_t
texture_id)
override {}
39 void OnPlatformViewMarkTextureFrameAvailable(int64_t
texture_id)
override {}
41 void LoadDartDeferredLibrary(intptr_t loading_unit_id,
42 std::unique_ptr<const fml::Mapping> snapshot_data,
43 std::unique_ptr<const fml::Mapping> snapshot_instructions)
override {
45 void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
46 const std::string error_message,
47 bool transient)
override {}
48 void UpdateAssetResolverByType(std::unique_ptr<AssetResolver> updated_asset_resolver,
49 AssetResolver::AssetResolverType type)
override {}
62 std::unique_ptr<fml::WeakPtrFactory<flutter::PlatformView>>
weak_factory;
66 fml::MessageLoop::EnsureInitializedForCurrentThread();
67 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
68 auto sync_switch = std::make_shared<fml::SyncSwitch>();
69 flutter::TaskRunners runners(
self.name.UTF8String,
91 - (fml::WeakPtr<flutter::PlatformView>)platformViewReplacement {
95 - (void)testMsaaSampleCount {
98 XCTAssertEqual(
platform_view->GetIosContext()->GetMsaaSampleCount(), MsaaSampleCount::kFour);
101 XCTAssertEqual(
platform_view->GetIosContext()->GetMsaaSampleCount(), MsaaSampleCount::kNone);
108 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
109 auto sync_switch = std::make_shared<fml::SyncSwitch>();
110 flutter::TaskRunners runners(
self.name.UTF8String,
115 auto msaa_4x_platform_view = std::make_unique<flutter::PlatformViewIOS>(
123 XCTAssertEqual(msaa_4x_platform_view->GetIosContext()->GetMsaaSampleCount(),
124 MsaaSampleCount::kFour);
127 - (void)testCallsNotifyLowMemory {
130 id mockEngine = OCMPartialMock(
engine);
131 OCMStub([mockEngine notifyLowMemory]);
132 OCMStub([mockEngine iosPlatformView]).andReturn(
platform_view.get());
134 [engine setViewController:nil];
135 OCMVerify([mockEngine notifyLowMemory]);
136 OCMReject([mockEngine notifyLowMemory]);
138 XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
139 initWithName:UIApplicationDidReceiveMemoryWarningNotification];
140 [[NSNotificationCenter defaultCenter]
141 postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
143 [
self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
144 OCMVerify([mockEngine notifyLowMemory]);
145 OCMReject([mockEngine notifyLowMemory]);
147 XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
148 initWithName:UIApplicationDidEnterBackgroundNotification];
149 [[NSNotificationCenter defaultCenter]
150 postNotificationName:UIApplicationDidEnterBackgroundNotification
152 [
self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];
154 OCMVerify([mockEngine notifyLowMemory]);