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 HitTestResponse OnPlatformViewHitTest(int64_t view_id,
const flutter::PointData offset)
override {
39 return {.has_platform_view =
false};
41 void OnPlatformViewDispatchSemanticsAction(int64_t view_id,
43 SemanticsAction action,
44 fml::MallocMapping args)
override {}
45 void OnPlatformViewSetSemanticsEnabled(
bool enabled)
override {}
46 void OnPlatformViewSetAccessibilityFeatures(int32_t flags)
override {}
47 void OnPlatformViewRegisterTexture(std::shared_ptr<Texture> texture)
override {}
48 void OnPlatformViewUnregisterTexture(int64_t
texture_id)
override {}
49 void OnPlatformViewMarkTextureFrameAvailable(int64_t
texture_id)
override {}
51 void LoadDartDeferredLibrary(intptr_t loading_unit_id,
52 std::unique_ptr<const fml::Mapping> snapshot_data,
53 std::unique_ptr<const fml::Mapping> snapshot_instructions)
override {
55 void LoadDartDeferredLibraryError(intptr_t loading_unit_id,
56 const std::string error_message,
57 bool transient)
override {}
58 void UpdateAssetResolverByType(std::unique_ptr<AssetResolver> updated_asset_resolver,
59 AssetResolver::AssetResolverType type)
override {}
72 std::unique_ptr<fml::WeakPtrFactory<flutter::PlatformView>>
weak_factory;
76 fml::MessageLoop::EnsureInitializedForCurrentThread();
77 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
78 auto sync_switch = std::make_shared<fml::SyncSwitch>();
79 flutter::TaskRunners runners(
self.name.UTF8String,
101 - (
fml::WeakPtr<flutter::PlatformView>)platformViewReplacement {
105 - (void)testCallsNotifyLowMemory {
108 id mockEngine = OCMPartialMock(
engine);
109 OCMStub([mockEngine notifyLowMemory]);
110 OCMStub([mockEngine platformView]).andReturn(
platform_view.get());
112 [engine setViewController:nil];
113 OCMVerify([mockEngine notifyLowMemory]);
114 OCMReject([mockEngine notifyLowMemory]);
116 XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
117 initWithName:UIApplicationDidReceiveMemoryWarningNotification];
118 [[NSNotificationCenter defaultCenter]
119 postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
121 [
self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
122 OCMVerify([mockEngine notifyLowMemory]);
123 OCMReject([mockEngine notifyLowMemory]);
125 XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
126 initWithName:UIApplicationDidEnterBackgroundNotification];
127 [[NSNotificationCenter defaultCenter]
128 postNotificationName:UIApplicationDidEnterBackgroundNotification
130 [
self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];
132 OCMVerify([mockEngine notifyLowMemory]);