Skip to content

Migrate asset_handler_test to null-safety #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 4, 2022

Conversation

elliette
Copy link
Contributor

@elliette elliette commented Aug 2, 2022

No description provided.

@elliette elliette changed the title Trying to fix asset_handler test Migrate asset_handler_test to null-safety Aug 4, 2022
@elliette elliette marked this pull request as ready for review August 4, 2022 00:22
@elliette elliette requested a review from annagrin August 4, 2022 00:23
Copy link
Contributor

@annagrin annagrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Elliott! LGTM with a couple of questions an an optional ask.

await tabConnection.runtime.enable();
await tabConnection.debugger.enable();
final tab = await connection.getTab((t) => t.url == appUrl);
if (tab != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should throw if tab is not found, the tests won't run properly in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done!

@@ -55,7 +55,7 @@ class DwdsVmClient {
'$request');
return;
}
requestController.sink.add(jsonDecode(request) as Map<String, Object>);
requestController.sink.add(Map<String, Object>.from(jsonDecode(request)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it is necessary to create a new object here (possible performance hit?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of another way - jsonDecode returns dynamic, so using as to cast is throwing a type error (as should only be used "if and only if you are sure that the object is of that type": https://dart.dev/guides/language/language-tour#type-test-operators)

@@ -53,7 +53,7 @@ void Function(WebSocketChannel, String) _createNewConnectionHandler(
'Got value with unexpected type ${value.runtimeType} from web '
'socket, expected a List<int> or String.');
}
final request = jsonDecode(value as String) as Map<String, Object>;
final request = Map<String, Object>.from(jsonDecode(value));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the new object necessary here as well?

@elliette elliette merged commit 490d6a0 into dart-lang:master Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants