Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/google_sign_in/google_sign_in_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 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.
* Migrate tests to run with `flutter drive`

## 0.9.1+2

* Update package:e2e reference to use the local version in the flutter/plugins
Expand Down
6 changes: 1 addition & 5 deletions packages/google_sign_in/google_sign_in_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,17 @@ 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',
message: reason.error,
details: reason.details,
);
isAuthInitialized.completeError(PlatformException(
code: reason.error,
message: reason.details,
details:
'https://developers.google.com/identity/sign-in/web/reference#error_codes',
));
}));

return null;
return _isAuthInitialized;
}

@override
Expand All @@ -128,8 +129,16 @@ class GoogleSignInPlugin extends GoogleSignInPlatform {
@override
Future<GoogleSignInUserData> 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:
'https://developers.google.com/identity/sign-in/web/reference#error_codes_2',
);
}
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ import "package:js/js_util.dart" show promiseToFuture;

/// <reference types="gapi" />

@anonymous
@JS()
class GoogleAuthInitFailureError {
external String get error;
external set error(String value);

external String get details;
external set details(String value);
}

@anonymous
@JS()
class GoogleAuthSignInError {
external String get error;
external set error(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,
Expand All @@ -30,7 +47,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();
Expand Down
4 changes: 3 additions & 1 deletion packages/google_sign_in/google_sign_in_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions packages/google_sign_in/google_sign_in_web/test/README.md
Original file line number Diff line number Diff line change
@@ -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:
* <https://chromedriver.chromium.org/downloads>

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`
83 changes: 0 additions & 83 deletions packages/google_sign_in/google_sign_in_web/test/auth2_test.dart

This file was deleted.

This file was deleted.

22 changes: 22 additions & 0 deletions packages/google_sign_in/google_sign_in_web/test/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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<MyApp> {
@override
Widget build(BuildContext context) {
return Text('Testing... Look at the console output for results!');
}
}
24 changes: 24 additions & 0 deletions packages/google_sign_in/google_sign_in_web/test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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
integration_test:
path: ../../../integration_test

dependency_overrides:
google_sign_in_web:
path: ../
17 changes: 17 additions & 0 deletions packages/google_sign_in/google_sign_in_web/test/run_test
Original file line number Diff line number Diff line change
@@ -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

Loading