Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_sign_in] Add iOS unit tests #4157

Merged
merged 8 commits into from
Jul 20, 2021
Merged

Conversation

jmagman
Copy link
Member

@jmagman jmagman commented Jul 15, 2021

  • Add google_sign_in iOS unit tests to validate we don't break (much) in preparation for [google_sign_in] Update GoogleSignIn dependency to 6.2 flutter#86436, which included SDK removals and signature changes without deprecations. Native code plugin coverage increased from 41.4% to 78.4%.
  • Add -[FLTGoogleSignInPlugin initWithSignIn:] initializer to allow easy injection of GIDSignIn into unit tests. Expose in a new google_sign_in.Test explicit clang module. Include new modulemap and umbrella header to support this.
  • Add lightweight generics to the plugin.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@@ -25,6 +25,6 @@
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
Copy link
Member Author

Choose a reason for hiding this comment

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

Automatic from flutter/flutter#85174

@@ -539,7 +539,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
Copy link
Member Author

Choose a reason for hiding this comment

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

Automatic from flutter/flutter#85174

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Nice :)

The description says "Turn on code coverage", but I'm not seeing project changes other than deployment target.

@jmagman
Copy link
Member Author

jmagman commented Jul 15, 2021

The description says "Turn on code coverage", but I'm not seeing project changes other than deployment target.

Ah sorry I removed that in an intermediate commit since it's not being checked anywhere, so not worth the overhead in CI. Fixed the description.

@@ -0,0 +1,13 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately I had to make this a public header to make it accessible to the RunnerTest.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I should rename to FLTGoogleSignInPlugin_Test.h

Copy link
Member Author

Choose a reason for hiding this comment

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

Just renamed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be kind of ugly, but couldn't the test do a path-based include of the private header instead of getting it via the module import?

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternately, you could do the thing that I almost always tell people not to do (in favor of making an internal header like you did) and re-declare the method you need at the top of the test file. I've never liked it, but it seems better than actually making the private header public in the module.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about a Test module so it needs to be explicitly imported?

@import google_sign_in;
@import google_sign_in.Test;

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g 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 the private header thing adrressed

@@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android and iOS.
repository: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 5.0.4
version: 5.0.5
Copy link
Member Author

Choose a reason for hiding this comment

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

@stuartmorgan with the module change this seems different enough to warrant a patch bump.

@@ -12,8 +12,9 @@ Enables Google Sign-In in Flutter apps.
s.license = { :type => 'BSD', :file => '../LICENSE' }
s.author = { 'Flutter Team' => '[email protected]' }
s.source = { :http => 'https://github.com/flutter/plugins/tree/master/packages/google_sign_in' }
s.source_files = 'Classes/**/*'
s.source_files = 'Classes/**/*.{h,m}'
Copy link
Member Author

Choose a reason for hiding this comment

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

modulemap shouldn't be included in the source files.

@@ -0,0 +1,10 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member Author

Choose a reason for hiding this comment

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

The file was previously generated by CocoaPods with the same name. Now we need to manage it manually and check it into the repo because we're defining a module map, which takes us out of the magical auto module world.

export *
module * { export * }

explicit module Test {
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't a private module since there are some complications for Swift files not being able to import those.

Instead, this explicit module requires that google_sign_in.Test be imported to access FLTGoogleSignInPlugin_Test. So initWithSignIn: won't be available in the normal import google_sign_in case, won't auto-complete, etc.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM

fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
amantoux pushed a commit to amantoux/plugins that referenced this pull request Sep 27, 2021
mvanbeusekom added a commit to Baseflow/flutter-plugins that referenced this pull request Feb 2, 2022
Refactored the existing unit tests to expose private interfaces in a
separate test header instead of an inline interface. This was first
introduced in the google_sign_in plugin (flutter#4157) and after that also
applied in the camera plugin (flutter#4426) and the webview_flutter plugin
(flutter#4480).

This commit also removed several obsolete `OCMStub` declarations.
mvanbeusekom added a commit to Baseflow/flutter-plugins that referenced this pull request Feb 2, 2022
Refactored the existing unit tests to expose private interfaces in a
separate test header instead of an inline interface. This was first
introduced in the google_sign_in plugin (flutter#4157) and after that also
applied in the camera plugin (flutter#4426) and the webview_flutter plugin
(flutter#4480).

This commit also removed several obsolete `OCMStub` declarations.
mvanbeusekom added a commit to Baseflow/flutter-plugins that referenced this pull request Feb 2, 2022
Refactored the existing unit tests to expose private interfaces in a
separate test header instead of an inline interface. This was first
introduced in the google_sign_in plugin (flutter#4157) and after that also
applied in the camera plugin (flutter#4426) and the webview_flutter plugin
(flutter#4480).

This commit also removed several obsolete `OCMStub` declarations.
mvanbeusekom added a commit to Baseflow/flutter-plugins that referenced this pull request Feb 2, 2022
Refactored the existing unit tests to expose private interfaces in a
separate test header instead of an inline interface. This was first
introduced in the google_sign_in plugin (flutter#4157) and after that also
applied in the camera plugin (flutter#4426) and the webview_flutter plugin
(flutter#4480).
mvanbeusekom added a commit to Baseflow/flutter-plugins that referenced this pull request Feb 2, 2022
Refactored the existing unit tests to expose private interfaces in a
separate test header instead of an inline interface. This was first
introduced in the google_sign_in plugin (flutter#4157) and after that also
applied in the camera plugin (flutter#4426) and the webview_flutter plugin
(flutter#4480).
mvanbeusekom added a commit to Baseflow/flutter-plugins that referenced this pull request Feb 2, 2022
Refactored the existing unit tests to expose private interfaces in a
separate test header instead of an inline interface. This was first
introduced in the google_sign_in plugin (flutter#4157) and after that also
applied in the camera plugin (flutter#4426) and the webview_flutter plugin
(flutter#4480).
mvanbeusekom added a commit to Baseflow/flutter-plugins that referenced this pull request Feb 7, 2022
Refactored the existing unit tests to expose private interfaces in a
separate test header instead of an inline interface. This was first
introduced in the google_sign_in plugin (flutter#4157) and after that also
applied in the camera plugin (flutter#4426) and the webview_flutter plugin
(flutter#4480).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants