Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | List of all members
FlutterEnginePlatformViewTest Class Reference
Inheritance diagram for FlutterEnginePlatformViewTest:

Instance Methods

(void) - setUp [implementation]
 
(void) - tearDown [implementation]
 
(fml::WeakPtr< flutter::PlatformView >) - platformViewReplacement [implementation]
 
(void) - testMsaaSampleCount [implementation]
 
(void) - testCallsNotifyLowMemory [implementation]
 

Detailed Description

Definition at line 61 of file FlutterEnginePlatformViewTest.mm.

Method Documentation

◆ platformViewReplacement

- (WeakPtr<) flutter:
implementation

Definition at line 67 of file FlutterEnginePlatformViewTest.mm.

95 {
96 return weak_factory->GetWeakPtr();
97}
std::unique_ptr< fml::WeakPtrFactory< flutter::PlatformView > > weak_factory

◆ setUp

- (void) setUp
implementation

Definition at line 67 of file FlutterEnginePlatformViewTest.mm.

69 {
71 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
72 auto sync_switch = std::make_shared<fml::SyncSwitch>();
73 flutter::TaskRunners runners(/*label=*/self.name.UTF8String,
74 /*platform=*/thread_task_runner,
75 /*raster=*/thread_task_runner,
76 /*ui=*/thread_task_runner,
77 /*io=*/thread_task_runner);
78 platform_view = std::make_unique<flutter::PlatformViewIOS>(
79 /*delegate=*/fake_delegate,
80 /*rendering_api=*/fake_delegate.settings_.enable_impeller
83 /*platform_views_controller=*/nil,
84 /*task_runners=*/runners,
85 /*worker_task_runner=*/nil,
86 /*is_gpu_disabled_sync_switch=*/sync_switch);
87 weak_factory = std::make_unique<fml::WeakPtrFactory<flutter::PlatformView>>(platform_view.get());
88}
flutter::FakeDelegate fake_delegate
std::unique_ptr< flutter::PlatformViewIOS > platform_view
static void EnsureInitializedForCurrentThread()
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
@ kSoftware
Definition embedder.h:81
const char * name
Definition fuchsia.cc:50

◆ tearDown

- (void) tearDown
implementation

Definition at line 67 of file FlutterEnginePlatformViewTest.mm.

90 {
91 weak_factory.reset();
92 platform_view.reset();
93}

◆ testCallsNotifyLowMemory

- (void) testCallsNotifyLowMemory
implementation

Definition at line 67 of file FlutterEnginePlatformViewTest.mm.

131 {
132 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"tester"];
133 XCTAssertNotNil(engine);
134 id mockEngine = OCMPartialMock(engine);
135 OCMStub([mockEngine notifyLowMemory]);
136 OCMStub([mockEngine iosPlatformView]).andReturn(platform_view.get());
137
138 [engine setViewController:nil];
139 OCMVerify([mockEngine notifyLowMemory]);
140 OCMReject([mockEngine notifyLowMemory]);
141
142 XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
143 initWithName:UIApplicationDidReceiveMemoryWarningNotification];
144 [[NSNotificationCenter defaultCenter]
145 postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
146 object:nil];
147 [self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
148 OCMVerify([mockEngine notifyLowMemory]);
149 OCMReject([mockEngine notifyLowMemory]);
150
151 XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
152 initWithName:UIApplicationDidEnterBackgroundNotification];
153 [[NSNotificationCenter defaultCenter]
154 postNotificationName:UIApplicationDidEnterBackgroundNotification
155 object:nil];
156 [self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];
157
158 OCMVerify([mockEngine notifyLowMemory]);
159}
FlutterEngine engine
Definition main.cc:68
void setViewController:(FlutterViewController *viewController)

◆ testMsaaSampleCount

- (void) testMsaaSampleCount
implementation

Definition at line 67 of file FlutterEnginePlatformViewTest.mm.

99 {
100 if (fake_delegate.settings_.enable_impeller) {
101 // Default should be 4 for Impeller.
102 XCTAssertEqual(platform_view->GetIosContext()->GetMsaaSampleCount(), MsaaSampleCount::kFour);
103 } else {
104 // Default should be 1 for Skia.
105 XCTAssertEqual(platform_view->GetIosContext()->GetMsaaSampleCount(), MsaaSampleCount::kNone);
106 }
107
108 // Verify the platform view creates a new context with updated msaa_samples.
109 // Need to use Metal, since this is ignored for Software/GL.
110 fake_delegate.settings_.msaa_samples = 4;
111
112 auto thread_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
113 auto sync_switch = std::make_shared<fml::SyncSwitch>();
114 flutter::TaskRunners runners(/*label=*/self.name.UTF8String,
115 /*platform=*/thread_task_runner,
116 /*raster=*/thread_task_runner,
117 /*ui=*/thread_task_runner,
118 /*io=*/thread_task_runner);
119 auto msaa_4x_platform_view = std::make_unique<flutter::PlatformViewIOS>(
120 /*delegate=*/fake_delegate,
121 /*rendering_api=*/flutter::IOSRenderingAPI::kMetal,
122 /*platform_views_controller=*/nil,
123 /*task_runners=*/runners,
124 /*worker_task_runner=*/nil,
125 /*is_gpu_disabled_sync_switch=*/sync_switch);
126
127 XCTAssertEqual(msaa_4x_platform_view->GetIosContext()->GetMsaaSampleCount(),
129}

The documentation for this class was generated from the following file: