6 #define FML_USED_ON_EMBEDDER
8 #import <OCMock/OCMock.h>
9 #import <XCTest/XCTest.h>
11 #include "flutter/fml/message_loop.h"
24 void OnPlatformViewCreated(std::unique_ptr<Surface> surface)
override {}
25 void OnPlatformViewDestroyed()
override {}
26 void OnPlatformViewScheduleFrame()
override {}
27 void OnPlatformViewAddView(int64_t view_id,
28 const ViewportMetrics& viewport_metrics,
29 AddViewCallback callback)
override {}
30 void OnPlatformViewRemoveView(int64_t view_id, RemoveViewCallback callback)
override {}
31 void OnPlatformViewSetNextFrameCallback(
const fml::closure& closure)
override {}
32 void OnPlatformViewSetViewportMetrics(int64_t view_id,
const ViewportMetrics& metrics)
override {}
33 const flutter::Settings& OnPlatformViewGetSettings()
const override {
return settings_; }
34 void OnPlatformViewDispatchPlatformMessage(std::unique_ptr<PlatformMessage> message)
override {}
35 void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr<PointerDataPacket> packet)
override {
37 void OnPlatformViewDispatchSemanticsAction(int32_t
id,
38 SemanticsAction action,
39 fml::MallocMapping args)
override {}
40 void OnPlatformViewSetSemanticsEnabled(
bool enabled)
override {}
41 void OnPlatformViewSetAccessibilityFeatures(int32_t flags)
override {}
42 void OnPlatformViewRegisterTexture(std::shared_ptr<Texture> texture)
override {}
43 void OnPlatformViewUnregisterTexture(int64_t
texture_id)
override {}
44 void OnPlatformViewMarkTextureFrameAvailable(int64_t
texture_id)
override {}
46 void LoadDartDeferredLibrary(intptr_t loading_unit_id,
47 std::unique_ptr<const fml::Mapping> snapshot_data,
48 std::unique_ptr<const fml::Mapping> snapshot_instructions)
override {
50 void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
51 const std::string error_message,
52 bool transient)
override {}
53 void UpdateAssetResolverByType(std::unique_ptr<AssetResolver> updated_asset_resolver,
54 AssetResolver::AssetResolverType type)
override {}
67 std::unique_ptr<fml::WeakPtrFactory<flutter::PlatformView>>
weak_factory;
71 fml::MessageLoop::EnsureInitializedForCurrentThread();
72 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
73 auto sync_switch = std::make_shared<fml::SyncSwitch>();
74 flutter::TaskRunners runners(
self.name.UTF8String,
96 - (
fml::WeakPtr<flutter::PlatformView>)platformViewReplacement {
100 - (void)testCallsNotifyLowMemory {
103 id mockEngine = OCMPartialMock(
engine);
104 OCMStub([mockEngine notifyLowMemory]);
105 OCMStub([mockEngine platformView]).andReturn(
platform_view.get());
107 [engine setViewController:nil];
108 OCMVerify([mockEngine notifyLowMemory]);
109 OCMReject([mockEngine notifyLowMemory]);
111 XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
112 initWithName:UIApplicationDidReceiveMemoryWarningNotification];
113 [[NSNotificationCenter defaultCenter]
114 postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
116 [
self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
117 OCMVerify([mockEngine notifyLowMemory]);
118 OCMReject([mockEngine notifyLowMemory]);
120 XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
121 initWithName:UIApplicationDidEnterBackgroundNotification];
122 [[NSNotificationCenter defaultCenter]
123 postNotificationName:UIApplicationDidEnterBackgroundNotification
125 [
self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];
127 OCMVerify([mockEngine notifyLowMemory]);