Unverified Commit 4af67428 authored by Dan Field's avatar Dan Field Committed by GitHub

Move service extension to correct binding so images are repainted after...

Move service extension to correct binding so images are repainted after enabling/disabling, update test (#68793)

* Move service extension to correct binding so images are repainted after enabling/disabling, update test

* Update binding.dart
parent 37042fdb
......@@ -59,6 +59,17 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
assert(() {
// these service extensions only work in debug mode
registerBoolServiceExtension(
name: 'invertOversizedImages',
getter: () async => debugInvertOversizedImages,
setter: (bool value) async {
if (debugInvertOversizedImages != value) {
debugInvertOversizedImages = value;
return _forceRepaint();
}
return Future<void>.value();
},
);
registerBoolServiceExtension(
name: 'debugPaint',
getter: () async => debugPaintSizeEnabled,
......
......@@ -460,18 +460,6 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
}
assert(() {
registerBoolServiceExtension(
name: 'invertOversizedImages',
getter: () async => debugInvertOversizedImages,
setter: (bool value) async {
if (debugInvertOversizedImages != value) {
debugInvertOversizedImages = value;
return _forceRebuild();
}
return Future<void>.value();
},
);
registerBoolServiceExtension(
name: 'debugAllowBanner',
getter: () => Future<bool>.value(WidgetsApp.debugAllowBannerOverride),
......
......@@ -399,21 +399,44 @@ void main() {
test('Service extensions - invertOversizedImages', () async {
Map<String, dynamic> result;
Future<Map<String, dynamic>> pendingResult;
bool completed;
expect(binding.frameScheduled, isFalse);
expect(debugInvertOversizedImages, false);
result = await binding.testExtension('invertOversizedImages', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugInvertOversizedImages, false);
result = await binding.testExtension('invertOversizedImages', <String, String>{'enabled': 'true'});
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('invertOversizedImages', <String, String>{'enabled': 'true'});
completed = false;
pendingResult.whenComplete(() { completed = true; });
await binding.flushMicrotasks();
expect(binding.frameScheduled, isTrue);
expect(completed, isFalse);
await binding.doFrame();
await binding.flushMicrotasks();
expect(completed, isTrue);
expect(binding.frameScheduled, isFalse);
result = await pendingResult;
expect(result, <String, String>{'enabled': 'true'});
expect(debugInvertOversizedImages, true);
result = await binding.testExtension('invertOversizedImages', <String, String>{});
expect(result, <String, String>{'enabled': 'true'});
expect(debugInvertOversizedImages, true);
result = await binding.testExtension('invertOversizedImages', <String, String>{'enabled': 'false'});
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('invertOversizedImages', <String, String>{'enabled': 'false'});
await binding.flushMicrotasks();
expect(binding.frameScheduled, isTrue);
await binding.doFrame();
expect(binding.frameScheduled, isFalse);
result = await pendingResult;
expect(result, <String, String>{'enabled': 'false'});
expect(debugInvertOversizedImages, false);
result = await binding.testExtension('invertOversizedImages', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugInvertOversizedImages, false);
......
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