Unverified Commit 762c8699 authored by Devon Carew's avatar Devon Carew Committed by GitHub

expose the debugProfileBuildsEnabled flag as a service extension (#21492)

* expose the debugProfileBuildsEnabled flag as a service extension

* fix tests

* review comments

* remove a new keyword

* test fixes

* review comments
parent 989cf18b
......@@ -14,6 +14,7 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'app.dart';
import 'debug.dart';
import 'focus_manager.dart';
import 'framework.dart';
import 'widget_inspector.dart';
......@@ -268,7 +269,10 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture
registerSignalServiceExtension(
name: 'debugDumpApp',
callback: () { debugDumpApp(); return debugPrintDone; }
callback: () {
debugDumpApp();
return debugPrintDone;
}
);
registerBoolServiceExtension(
......@@ -293,6 +297,19 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture
}
);
assert(() {
// Expose the ability to send Widget rebuilds as [Timeline] events.
registerBoolServiceExtension(
name: 'profileWidgetBuilds',
getter: () async => debugProfileBuildsEnabled,
setter: (bool value) async {
if (debugProfileBuildsEnabled != value)
debugProfileBuildsEnabled = value;
}
);
return true;
}());
// This service extension is deprecated and will be removed by 7/1/2018.
// Use ext.flutter.inspector.show instead.
registerBoolServiceExtension(
......
......@@ -298,6 +298,35 @@ void main() {
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - profileWidgetBuilds', () async {
Map<String, dynamic> result;
expect(binding.frameScheduled, isFalse);
expect(debugProfileBuildsEnabled, false);
result = await binding.testExtension('profileWidgetBuilds', <String, String>{});
expect(result, <String, String>{ 'enabled': 'false' });
expect(debugProfileBuildsEnabled, false);
result = await binding.testExtension('profileWidgetBuilds', <String, String>{ 'enabled': 'true' });
expect(result, <String, String>{ 'enabled': 'true' });
expect(debugProfileBuildsEnabled, true);
result = await binding.testExtension('profileWidgetBuilds', <String, String>{});
expect(result, <String, String>{ 'enabled': 'true' });
expect(debugProfileBuildsEnabled, true);
result = await binding.testExtension('profileWidgetBuilds', <String, String>{ 'enabled': 'false' });
expect(result, <String, String>{ 'enabled': 'false' });
expect(debugProfileBuildsEnabled, false);
result = await binding.testExtension('profileWidgetBuilds', <String, String>{});
expect(result, <String, String>{ 'enabled': 'false' });
expect(debugProfileBuildsEnabled, false);
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - evict', () async {
Map<String, dynamic> result;
bool completed;
......@@ -512,7 +541,7 @@ void main() {
// If you add a service extension... TEST IT! :-)
// ...then increment this number.
expect(binding.extensions.length, 38);
expect(binding.extensions.length, 39);
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