Unverified Commit 52e5cd24 authored by Kenzie Schmoll's avatar Kenzie Schmoll Committed by GitHub

Add didSendFirstFrameEvent service extension. (#25977)

* Add didSendFirstFrameEvent service extension.
parent 71be92e6
......@@ -289,6 +289,15 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB
return _forceRebuild();
},
);
registerServiceExtension(
name: 'didSendFirstFrameEvent',
callback: (_) async {
return <String, dynamic>{
'enabled': _needToReportFirstFrame ? 'false' : 'true'
};
},
);
}
assert(() {
......
......@@ -104,7 +104,20 @@ void main() {
test('Service extensions - pretest', () async {
binding = TestServiceExtensionsBinding();
expect(binding.frameScheduled, isTrue);
// We need to test this service extension here because the result is true
// after the first binding.doFrame() call.
Map<String, dynamic> firstFrameResult;
expect(binding.debugDidSendFirstFrameEvent, isFalse);
firstFrameResult = await binding.testExtension('didSendFirstFrameEvent', <String, String>{});
expect(firstFrameResult, <String, String>{ 'enabled': 'false' });
await binding.doFrame(); // initial frame scheduled by creating the binding
expect(binding.debugDidSendFirstFrameEvent, isTrue);
firstFrameResult = await binding.testExtension('didSendFirstFrameEvent', <String, String>{});
expect(firstFrameResult, <String, String>{ 'enabled': 'true' });
expect(binding.frameScheduled, isFalse);
expect(debugPrint, equals(debugPrintThrottled));
......@@ -548,7 +561,7 @@ void main() {
// If you add a service extension... TEST IT! :-)
// ...then increment this number.
expect(binding.extensions.length, 24 + widgetInspectorExtensionCount);
expect(binding.extensions.length, 25 + widgetInspectorExtensionCount);
expect(console, isEmpty);
debugPrint = debugPrintThrottled;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment