From a9a19d54752e0a12420cb1201306039ca53e41a5 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 18 Aug 2020 18:59:59 -0700 Subject: [PATCH 01/12] [google_sign_in_web] Add GoogleAuthInitFailureError type. This type is the parameter type passed to the `onFailure` callback of the `auth` promise. This makes auth exceptions more predictable in profile/release mode. --- .../google_sign_in_web/lib/google_sign_in_web.dart | 2 +- .../lib/src/generated/gapiauth2.dart | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index bb43ba100c5d..f4a6723cbc56 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -105,7 +105,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { // state of the authentication, i.e: if you logout elsewhere... isAuthInitialized.complete(); - }), allowInterop((dynamic reason) { + }), allowInterop((auth2.GoogleAuthInitFailureError reason) { // onError throw PlatformException( code: 'google_sign_in', diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart index e05bedf3af1e..d2fe5e6e2535 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart @@ -16,6 +16,16 @@ import "package:js/js_util.dart" show promiseToFuture; /// +// @anonymous +@JS() +class GoogleAuthInitFailureError { + external String get error; + external set name(String value); + + external String get details; + external set details(String value); +} + // Module gapi.auth2 /// GoogleAuth is a singleton class that provides methods to allow the user to sign in with a Google account, /// get the user's current sign-in status, get specific data from the user's Google profile, @@ -30,7 +40,7 @@ class GoogleAuth { /// Calls the onInit function when the GoogleAuth object is fully initialized, or calls the onFailure function if /// initialization fails. external dynamic then(dynamic onInit(GoogleAuth googleAuth), - [dynamic onFailure(dynamic /*{error: string, details: string}*/ reason)]); + [dynamic onFailure(GoogleAuthInitFailureError reason)]); /// Signs out all accounts from the application. external dynamic signOut(); From f9b7ffd6d6594f775db18754dac21ff1716eb223 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 18 Aug 2020 20:04:16 -0700 Subject: [PATCH 02/12] Add GoogleAuthSignInError JS object. Throw a PlatformException when the signIn() method fails, instead of letting it throw a raw JS Object. --- .../lib/google_sign_in_web.dart | 17 ++++++++++++----- .../lib/src/generated/gapiauth2.dart | 9 ++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index f4a6723cbc56..c3f7978ca3ef 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -108,9 +108,9 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { }), allowInterop((auth2.GoogleAuthInitFailureError reason) { // onError throw PlatformException( - code: 'google_sign_in', - message: reason.error, - details: reason.details, + code: reason.error, + message: reason.details, + details: 'google_sign_in', ); })); @@ -128,8 +128,15 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { @override Future signIn() async { await initialized; - - return gapiUserToPluginUserData(await auth2.getAuthInstance().signIn()); + try { + return gapiUserToPluginUserData(await auth2.getAuthInstance().signIn()); + } on auth2.GoogleAuthSignInError catch (reason) { + throw PlatformException( + code: reason.error, + message: 'Exception raised from GoogleAuth.signIn()', + details: 'google_sign_in', + ); + } } @override diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart index d2fe5e6e2535..5c3683972ad4 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart @@ -16,7 +16,7 @@ import "package:js/js_util.dart" show promiseToFuture; /// -// @anonymous +@anonymous @JS() class GoogleAuthInitFailureError { external String get error; @@ -26,6 +26,13 @@ class GoogleAuthInitFailureError { external set details(String value); } +@anonymous +@JS() +class GoogleAuthSignInError { + external String get error; + external set name(String value); +} + // Module gapi.auth2 /// GoogleAuth is a singleton class that provides methods to allow the user to sign in with a Google account, /// get the user's current sign-in status, get specific data from the user's Google profile, From c4977bed0df195b1109988825ed98820742f41e4 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 18 Aug 2020 21:20:12 -0700 Subject: [PATCH 03/12] Bump version and changelog. --- packages/google_sign_in/google_sign_in_web/CHANGELOG.md | 6 ++++++ packages/google_sign_in/google_sign_in_web/pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 35a6934f9d4e..ca595119b8b6 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.9.2 + +* Throw PlatformExceptions from where the GMaps SDK may throw exceptions: `init()` and `signIn()`. +* Add two new JS-interop types to be able to unwrap JS errors in release mode. +* Align the fields of the thrown PlatformExceptions with the mobile version. + ## 0.9.1+2 * Update package:e2e reference to use the local version in the flutter/plugins diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index 8b48d36fde3c..317e02c337a8 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in_web description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web. homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in_web -version: 0.9.1+2 +version: 0.9.2 flutter: plugin: From 03d3d8702a2dda0e78f0ac404146f6e8625109a8 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 24 Aug 2020 13:49:00 -0700 Subject: [PATCH 04/12] Move tests to integration_test --- .../google_sign_in_web/test/README.md | 17 ++++++++++++++ .../google_sign_in_web/test/lib/main.dart | 22 ++++++++++++++++++ .../google_sign_in_web/test/pubspec.yaml | 23 +++++++++++++++++++ .../google_sign_in_web/test/run_test | 17 ++++++++++++++ .../auth2_integration.dart} | 2 +- .../test_driver/auth2_integration_test.dart | 8 +++++++ .../gapi_load_integration.dart} | 2 +- .../gapi_load_integration_test.dart | 8 +++++++ .../gapi_mocks/gapi_mocks.dart | 0 .../gapi_mocks/src/auth2_init.dart | 0 .../gapi_mocks/src/gapi.dart | 0 .../gapi_mocks/src/google_user.dart | 0 .../gapi_mocks/src/test_iife.dart | 0 .../gapi_utils_integration.dart} | 0 .../gapi_utils_integration_test.dart | 8 +++++++ .../src/test_utils.dart} | 0 .../google_sign_in_web/test/web/index.html | 13 +++++++++++ 17 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 packages/google_sign_in/google_sign_in_web/test/README.md create mode 100644 packages/google_sign_in/google_sign_in_web/test/lib/main.dart create mode 100644 packages/google_sign_in/google_sign_in_web/test/pubspec.yaml create mode 100755 packages/google_sign_in/google_sign_in_web/test/run_test rename packages/google_sign_in/google_sign_in_web/test/{auth2_test.dart => test_driver/auth2_integration.dart} (98%) create mode 100644 packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart rename packages/google_sign_in/google_sign_in_web/test/{gapi_load_test.dart => test_driver/gapi_load_integration.dart} (97%) create mode 100644 packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart rename packages/google_sign_in/google_sign_in_web/test/{ => test_driver}/gapi_mocks/gapi_mocks.dart (100%) rename packages/google_sign_in/google_sign_in_web/test/{ => test_driver}/gapi_mocks/src/auth2_init.dart (100%) rename packages/google_sign_in/google_sign_in_web/test/{ => test_driver}/gapi_mocks/src/gapi.dart (100%) rename packages/google_sign_in/google_sign_in_web/test/{ => test_driver}/gapi_mocks/src/google_user.dart (100%) rename packages/google_sign_in/google_sign_in_web/test/{ => test_driver}/gapi_mocks/src/test_iife.dart (100%) rename packages/google_sign_in/google_sign_in_web/test/{gapi_utils_test.dart => test_driver/gapi_utils_integration.dart} (100%) create mode 100644 packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart rename packages/google_sign_in/google_sign_in_web/test/{utils.dart => test_driver/src/test_utils.dart} (100%) create mode 100644 packages/google_sign_in/google_sign_in_web/test/web/index.html diff --git a/packages/google_sign_in/google_sign_in_web/test/README.md b/packages/google_sign_in/google_sign_in_web/test/README.md new file mode 100644 index 000000000000..7c48d024ba57 --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/README.md @@ -0,0 +1,17 @@ +# Running browser_tests + +Make sure you have updated to the latest Flutter master. + +1. Check what version of Chrome is running on the machine you're running tests on. + +2. Download and install driver for that version from here: + * + +3. Start the driver using `chromedriver --port=4444` + +4. Change into the `test` directory of your clone. + +5. Run tests: `flutter drive -d web-server --browser-name=chrome --target=test_driver/TEST_NAME_integration.dart`, or (in Linux): + + * Single: `./run_test test_driver/TEST_NAME_integration.dart` + * All: `./run_test` diff --git a/packages/google_sign_in/google_sign_in_web/test/lib/main.dart b/packages/google_sign_in/google_sign_in_web/test/lib/main.dart new file mode 100644 index 000000000000..10415204570c --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/lib/main.dart @@ -0,0 +1,22 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() { + runApp(MyApp()); +} + +/// App for testing +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + @override + Widget build(BuildContext context) { + return Text('Testing... Look at the console output for results!'); + } +} diff --git a/packages/google_sign_in/google_sign_in_web/test/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/test/pubspec.yaml new file mode 100644 index 000000000000..6f543b7911bc --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/pubspec.yaml @@ -0,0 +1,23 @@ +name: regular_integration_tests +publish_to: none + +environment: + sdk: ">=2.2.2 <3.0.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + google_sign_in: ^4.5.3 + flutter_driver: + sdk: flutter + flutter_test: + sdk: flutter + http: ^0.12.2 + mockito: ^4.1.1 + google_sign_in_web: + path: ../ + integration_test: + path: ../../../integration_test + diff --git a/packages/google_sign_in/google_sign_in_web/test/run_test b/packages/google_sign_in/google_sign_in_web/test/run_test new file mode 100755 index 000000000000..74a8526a0fa3 --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/run_test @@ -0,0 +1,17 @@ +#!/usr/bin/bash +if pgrep -lf chromedriver > /dev/null; then + echo "chromedriver is running." + + if [ $# -eq 0 ]; then + echo "No target specified, running all tests..." + find test_driver/ -iname *_integration.dart | xargs -n1 -i -t flutter drive -d web-server --web-port=7357 --browser-name=chrome --target='{}' + else + echo "Running test target: $1..." + set -x + flutter drive -d web-server --web-port=7357 --browser-name=chrome --target=$1 + fi + + else + echo "chromedriver is not running." +fi + diff --git a/packages/google_sign_in/google_sign_in_web/test/auth2_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart similarity index 98% rename from packages/google_sign_in/google_sign_in_web/test/auth2_test.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart index 40bc8a404d06..0bf389644c5a 100644 --- a/packages/google_sign_in/google_sign_in_web/test/auth2_test.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'; import 'package:google_sign_in_web/google_sign_in_web.dart'; import 'gapi_mocks/gapi_mocks.dart' as gapi_mocks; -import 'utils.dart'; +import 'src/test_utils.dart'; void main() { GoogleSignInTokenData expectedTokenData = diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart new file mode 100644 index 000000000000..bb7a8cd46a9b --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart @@ -0,0 +1,8 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() async => integrationDriver(); + diff --git a/packages/google_sign_in/google_sign_in_web/test/gapi_load_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration.dart similarity index 97% rename from packages/google_sign_in/google_sign_in_web/test/gapi_load_test.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration.dart index 6703beca2cad..5c9d9400cdb8 100644 --- a/packages/google_sign_in/google_sign_in_web/test/gapi_load_test.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration.dart @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'; import 'package:google_sign_in_web/google_sign_in_web.dart'; import 'gapi_mocks/gapi_mocks.dart' as gapi_mocks; -import 'utils.dart'; +import 'src/test_utils.dart'; void main() { gapiUrl = toBase64Url(gapi_mocks.auth2InitSuccess(GoogleSignInUserData())); diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart new file mode 100644 index 000000000000..bb7a8cd46a9b --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart @@ -0,0 +1,8 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() async => integrationDriver(); + diff --git a/packages/google_sign_in/google_sign_in_web/test/gapi_mocks/gapi_mocks.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/gapi_mocks.dart similarity index 100% rename from packages/google_sign_in/google_sign_in_web/test/gapi_mocks/gapi_mocks.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/gapi_mocks.dart diff --git a/packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/auth2_init.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart similarity index 100% rename from packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/auth2_init.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart diff --git a/packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/gapi.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/gapi.dart similarity index 100% rename from packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/gapi.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/gapi.dart diff --git a/packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/google_user.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/google_user.dart similarity index 100% rename from packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/google_user.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/google_user.dart diff --git a/packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/test_iife.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/test_iife.dart similarity index 100% rename from packages/google_sign_in/google_sign_in_web/test/gapi_mocks/src/test_iife.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/test_iife.dart diff --git a/packages/google_sign_in/google_sign_in_web/test/gapi_utils_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart similarity index 100% rename from packages/google_sign_in/google_sign_in_web/test/gapi_utils_test.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart new file mode 100644 index 000000000000..bb7a8cd46a9b --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart @@ -0,0 +1,8 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() async => integrationDriver(); + diff --git a/packages/google_sign_in/google_sign_in_web/test/utils.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/src/test_utils.dart similarity index 100% rename from packages/google_sign_in/google_sign_in_web/test/utils.dart rename to packages/google_sign_in/google_sign_in_web/test/test_driver/src/test_utils.dart diff --git a/packages/google_sign_in/google_sign_in_web/test/web/index.html b/packages/google_sign_in/google_sign_in_web/test/web/index.html new file mode 100644 index 000000000000..59a832b5de4c --- /dev/null +++ b/packages/google_sign_in/google_sign_in_web/test/web/index.html @@ -0,0 +1,13 @@ + + + + + Browser Tests + + + + + + From 9dd2f5667b74b48f139ecc922a92611d014a835b Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 24 Aug 2020 14:03:12 -0700 Subject: [PATCH 05/12] Migrate test code to integration_test --- .../google_sign_in_web/test/pubspec.yaml | 5 +++-- .../test/test_driver/auth2_integration.dart | 16 +++++++++------- .../test/test_driver/gapi_load_integration.dart | 10 ++++++---- .../test/test_driver/gapi_utils_integration.dart | 13 +++++++------ 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/test/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/test/pubspec.yaml index 6f543b7911bc..dd0354e81498 100644 --- a/packages/google_sign_in/google_sign_in_web/test/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/test/pubspec.yaml @@ -16,8 +16,9 @@ dev_dependencies: sdk: flutter http: ^0.12.2 mockito: ^4.1.1 - google_sign_in_web: - path: ../ integration_test: path: ../../../integration_test +dependency_overrides: + google_sign_in_web: + path: ../ diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart index 0bf389644c5a..708b181388b3 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -@TestOn('browser') +import 'package:integration_test/integration_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'; @@ -11,6 +11,8 @@ import 'gapi_mocks/gapi_mocks.dart' as gapi_mocks; import 'src/test_utils.dart'; void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + GoogleSignInTokenData expectedTokenData = GoogleSignInTokenData(idToken: '70k3n', accessToken: 'access_70k3n'); @@ -31,11 +33,11 @@ void main() { plugin = GoogleSignInPlugin(); }); - test('Init requires clientId', () async { + testWidgets('Init requires clientId', (WidgetTester tester) async { expect(plugin.init(hostedDomain: ''), throwsAssertionError); }); - test('Init doesn\'t accept spaces in scopes', () async { + testWidgets('Init doesn\'t accept spaces in scopes', (WidgetTester tester) async { expect( plugin.init( hostedDomain: '', @@ -55,26 +57,26 @@ void main() { await plugin.initialized; }); - test('signInSilently', () async { + testWidgets('signInSilently', (WidgetTester tester) async { GoogleSignInUserData actualUser = await plugin.signInSilently(); expect(actualUser, expectedUserData); }); - test('signIn', () async { + testWidgets('signIn', (WidgetTester tester) async { GoogleSignInUserData actualUser = await plugin.signIn(); expect(actualUser, expectedUserData); }); - test('getTokens', () async { + testWidgets('getTokens', (WidgetTester tester) async { GoogleSignInTokenData actualToken = await plugin.getTokens(email: expectedUserData.email); expect(actualToken, expectedTokenData); }); - test('requestScopes', () async { + testWidgets('requestScopes', (WidgetTester tester) async { bool scopeGranted = await plugin.requestScopes(['newScope']); expect(scopeGranted, isTrue); diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration.dart index 5c9d9400cdb8..540369cae370 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration.dart @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -@TestOn('browser') - import 'dart:html' as html; +import 'package:integration_test/integration_test.dart'; + import 'package:flutter_test/flutter_test.dart'; import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart'; import 'package:google_sign_in_web/google_sign_in_web.dart'; @@ -13,10 +13,12 @@ import 'gapi_mocks/gapi_mocks.dart' as gapi_mocks; import 'src/test_utils.dart'; void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + gapiUrl = toBase64Url(gapi_mocks.auth2InitSuccess(GoogleSignInUserData())); - test('Plugin is initialized after GAPI fully loads and init is called', - () async { + testWidgets('Plugin is initialized after GAPI fully loads and init is called', + (WidgetTester tester) async { expect( html.querySelector('script[src^="data:"]'), isNull, diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart index 2dc49fc5b67a..fe204420d340 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart @@ -1,10 +1,10 @@ // Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -@TestOn('browser') - import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + import 'package:google_sign_in_web/src/generated/gapiauth2.dart' as gapi; import 'package:google_sign_in_web/src/utils.dart'; import 'package:mockito/mockito.dart'; @@ -15,6 +15,7 @@ class MockBasicProfile extends Mock implements gapi.BasicProfile {} void main() { // The non-null use cases are covered by the auth2_test.dart file. + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('gapiUserToPluginUserData', () { var mockUser; @@ -23,21 +24,21 @@ void main() { mockUser = MockGoogleUser(); }); - test('null user -> null response', () { + testWidgets('null user -> null response', (WidgetTester tester) async { expect(gapiUserToPluginUserData(null), isNull); }); - test('not signed-in user -> null response', () { + testWidgets('not signed-in user -> null response', (WidgetTester tester) async { when(mockUser.isSignedIn()).thenReturn(false); expect(gapiUserToPluginUserData(mockUser), isNull); }); - test('signed-in, but null profile user -> null response', () { + testWidgets('signed-in, but null profile user -> null response', (WidgetTester tester) async { when(mockUser.isSignedIn()).thenReturn(true); expect(gapiUserToPluginUserData(mockUser), isNull); }); - test('signed-in, null userId in profile user -> null response', () { + testWidgets('signed-in, null userId in profile user -> null response', (WidgetTester tester) async { when(mockUser.isSignedIn()).thenReturn(true); when(mockUser.getBasicProfile()).thenReturn(MockBasicProfile()); expect(gapiUserToPluginUserData(mockUser), isNull); From 68394ad4e037d97ab5422271db209260d60f8613 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 24 Aug 2020 14:04:04 -0700 Subject: [PATCH 06/12] dartfmt -w . --- .../test/test_driver/auth2_integration.dart | 3 ++- .../test/test_driver/auth2_integration_test.dart | 1 - .../test/test_driver/gapi_load_integration_test.dart | 1 - .../test/test_driver/gapi_utils_integration.dart | 9 ++++++--- .../test/test_driver/gapi_utils_integration_test.dart | 1 - 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart index 708b181388b3..3053fcbcca0d 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart @@ -37,7 +37,8 @@ void main() { expect(plugin.init(hostedDomain: ''), throwsAssertionError); }); - testWidgets('Init doesn\'t accept spaces in scopes', (WidgetTester tester) async { + testWidgets('Init doesn\'t accept spaces in scopes', + (WidgetTester tester) async { expect( plugin.init( hostedDomain: '', diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart index bb7a8cd46a9b..39444c0daa24 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration_test.dart @@ -5,4 +5,3 @@ import 'package:integration_test/integration_test_driver.dart'; Future main() async => integrationDriver(); - diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart index bb7a8cd46a9b..39444c0daa24 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_load_integration_test.dart @@ -5,4 +5,3 @@ import 'package:integration_test/integration_test_driver.dart'; Future main() async => integrationDriver(); - diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart index fe204420d340..55b942842b33 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration.dart @@ -28,17 +28,20 @@ void main() { expect(gapiUserToPluginUserData(null), isNull); }); - testWidgets('not signed-in user -> null response', (WidgetTester tester) async { + testWidgets('not signed-in user -> null response', + (WidgetTester tester) async { when(mockUser.isSignedIn()).thenReturn(false); expect(gapiUserToPluginUserData(mockUser), isNull); }); - testWidgets('signed-in, but null profile user -> null response', (WidgetTester tester) async { + testWidgets('signed-in, but null profile user -> null response', + (WidgetTester tester) async { when(mockUser.isSignedIn()).thenReturn(true); expect(gapiUserToPluginUserData(mockUser), isNull); }); - testWidgets('signed-in, null userId in profile user -> null response', (WidgetTester tester) async { + testWidgets('signed-in, null userId in profile user -> null response', + (WidgetTester tester) async { when(mockUser.isSignedIn()).thenReturn(true); when(mockUser.getBasicProfile()).thenReturn(MockBasicProfile()); expect(gapiUserToPluginUserData(mockUser), isNull); diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart index bb7a8cd46a9b..39444c0daa24 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_utils_integration_test.dart @@ -5,4 +5,3 @@ import 'package:integration_test/integration_test_driver.dart'; Future main() async => integrationDriver(); - From 42143d29add60934226142420fc2fe1ed16f18f6 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 24 Aug 2020 16:27:04 -0700 Subject: [PATCH 07/12] Test init and other catchable exceptions. --- .../test/test_driver/auth2_integration.dart | 155 +++++++++++++----- .../gapi_mocks/src/auth2_init.dart | 20 +++ 2 files changed, 136 insertions(+), 39 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart index 3053fcbcca0d..51b952371975 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/services.dart'; import 'package:integration_test/integration_test.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -24,63 +25,139 @@ void main() { idToken: expectedTokenData.idToken, ); - // The pre-configured use case for the instances of the plugin in this test - gapiUrl = toBase64Url(gapi_mocks.auth2InitSuccess(expectedUserData)); - GoogleSignInPlugin plugin; - setUp(() { - plugin = GoogleSignInPlugin(); - }); + group('plugin.init() throws a catchable exception', () { + setUp(() { + // The pre-configured use case for the instances of the plugin in this test + gapiUrl = toBase64Url(gapi_mocks.auth2InitError()); + plugin = GoogleSignInPlugin(); + }); - testWidgets('Init requires clientId', (WidgetTester tester) async { - expect(plugin.init(hostedDomain: ''), throwsAssertionError); - }); + testWidgets('init throws PlatformException', (WidgetTester tester) async { + await expectLater( + plugin.init( + hostedDomain: 'foo', + scopes: ['some', 'scope'], + clientId: '1234', + ), + throwsA(isA())); + }); - testWidgets('Init doesn\'t accept spaces in scopes', - (WidgetTester tester) async { - expect( - plugin.init( - hostedDomain: '', - clientId: '', - scopes: ['scope with spaces'], - ), - throwsAssertionError); + testWidgets('init forwards error code from JS', + (WidgetTester tester) async { + try { + await plugin.init( + hostedDomain: 'foo', + scopes: ['some', 'scope'], + clientId: '1234', + ); + fail('plugin.init should have thrown an exception!'); + } catch (e) { + expect(e.code, 'idpiframe_initialization_failed'); + } + }); }); - group('Successful .init, then', () { - setUp(() async { - await plugin.init( - hostedDomain: 'foo', - scopes: ['some', 'scope'], - clientId: '1234', - ); - await plugin.initialized; + group('other methods also throw catchable exceptions on init fail', () { + // This function ensures that init gets called, but for some reason, we + // ignored that it has thrown stuff... + void _discardInit() async { + try { + await plugin.init( + hostedDomain: 'foo', + scopes: ['some', 'scope'], + clientId: '1234', + ); + } catch (e) { + // Noop so we can call other stuff + } + } + + setUp(() { + gapiUrl = toBase64Url(gapi_mocks.auth2InitError()); + plugin = GoogleSignInPlugin(); }); - testWidgets('signInSilently', (WidgetTester tester) async { - GoogleSignInUserData actualUser = await plugin.signInSilently(); + testWidgets('signInSilently throws', (WidgetTester tester) async { + await _discardInit(); + await expectLater( + plugin.signInSilently(), throwsA(isA())); + }); - expect(actualUser, expectedUserData); + testWidgets('signIn throws', (WidgetTester tester) async { + await _discardInit(); + await expectLater(plugin.signIn(), throwsA(isA())); }); - testWidgets('signIn', (WidgetTester tester) async { - GoogleSignInUserData actualUser = await plugin.signIn(); + testWidgets('getTokens throws', (WidgetTester tester) async { + await _discardInit(); + await expectLater(plugin.getTokens(email: 'test@example.com'), + throwsA(isA())); + }); + testWidgets('requestScopes', (WidgetTester tester) async { + await _discardInit(); + await expectLater(plugin.requestScopes(['newScope']), + throwsA(isA())); + }); + }); - expect(actualUser, expectedUserData); + group('auth2 Init Successful', () { + setUp(() { + // The pre-configured use case for the instances of the plugin in this test + gapiUrl = toBase64Url(gapi_mocks.auth2InitSuccess(expectedUserData)); + plugin = GoogleSignInPlugin(); }); - testWidgets('getTokens', (WidgetTester tester) async { - GoogleSignInTokenData actualToken = - await plugin.getTokens(email: expectedUserData.email); + testWidgets('Init requires clientId', (WidgetTester tester) async { + expect(plugin.init(hostedDomain: ''), throwsAssertionError); + }); - expect(actualToken, expectedTokenData); + testWidgets('Init doesn\'t accept spaces in scopes', + (WidgetTester tester) async { + expect( + plugin.init( + hostedDomain: '', + clientId: '', + scopes: ['scope with spaces'], + ), + throwsAssertionError); }); - testWidgets('requestScopes', (WidgetTester tester) async { - bool scopeGranted = await plugin.requestScopes(['newScope']); + group('Successful .init, then', () { + setUp(() async { + await plugin.init( + hostedDomain: 'foo', + scopes: ['some', 'scope'], + clientId: '1234', + ); + await plugin.initialized; + }); + + testWidgets('signInSilently', (WidgetTester tester) async { + GoogleSignInUserData actualUser = await plugin.signInSilently(); + + expect(actualUser, expectedUserData); + }); + + testWidgets('signIn', (WidgetTester tester) async { + GoogleSignInUserData actualUser = await plugin.signIn(); + + expect(actualUser, expectedUserData); + }); + + testWidgets('getTokens', (WidgetTester tester) async { + GoogleSignInTokenData actualToken = + await plugin.getTokens(email: expectedUserData.email); + + expect(actualToken, expectedTokenData); + }); + + testWidgets('requestScopes', (WidgetTester tester) async { + bool scopeGranted = await plugin.requestScopes(['newScope']); - expect(scopeGranted, isTrue); + expect(scopeGranted, isTrue); + }); }); }); } diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart index 1846033151c1..4c9dba80a514 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart @@ -45,3 +45,23 @@ GapiAuth2.prototype.getAuthInstance = function () { window.gapi.auth2 = new GapiAuth2(); '''); + +String auth2InitError() => testIife(''' +${gapi()} + +function GapiAuth2() {} +GapiAuth2.prototype.init = function (initOptions) { + return { + then: (onSuccess, onError) => { + window.setTimeout(() => { + onError({ + error: 'idpiframe_initialization_failed', + details: 'This error was raised from a test.', + }); + }, 30); + } + } +}; + +window.gapi.auth2 = new GapiAuth2(); +'''); From 26e8eda069600385189f81f8d7f2ed4f5cf9e0e0 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 24 Aug 2020 16:48:37 -0700 Subject: [PATCH 08/12] Test SignIn errors --- .../lib/google_sign_in_web.dart | 6 +-- .../lib/src/generated/gapiauth2.dart | 4 +- .../test/test_driver/auth2_integration.dart | 29 ++++++++++++++ .../gapi_mocks/src/auth2_init.dart | 40 +++++++++++++++++++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index c3f7978ca3ef..cce6b229a72e 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -107,14 +107,14 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { isAuthInitialized.complete(); }), allowInterop((auth2.GoogleAuthInitFailureError reason) { // onError - throw PlatformException( + isAuthInitialized.completeError(PlatformException( code: reason.error, message: reason.details, details: 'google_sign_in', - ); + )); })); - return null; + return _isAuthInitialized; } @override diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart index 5c3683972ad4..ed7a2816d55e 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart @@ -20,7 +20,7 @@ import "package:js/js_util.dart" show promiseToFuture; @JS() class GoogleAuthInitFailureError { external String get error; - external set name(String value); + external set error(String value); external String get details; external set details(String value); @@ -30,7 +30,7 @@ class GoogleAuthInitFailureError { @JS() class GoogleAuthSignInError { external String get error; - external set name(String value); + external set error(String value); } // Module gapi.auth2 diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart index 51b952371975..e2f16f2aee43 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/auth2_integration.dart @@ -160,4 +160,33 @@ void main() { }); }); }); + + group('auth2 Init successful, but exception on signIn() method', () { + setUp(() async { + // The pre-configured use case for the instances of the plugin in this test + gapiUrl = toBase64Url(gapi_mocks.auth2SignInError()); + plugin = GoogleSignInPlugin(); + await plugin.init( + hostedDomain: 'foo', + scopes: ['some', 'scope'], + clientId: '1234', + ); + await plugin.initialized; + }); + + testWidgets('User aborts sign in flow, throws PlatformException', + (WidgetTester tester) async { + await expectLater(plugin.signIn(), throwsA(isA())); + }); + + testWidgets('User aborts sign in flow, error code is forwarded from JS', + (WidgetTester tester) async { + try { + await plugin.signIn(); + fail('plugin.signIn() should have thrown an exception!'); + } catch (e) { + expect(e.code, 'popup_closed_by_user'); + } + }); + }); } diff --git a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart index 4c9dba80a514..79d798ad2c85 100644 --- a/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart +++ b/packages/google_sign_in/google_sign_in_web/test/test_driver/gapi_mocks/src/auth2_init.dart @@ -65,3 +65,43 @@ GapiAuth2.prototype.init = function (initOptions) { window.gapi.auth2 = new GapiAuth2(); '''); + +String auth2SignInError([String error = 'popup_closed_by_user']) => testIife(''' +${gapi()} + +var mockUser = null; + +function GapiAuth2() {} +GapiAuth2.prototype.init = function (initOptions) { + return { + then: (onSuccess, onError) => { + window.setTimeout(() => { + onSuccess(window.gapi.auth2); + }, 30); + }, + currentUser: { + listen: (cb) => { + window.setTimeout(() => { + cb(mockUser); + }, 30); + } + } + } +}; + +GapiAuth2.prototype.getAuthInstance = function () { + return { + signIn: () => { + return new Promise((resolve, reject) => { + window.setTimeout(() => { + reject({ + error: '${error}' + }); + }, 30); + }); + }, + } +}; + +window.gapi.auth2 = new GapiAuth2(); +'''); From 5948b9645e1d86df5feee0c577a111a759c10719 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 24 Aug 2020 16:58:33 -0700 Subject: [PATCH 09/12] Update docs about testing. --- packages/google_sign_in/google_sign_in_web/CHANGELOG.md | 1 + packages/google_sign_in/google_sign_in_web/README.md | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index ca595119b8b6..d71badc53bfc 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -3,6 +3,7 @@ * Throw PlatformExceptions from where the GMaps SDK may throw exceptions: `init()` and `signIn()`. * Add two new JS-interop types to be able to unwrap JS errors in release mode. * Align the fields of the thrown PlatformExceptions with the mobile version. +* Migrate tests to run with `flutter drive` ## 0.9.1+2 diff --git a/packages/google_sign_in/google_sign_in_web/README.md b/packages/google_sign_in/google_sign_in_web/README.md index 930212c17558..7a44e998f3c3 100644 --- a/packages/google_sign_in/google_sign_in_web/README.md +++ b/packages/google_sign_in/google_sign_in_web/README.md @@ -98,11 +98,7 @@ See the [google_sign_in.dart](https://github.com/flutter/plugins/blob/master/pac Tests are a crucial to contributions to this package. All new contributions should be reasonably tested. -In order to run tests in this package, do: - -``` -flutter test --platform chrome -j1 -``` +**Check the [`test/README.md` file](https://github.com/flutter/plugins/blob/master/packages/google_sign_in/google_sign_in_web/test/README.md)** for more information on how to run tests on this package. Contributions to this package are welcome. Read the [Contributing to Flutter Plugins](https://github.com/flutter/plugins/blob/master/CONTRIBUTING.md) guide to get started. From f051ddfb7871fcde72c345b05224723630851446 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 24 Aug 2020 17:05:56 -0700 Subject: [PATCH 10/12] Fix check. --- packages/google_sign_in/google_sign_in_web/pubspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index 317e02c337a8..70758ac6830d 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -26,6 +26,8 @@ dev_dependencies: google_sign_in: ^4.0.14 pedantic: ^1.8.0 mockito: ^4.1.1 + integration_test: + path: ../../integration_test environment: sdk: ">=2.6.0 <3.0.0" From 80663d04e3a6c3a23f491ff842c82c12250ac498 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 11 Sep 2020 11:33:58 -0700 Subject: [PATCH 11/12] Add link to API reference for Sign In errors --- .../google_sign_in_web/lib/google_sign_in_web.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index cce6b229a72e..112443bafb94 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -134,7 +134,8 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { throw PlatformException( code: reason.error, message: 'Exception raised from GoogleAuth.signIn()', - details: 'google_sign_in', + details: + 'https://developers.google.com/identity/sign-in/web/reference#error_codes_2', ); } } From fe267bb25914e2399ad0578cf745bbc36f0f83c7 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 11 Sep 2020 14:46:24 -0700 Subject: [PATCH 12/12] Add link to api reference to the init error as well! --- .../google_sign_in_web/lib/google_sign_in_web.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index 112443bafb94..dd82852fa350 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -110,7 +110,8 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { isAuthInitialized.completeError(PlatformException( code: reason.error, message: reason.details, - details: 'google_sign_in', + details: + 'https://developers.google.com/identity/sign-in/web/reference#error_codes', )); }));