Skip to content
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

Migrate more tests to null safety #67360

Merged
merged 7 commits into from Oct 6, 2020

Conversation

@goderbauer
Copy link
Member

@goderbauer goderbauer commented Oct 5, 2020

@goderbauer goderbauer requested a review from dnfield Oct 5, 2020
@goderbauer goderbauer changed the title Moretestmigration Migrate more tests to null safety Oct 5, 2020
@goderbauer goderbauer force-pushed the goderbauer:moretestmigration branch Oct 5, 2020
packages/flutter/test/painting/image_provider_and_image_cache_test.dart Outdated
expect(imageCache.statusForKey(provider).untracked, true);
expect(imageCache.pendingImageCount, 0);
expect(imageCache!.statusForKey(provider).untracked, true);
expect(imageCache!.pendingImageCount, 0);

This comment has been minimized.

@goderbauer

goderbauer Oct 5, 2020
Author Member

This expect is failing:

package:test_api                                             expect
package:flutter_test/src/widget_tester.dart 429:3            expect
test/painting/image_provider_and_image_cache_test.dart 80:5  main.<fn>

Expected: <0>
  Actual: <1>

I doesn't make sense to me why migrating this to NNBD would cause that... /cc @dnfield any idea?

This comment has been minimized.

@dnfield

dnfield Oct 5, 2020
Member

Why are we changing the completer from Completer<StateError> to Completer<void>?I don't see how that would cause this problem but it seems strange to me.

This comment has been minimized.

@goderbauer

goderbauer Oct 6, 2020
Author Member

I think I got it, this test case was supposed to test this error case here:

// `key.bundle.load` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (data == null) { // ignore: dead_code
PaintingBinding.instance!.imageCache!.evict(key);
throw StateError('Unable to read data');
}

However, as the comment there says, with null-safety enabled, that error cannot happen anymore. Therefore deleting this test case.

}, skip: isBrowser); // https://github.com/flutter/flutter/issues/56314

test('AssetImageProvider - evicts on null load', () async {

This comment has been minimized.

@goderbauer

goderbauer Oct 6, 2020
Author Member

Deleting as explained here: #67360 (comment)

final RadialGradient actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);

expect(actual.focal, isNull);
final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);

This comment has been minimized.

@dnfield

dnfield Oct 6, 2020
Member

nit: why not use ! and leave the null check as is?

This comment has been minimized.

@goderbauer

goderbauer Oct 6, 2020
Author Member

either works :)

expect(imageCache.statusForKey(testImage).live, true);
expect(imageCache.statusForKey(testImage).keepAlive, false);
expect(imageCache.currentSizeBytes, 0);
imageCache!.putIfAbsent(testImage, () => completer1);

This comment has been minimized.

@dnfield

dnfield Oct 6, 2020
Member

Not for this PR, but all of this is making me think we should just be making the imageCache late non-nullable somehow.

@dnfield
dnfield approved these changes Oct 6, 2020
Copy link
Member

@dnfield dnfield left a comment

LGTM

@goderbauer goderbauer force-pushed the goderbauer:moretestmigration branch to b9feb2a Oct 6, 2020
@fluttergithubbot fluttergithubbot merged commit b3bd9e6 into flutter:master Oct 6, 2020
33 checks passed
33 checks passed
@flutter-github-sync
Google testing Google testing passed!
Details
@flutter-dashboard
Linux analyze
Details
@flutter-dashboard
Linux build_tests
Details
@flutter-dashboard
Linux customer_testing
Details
@flutter-dashboard
Linux docs
Details
@flutter-dashboard
Linux firebase_abstract_method_smoke_test
Details
@flutter-dashboard
Linux firebase_android_embedding_v2_smoke_test
Details
@flutter-dashboard
Linux firebase_release_smoke_test
Details
@flutter-dashboard
Linux framework_tests
Details
@flutter-dashboard
Linux fuchsia_precache
Details
@flutter-dashboard
Linux gradle_r8_test
Details
@flutter-dashboard
Linux web_integration_tests
Details
@flutter-dashboard
Linux web_smoke_test
Details
@flutter-dashboard
Linux web_tests
Details
@flutter-dashboard
Mac customer_testing
Details
@flutter-dashboard
Mac framework_tests
Details
@wip
WIP Ready for review
Details
@flutter-dashboard
Windows customer_testing
Details
@flutter-dashboard
Windows framework_tests
Details
@flutter-dashboard
Windows tool_tests
Details
@cirrus-ci
analyze-linux Task Summary
Details
@googlebot
cla/google All necessary CLAs are signed
@cirrus-ci
customer_testing-linux Task Summary
Details
@cirrus-ci
deploy_gallery-linux Task Summary
Details
@cirrus-ci
deploy_gallery-macos Task Summary
Details
@cirrus-ci
docs-linux Task Summary
Details
@flutter-dashboard
flutter-build
Details
@flutter-dashboard
flutter-gold All golden file tests have passed.
Details
@cirrus-ci
framework_tests-libraries-linux Task Summary
Details
@cirrus-ci
framework_tests-misc-linux Task Summary
Details
@cirrus-ci
framework_tests-widgets-linux Task Summary
Details
@cirrus-ci
web_integration_tests Task Summary
Details
@cirrus-ci
web_smoke_test Task Summary
Details
@goderbauer goderbauer deleted the goderbauer:moretestmigration branch Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants