Skip to content

Conversation

renefloor
Copy link
Contributor

@renefloor renefloor commented Apr 17, 2020

With this method custom ImageStreamCompleter implementations can also send these events.
Fixes #55040

Description

As described in #55040 custom implementations of ImageStreamCompleter are currently unable to send report updates to the listeners. Only implementations within the same file are able to do so. The method is made in a very similar way as setImage and reportError.

Related Issues

Fixes issue #55040

Tests

I could use some help with this. This method is covered by existing tests in image_stream_test.dart, for example 'Chunk events are delivered'. So I'm not sure whether I need to add new tests or how they should be made. So I guess the coverage is still 100%, but maybe we need a more specific test.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

With this method custom ImageStreamCompleter implementations can also send these events.
@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Apr 17, 2020
@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

Seems reasonable. @dnfield What do you think?

}
}

/// Calls all the registered ImageChunkListeners (listeners with an
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Calls all the registered ImageChunkListeners (listeners with an
/// Calls all the registered [ImageChunkListeners] (listeners with an

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@goderbauer ImageChunkListener or ImageChunkListeners is not a class or variable or anything on it's own, so there is nothing to link to. Just like
If no error listeners (listeners with an [ImageStreamListener.onError] specified) are attached

I'll rewrite it to image chunk listeners, so it is clear that it is no class.

Copy link
Member

Choose a reason for hiding this comment

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

listener(event);
}
}
reportImageChunkEvent(event);
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to pass reportImageChunkEvent directly to listen without the need for an extra closure.

@goderbauer
Copy link
Member

This PR will also need a test.

@renefloor
Copy link
Contributor Author

@goderbauer I made an extra FakeEventReportingImageStreamCompleter to run the tests on for the event reporting and renamed the existing tests that run on the MultiFrameImageStreamCompleter implementation.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM with 2 formatting nits

);

imageStream.addListener(ImageStreamListener(
(ImageInfo image, bool synchronousCall) { },
Copy link
Member

Choose a reason for hiding this comment

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

nit formatting: put this on the same indentation as the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@goderbauer There is no formatting tool for Flutter right?

streamController.add(const ImageChunkEvent(cumulativeBytesLoaded: 1, expectedTotalBytes: 3));
await tester.idle();
imageStream.addListener(ImageStreamListener(
(ImageInfo image, bool synchronousCall) { },
Copy link
Member

Choose a reason for hiding this comment

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

same.

@dnfield
Copy link
Contributor

dnfield commented Apr 20, 2020

This seems fine to me once @goderbauer's comments are resolved

@renefloor
Copy link
Contributor Author

@dnfield and @goderbauer It can be merged now right?

@dnfield
Copy link
Contributor

dnfield commented Apr 22, 2020

Yes, thanks! I've added a label that should cause it to get merged once some unrelated infra issues are resolved.

@fluttergithubbot fluttergithubbot merged commit 0763a57 into flutter:master Apr 22, 2020
@renefloor renefloor deleted the feature/report-image-chunck branch April 22, 2020 08:08
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ImageChunkListener in ImageStream accessible like ImageErrorListener

5 participants