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 OnPlatformViewSendViewFocusEvent(
const ViewFocusEvent& event)
override {}
32 void OnPlatformViewSetNextFrameCallback(
const fml::closure& closure)
override {}
33 void OnPlatformViewSetViewportMetrics(int64_t view_id,
const ViewportMetrics& metrics)
override {}
34 const flutter::Settings& OnPlatformViewGetSettings()
const override {
return settings_; }
35 void OnPlatformViewDispatchPlatformMessage(std::unique_ptr<PlatformMessage> message)
override {}
36 void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr<PointerDataPacket> packet)
override {
38 void OnPlatformViewDispatchSemanticsAction(int64_t view_id,
40 SemanticsAction action,
41 fml::MallocMapping args)
override {}
42 void OnPlatformViewSetSemanticsEnabled(
bool enabled)
override {}
43 void OnPlatformViewSetAccessibilityFeatures(int32_t flags)
override {}
44 void OnPlatformViewRegisterTexture(std::shared_ptr<Texture> texture)
override {}
45 void OnPlatformViewUnregisterTexture(int64_t
texture_id)
override {}
46 void OnPlatformViewMarkTextureFrameAvailable(int64_t
texture_id)
override {}
48 void LoadDartDeferredLibrary(intptr_t loading_unit_id,
49 std::unique_ptr<const fml::Mapping> snapshot_data,
50 std::unique_ptr<const fml::Mapping> snapshot_instructions)
override {
52 void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
53 const std::string error_message,
54 bool transient)
override {}
55 void UpdateAssetResolverByType(std::unique_ptr<AssetResolver> updated_asset_resolver,
56 AssetResolver::AssetResolverType type)
override {}
69 std::unique_ptr<fml::WeakPtrFactory<flutter::PlatformView>>
weak_factory;
73 fml::MessageLoop::EnsureInitializedForCurrentThread();
74 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
75 auto sync_switch = std::make_shared<fml::SyncSwitch>();
76 flutter::TaskRunners runners(
self.name.UTF8String,
98 - (
fml::WeakPtr<flutter::PlatformView>)platformViewReplacement {
102 - (void)testCallsNotifyLowMemory {
105 id mockEngine = OCMPartialMock(
engine);
106 OCMStub([mockEngine notifyLowMemory]);
107 OCMStub([mockEngine platformView]).andReturn(
platform_view.get());
109 [engine setViewController:nil];
110 OCMVerify([mockEngine notifyLowMemory]);
111 OCMReject([mockEngine notifyLowMemory]);
113 XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
114 initWithName:UIApplicationDidReceiveMemoryWarningNotification];
115 [[NSNotificationCenter defaultCenter]
116 postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
118 [
self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
119 OCMVerify([mockEngine notifyLowMemory]);
120 OCMReject([mockEngine notifyLowMemory]);
122 XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
123 initWithName:UIApplicationDidEnterBackgroundNotification];
124 [[NSNotificationCenter defaultCenter]
125 postNotificationName:UIApplicationDidEnterBackgroundNotification
127 [
self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];
129 OCMVerify([mockEngine notifyLowMemory]);