Skip to content

Commit

Permalink
Flush UserSettings to window (flutter#6850)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield authored Nov 14, 2018
1 parent 1e7e676 commit 396402f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ void _updateLocales(List<String> locales) {
@pragma('vm:entry-point')
void _updateUserSettingsData(String jsonData) {
final Map<String, dynamic> data = json.decode(jsonData);
if (data.isEmpty) {
return;
}
_updateTextScaleFactor(data['textScaleFactor'].toDouble());
_updateAlwaysUse24HourFormat(data['alwaysUse24HourFormat']);
}
Expand Down
3 changes: 2 additions & 1 deletion runtime/runtime_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ bool RuntimeController::FlushRuntimeStateToIsolate() {
return SetViewportMetrics(window_data_.viewport_metrics) &&
SetLocales(window_data_.locale_data) &&
SetSemanticsEnabled(window_data_.semantics_enabled) &&
SetAccessibilityFeatures(window_data_.accessibility_feature_flags_);
SetAccessibilityFeatures(window_data_.accessibility_feature_flags_) &&
SetUserSettingsData(window_data_.user_settings_data);
}

bool RuntimeController::SetViewportMetrics(const ViewportMetrics& metrics) {
Expand Down
6 changes: 6 additions & 0 deletions testing/dart/window_hooks_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void main() {
window.onTextScaleFactorChanged = originalOnTextScaleFactorChanged;
});

test('updateUserSettings can handle an empty object', () {
// this should now throw.
_updateUserSettingsData('{}');
expect(true, equals(true));
});

test('onMetricsChanged preserves callback zone', () {
Zone innerZone;
Zone runZone;
Expand Down

0 comments on commit 396402f

Please sign in to comment.