Flush UserSettings to window (#6850)

This commit is contained in:
Dan Field 2018-11-13 23:41:56 -08:00 committed by GitHub
parent 1e7e676e4d
commit 396402f5bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -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']);
}

View File

@ -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) {

View File

@ -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;