Re-add tests deleted on accident (flutter/engine#50223)

This re-adds the tests from https://github.com/flutter/engine/pull/41998/files that were accidentally deleted in https://github.com/flutter/engine/pull/42418/files#diff-2cce780ae0f93b9230cbf44030048dbf9ef4c6e0fdb959a47cae440fac0350faL808, probably because of a bad merge.
This commit is contained in:
Michael Goderbauer 2024-02-01 13:51:51 -08:00 committed by GitHub
parent 5d0859ada0
commit 2134c852b4

View File

@ -1097,6 +1097,57 @@ TEST_F(FlutterEngineTest, UnregistersPluginsOnEngineDestruction) {
[NSApplication sharedApplication].delegate = previousDelegate;
}
TEST_F(FlutterEngineTest, RunWithEntrypointUpdatesDisplayConfig) {
BOOL updated = NO;
FlutterEngine* engine = GetFlutterEngine();
auto original_update_displays = engine.embedderAPI.NotifyDisplayUpdate;
engine.embedderAPI.NotifyDisplayUpdate = MOCK_ENGINE_PROC(
NotifyDisplayUpdate, ([&updated, &original_update_displays](
auto engine, auto update_type, auto* displays, auto display_count) {
updated = YES;
return original_update_displays(engine, update_type, displays, display_count);
}));
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
EXPECT_TRUE(updated);
updated = NO;
[[NSNotificationCenter defaultCenter]
postNotificationName:NSApplicationDidChangeScreenParametersNotification
object:nil];
EXPECT_TRUE(updated);
}
TEST_F(FlutterEngineTest, NotificationsUpdateDisplays) {
BOOL updated = NO;
FlutterEngine* engine = GetFlutterEngine();
auto original_set_viewport_metrics = engine.embedderAPI.SendWindowMetricsEvent;
engine.embedderAPI.SendWindowMetricsEvent = MOCK_ENGINE_PROC(
SendWindowMetricsEvent,
([&updated, &original_set_viewport_metrics](auto engine, auto* window_metrics) {
updated = YES;
return original_set_viewport_metrics(engine, window_metrics);
}));
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
updated = NO;
[[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
object:nil];
// No VC.
EXPECT_FALSE(updated);
FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
nibName:nil
bundle:nil];
[viewController loadView];
viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
[[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
object:nil];
EXPECT_TRUE(updated);
}
} // namespace flutter::testing
// NOLINTEND(clang-analyzer-core.StackAddressEscape)