Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e8632a1

Browse files
committed
Re-add tests deleted on accident
1 parent a718337 commit e8632a1

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,57 @@ + (void)registerWithRegistrar:(id<FlutterPluginRegistrar>)registrar {
10971097
[NSApplication sharedApplication].delegate = previousDelegate;
10981098
}
10991099

1100+
TEST_F(FlutterEngineTest, RunWithEntrypointUpdatesDisplayConfig) {
1101+
BOOL updated = NO;
1102+
FlutterEngine* engine = GetFlutterEngine();
1103+
auto original_update_displays = engine.embedderAPI.NotifyDisplayUpdate;
1104+
engine.embedderAPI.NotifyDisplayUpdate = MOCK_ENGINE_PROC(
1105+
NotifyDisplayUpdate, ([&updated, &original_update_displays](
1106+
auto engine, auto update_type, auto* displays, auto display_count) {
1107+
updated = YES;
1108+
return original_update_displays(engine, update_type, displays, display_count);
1109+
}));
1110+
1111+
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1112+
EXPECT_TRUE(updated);
1113+
1114+
updated = NO;
1115+
[[NSNotificationCenter defaultCenter]
1116+
postNotificationName:NSApplicationDidChangeScreenParametersNotification
1117+
object:nil];
1118+
EXPECT_TRUE(updated);
1119+
}
1120+
1121+
TEST_F(FlutterEngineTest, NotificationsUpdateDisplays) {
1122+
BOOL updated = NO;
1123+
FlutterEngine* engine = GetFlutterEngine();
1124+
auto original_set_viewport_metrics = engine.embedderAPI.SendWindowMetricsEvent;
1125+
engine.embedderAPI.SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1126+
SendWindowMetricsEvent,
1127+
([&updated, &original_set_viewport_metrics](auto engine, auto* window_metrics) {
1128+
updated = YES;
1129+
return original_set_viewport_metrics(engine, window_metrics);
1130+
}));
1131+
1132+
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1133+
1134+
updated = NO;
1135+
[[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1136+
object:nil];
1137+
// No VC.
1138+
EXPECT_FALSE(updated);
1139+
1140+
FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
1141+
nibName:nil
1142+
bundle:nil];
1143+
[viewController loadView];
1144+
viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
1145+
1146+
[[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1147+
object:nil];
1148+
EXPECT_TRUE(updated);
1149+
}
1150+
11001151
} // namespace flutter::testing
11011152

11021153
// NOLINTEND(clang-analyzer-core.StackAddressEscape)

0 commit comments

Comments
 (0)