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 OnPlatformViewAddView(int64_t view_id,
27 const ViewportMetrics& viewport_metrics,
28 AddViewCallback callback)
override {}
29 void OnPlatformViewRemoveView(int64_t view_id, RemoveViewCallback callback)
override {}
30 void OnPlatformViewSetNextFrameCallback(
const fml::closure& closure)
override {}
31 void OnPlatformViewSetViewportMetrics(int64_t view_id,
const ViewportMetrics& metrics)
override {}
32 const flutter::Settings& OnPlatformViewGetSettings()
const override {
return settings_; }
33 void OnPlatformViewDispatchPlatformMessage(std::unique_ptr<PlatformMessage> message)
override {}
34 void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr<PointerDataPacket> packet)
override {
36 void OnPlatformViewDispatchSemanticsAction(int32_t
id,
37 SemanticsAction action,
38 fml::MallocMapping args)
override {}
39 void OnPlatformViewSetSemanticsEnabled(
bool enabled)
override {}
40 void OnPlatformViewSetAccessibilityFeatures(int32_t flags)
override {}
41 void OnPlatformViewRegisterTexture(std::shared_ptr<Texture> texture)
override {}
42 void OnPlatformViewUnregisterTexture(int64_t
texture_id)
override {}
43 void OnPlatformViewMarkTextureFrameAvailable(int64_t
texture_id)
override {}
45 void LoadDartDeferredLibrary(intptr_t loading_unit_id,
46 std::unique_ptr<const fml::Mapping> snapshot_data,
47 std::unique_ptr<const fml::Mapping> snapshot_instructions)
override {
49 void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
50 const std::string error_message,
51 bool transient)
override {}
52 void UpdateAssetResolverByType(std::unique_ptr<AssetResolver> updated_asset_resolver,
53 AssetResolver::AssetResolverType type)
override {}
66 std::unique_ptr<fml::WeakPtrFactory<flutter::PlatformView>>
weak_factory;
70 fml::MessageLoop::EnsureInitializedForCurrentThread();
71 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
72 auto sync_switch = std::make_shared<fml::SyncSwitch>();
73 flutter::TaskRunners runners(
self.name.UTF8String,
95 - (fml::WeakPtr<flutter::PlatformView>)platformViewReplacement {
99 - (void)testCallsNotifyLowMemory {
102 id mockEngine = OCMPartialMock(
engine);
103 OCMStub([mockEngine notifyLowMemory]);
104 OCMStub([mockEngine iosPlatformView]).andReturn(
platform_view.get());
106 [engine setViewController:nil];
107 OCMVerify([mockEngine notifyLowMemory]);
108 OCMReject([mockEngine notifyLowMemory]);
110 XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
111 initWithName:UIApplicationDidReceiveMemoryWarningNotification];
112 [[NSNotificationCenter defaultCenter]
113 postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
115 [
self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
116 OCMVerify([mockEngine notifyLowMemory]);
117 OCMReject([mockEngine notifyLowMemory]);
119 XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
120 initWithName:UIApplicationDidEnterBackgroundNotification];
121 [[NSNotificationCenter defaultCenter]
122 postNotificationName:UIApplicationDidEnterBackgroundNotification
124 [
self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];
126 OCMVerify([mockEngine notifyLowMemory]);