Skip to content

Add native iOS screenshots to integration_test#84611

Merged
fluttergithubbot merged 3 commits into
flutter:masterfrom
jmagman:integration-test-screenshot
Aug 6, 2021
Merged

Add native iOS screenshots to integration_test#84611
fluttergithubbot merged 3 commits into
flutter:masterfrom
jmagman:integration-test-screenshot

Conversation

@jmagman

@jmagman jmagman commented Jun 15, 2021

Copy link
Copy Markdown
Member

Implement the native iOS screenshot side of #84472. Added an optional "name" argument for the "captureScreenshot" method.

When run as a native Xcode test, the screenshots are saved to the Xcode test results bundle in addition to the bytes being passed back over the channel.
Screen Shot 2021-07-22 at 4 32 46 PM

Screenshot is the app window, not including the status bar, etc.
public png_1_7EACEC54-4CF2-42E1-A6B3-D203D265DD1E

iOS screenshot prototype of #83856

@jmagman jmagman added platform-ios iOS applications specifically f: integration_test The flutter/packages/integration_test plugin labels Jun 15, 2021
@flutter-dashboard flutter-dashboard Bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Jun 15, 2021
@google-cla google-cla Bot added the cla: yes label Jun 15, 2021
Comment thread packages/integration_test/lib/integration_test.dart Outdated
@jmagman
jmagman force-pushed the integration-test-screenshot branch 2 times, most recently from a80d1ed to bc4d3b8 Compare July 22, 2021 23:35

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should have been checked in before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Remove unnecessary build setting overrides. I can do this in a separate PR, if you prefer.

@jmagman
jmagman marked this pull request as ready for review July 22, 2021 23:37
@flutter-dashboard

Copy link
Copy Markdown

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.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

@stuartmorgan-g stuartmorgan-g left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with nits. Shouldn't we have a test of this functionality that screenshots a dummy plugin and compares it to a golden image though?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we get a comment on this weird API describing its behavior while you are touching it? (Or even better, could we make this an idiomatic ObjC method that returns either an NSString or nil?)

@jmagman jmagman Aug 5, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This API is very weird (I just added the nullability), and the INTEGRATION_TEST_IOS_RUNNER macro is downright Swift-hostile...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like we're not running clang-format in this directory on CI? This is way over the 100 char style guide length limit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think there are any formatters (even dartfmt) running on flutter/flutter (plus I hate how clang formatter mangles Obj-C blocks). Let me shorten these up.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This sounds to me like using an image is Android-only, but the logic below is the reverse.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@blasten What does Whether the Flutter surface uses an Image mean in this context? I think that the surface is frozen, the screenshot taken, and then it's unfrozen on Android?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the above !_usesFlutterImage if statement could also check if Platform.isAndroid

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it would need to noop if !Platform.isAndroid

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I meant to make it so it was never set to false on !Platform.isAndroid, let me clean this up.

@blasten blasten left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM % nits

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM with nits. Shouldn't we have a test of this functionality that screenshots a dummy plugin and compares it to a golden image though?

I think the next step for @blasten after I commit this was to set up the screenshot integration tests. But I should also write some iOS native tests.

@jmagman jmagman Aug 5, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This API is very weird (I just added the nullability), and the INTEGRATION_TEST_IOS_RUNNER macro is downright Swift-hostile...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think there are any formatters (even dartfmt) running on flutter/flutter (plus I hate how clang formatter mangles Obj-C blocks). Let me shorten these up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I meant to make it so it was never set to false on !Platform.isAndroid, let me clean this up.

@jmagman

jmagman commented Aug 6, 2021

Copy link
Copy Markdown
Member Author

LGTM with nits. Shouldn't we have a test of this functionality that screenshots a dummy plugin and compares it to a golden image though?

There will be some test harness work needed for the native side. Filed #87770.

We'll get some unit tests for this going soon.

@blasten

blasten commented Aug 6, 2021

Copy link
Copy Markdown

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. f: integration_test The flutter/packages/integration_test plugin platform-ios iOS applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants