Unverified Commit 26d1da41 authored by Lau Ching Jun's avatar Lau Ching Jun Committed by GitHub

Fix error in type cast. (#97778)

parent 1fcb076e
......@@ -980,7 +980,7 @@ class DebuggingOptions {
debuggingEnabled: (json['debuggingEnabled'] as bool?)!,
startPaused: (json['startPaused'] as bool?)!,
dartFlags: (json['dartFlags'] as String?)!,
dartEntrypointArgs: ((json['dartEntrypointArgs'] as List<String>?)?.cast<String>())!,
dartEntrypointArgs: ((json['dartEntrypointArgs'] as List<dynamic>?)?.cast<String>())!,
disableServiceAuthCodes: (json['disableServiceAuthCodes'] as bool?)!,
enableDds: (json['enableDds'] as bool?)!,
enableSoftwareRendering: (json['enableSoftwareRendering'] as bool?)!,
......
......@@ -9,7 +9,9 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:test/fake.dart';
......@@ -508,6 +510,29 @@ void main() {
expect(computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug, nullAssertions: true)), '--null_assertions');
expect(computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug, dartFlags: '--foo', nullAssertions: true)), '--foo,--null_assertions');
});
group('JSON encode DebuggingOptions', () {
testWithoutContext('can preserve the original options', () {
final DebuggingOptions original = DebuggingOptions.enabled(
BuildInfo.debug,
startPaused: true,
disableServiceAuthCodes: true,
enableDds: false,
dartEntrypointArgs: <String>['a', 'b'],
dartFlags: 'c',
deviceVmServicePort: 1234,
);
final String jsonString = json.encode(original.toJson());
final Map<String, dynamic> decoded = castStringKeyedMap(json.decode(jsonString))!;
final DebuggingOptions deserialized = DebuggingOptions.fromJson(decoded, BuildInfo.debug);
expect(deserialized.startPaused, original.startPaused);
expect(deserialized.disableServiceAuthCodes, original.disableServiceAuthCodes);
expect(deserialized.enableDds, original.enableDds);
expect(deserialized.dartEntrypointArgs, original.dartEntrypointArgs);
expect(deserialized.dartFlags, original.dartFlags);
expect(deserialized.deviceVmServicePort, original.deviceVmServicePort);
});
});
}
class TestDeviceManager extends DeviceManager {
......
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