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,
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 flutter::TaskRunners runners(
self.name.UTF8String,
88 - (fml::WeakPtr<flutter::PlatformView>)platformViewReplacement {
92 - (void)testMsaaSampleCount {
94 XCTAssertEqual(
platform_view->GetIosContext()->GetMsaaSampleCount(), MsaaSampleCount::kNone);
100 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
101 flutter::TaskRunners runners(
self.name.UTF8String,
106 auto msaa_4x_platform_view = std::make_unique<flutter::PlatformViewIOS>(
114 XCTAssertEqual(msaa_4x_platform_view->GetIosContext()->GetMsaaSampleCount(),
115 MsaaSampleCount::kFour);
118 - (void)testCallsNotifyLowMemory {
121 id mockEngine = OCMPartialMock(
engine);
122 OCMStub([mockEngine notifyLowMemory]);
123 OCMStub([mockEngine iosPlatformView]).andReturn(
platform_view.get());
125 [engine setViewController:nil];
126 OCMVerify([mockEngine notifyLowMemory]);
127 OCMReject([mockEngine notifyLowMemory]);
129 XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
130 initWithName:UIApplicationDidReceiveMemoryWarningNotification];
131 [[NSNotificationCenter defaultCenter]
132 postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
134 [
self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
135 OCMVerify([mockEngine notifyLowMemory]);
136 OCMReject([mockEngine notifyLowMemory]);
138 XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
139 initWithName:UIApplicationDidEnterBackgroundNotification];
140 [[NSNotificationCenter defaultCenter]
141 postNotificationName:UIApplicationDidEnterBackgroundNotification
143 [
self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];
145 OCMVerify([mockEngine notifyLowMemory]);