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

[google_sign_in] Add implementations for new Oauth scope methods. #2562

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
111e637
[flutter-plugin-android-lifecycle] Update Gradle version (#2551)
Feb 24, 2020
5ce6e9b
[e2e] fix flutter driver code snippet in readme and improve formattin…
MaikuB Feb 24, 2020
2e14771
[path_provider] Move package into a path_provider directory (#2542)
franciscojma86 Feb 25, 2020
df0c291
[path_provider] Create platform interface (#2553)
franciscojma86 Feb 26, 2020
fcd0f45
Exclude path_provider packages (#2558)
franciscojma86 Feb 27, 2020
71d5b15
[connectivity_platform_interface] Add `ConnectivityResult.unknown`. (…
ditman Feb 27, 2020
9cc8ac1
Revert "[connectivity_platform_interface] Add `ConnectivityResult.unk…
ditman Feb 27, 2020
82f9a85
[path_provider_macos] Adds example app (#2559)
franciscojma86 Feb 27, 2020
5bc74e4
[url_launcher] fix: url_launcher - updated _launchUniversalLinkIos an…
jddeep Feb 28, 2020
3489dfd
[share] plugin: Update gradle version of example for Android (#2555)
jddeep Feb 28, 2020
e87d73d
[path_provider_platform_interface] Rename back to StorageDirectory (…
franciscojma86 Feb 28, 2020
20d3d30
[web] adding a test for e2e web testing. (#2554)
Feb 28, 2020
122a11e
Connectivity deprecation fix
collinjackson Mar 2, 2020
a53b5e1
Revert "Connectivity deprecation fix"
collinjackson Mar 2, 2020
0fd6b86
[path_provider] Use platform interface (#2557)
franciscojma86 Mar 2, 2020
6dfb311
[path_provider] Endorse macOS implementation (#2566)
franciscojma86 Mar 2, 2020
036a6e1
Remove plugin class (#2569)
franciscojma86 Mar 2, 2020
6ee6c5d
[device_info] add PackageManager's SystemFeatures to AndroidDeviceInf…
EricEnslen Mar 3, 2020
15ea190
[webview_flkutter] remove ios workspace setting
Mar 4, 2020
9d02b1f
[android_intent] Make action optional, as Intents can also resolve wi…
ened Mar 5, 2020
da00443
Remove Swift dependency (#2580)
collinjackson Mar 6, 2020
d0c9985
Make FlutterRunner launch deterministic when running other tests. (#2…
collinjackson Mar 6, 2020
6ceda31
[android_alarm_manager] Added Espresso test for background execution …
bkonyi Mar 6, 2020
536add2
Remove unused variable (#2352)
jayjun Mar 8, 2020
1eba1a2
[android_intent] Bump to Flutter stable, remove deprecation warnings …
ened Mar 8, 2020
467c7db
[in_app_purchase] Android: fix potential crash when casting in v1 emb…
Mar 9, 2020
7d93486
[connectivity] remove ios workspace setting for example app. (#2592)
Mar 9, 2020
4dec670
[device_info] Update Android embedding to match latest Flutter stable…
ened Mar 10, 2020
93f3f6e
[shared_preferences] Fix deprecated API call (#2536)
Zazo032 Mar 10, 2020
3bb18ed
[google_sign_in] Add new Oauth scope methods to google_sign_in_platfo…
emerssso Mar 11, 2020
7cac561
Add scope handling methods to google_sign_in_web.
emerssso Feb 10, 2020
567b133
Update version and changelog for web plugin.
emerssso Feb 10, 2020
822b336
Add scope handling methods to google_sign_in.
emerssso Feb 10, 2020
9a3f790
Update version for main plugin.
emerssso Feb 10, 2020
647699e
Fix GoogleSignInPlugin.java formatting.
emerssso Feb 27, 2020
c8306dd
Implement requesting multiple scopes on all platforms.
emerssso Feb 27, 2020
517c0bd
Remove listMissingScopes from implementations.
emerssso Feb 28, 2020
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
15 changes: 15 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ task:
dockerfile: .ci/Dockerfile
cpu: 8
memory: 16G
env:
E2E_PATH: "./packages/e2e"
upgrade_script:
- flutter channel stable
- flutter upgrade
Expand Down Expand Up @@ -45,6 +47,19 @@ task:
- if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi
- flutter channel $CHANNEL
- ./script/build_all_plugins_app.sh apk
- name: e2e_web_smoke_test
# Tests e2e example test in web.
only_if: "changesInclude('.cirrus.yml', 'packages/e2e/**') || $CIRRUS_PR == ''"
install_script:
- flutter config --enable-web
- git clone https://github.com/flutter/web_installers.git
- cd web_installers/packages/web_drivers/
- pub get
- dart lib/web_driver_installer.dart chromedriver --install-only
- ./chromedriver/chromedriver --port=4444 &
test_script:
- cd $E2E_PATH/example/
- flutter drive -v --target=test_driver/example_e2e.dart -d web-server --release --browser-name=chrome
- name: build-apks+java-test+firebase-test-lab
env:
matrix:
Expand Down
4 changes: 4 additions & 0 deletions packages/android_alarm_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.5+5

* Added an Espresso test.

## 0.4.5+4

* Make the pedantic dev_dependency explicit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ flutter {

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation "com.google.truth:truth:1.0"
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
api 'androidx.test:core:1.2.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2020 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.

package io.flutter.plugins.androidalarmmanagerexample;

import static androidx.test.espresso.Espresso.pressBackUnconditionally;
import static androidx.test.espresso.flutter.EspressoFlutter.onFlutterWidget;
import static androidx.test.espresso.flutter.action.FlutterActions.click;
import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withValueKey;
import static org.junit.Assert.assertEquals;

import android.content.Context;
import android.content.SharedPreferences;
import androidx.test.InstrumentationRegistry;
import androidx.test.core.app.ActivityScenario;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class BackgroundExecutionTest {
private SharedPreferences prefs;
static final String COUNT_KEY = "flutter.count";

@Rule
public ActivityTestRule<DriverExtensionActivity> myActivityTestRule =
new ActivityTestRule<>(DriverExtensionActivity.class, true, false);

@Before
public void setUp() throws Exception {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
prefs = context.getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE);
prefs.edit().putLong(COUNT_KEY, 0).apply();

ActivityScenario.launch(DriverExtensionActivity.class);
}

@Test
public void startBackgroundIsolate() throws Exception {

// Register a one shot alarm which will go off in ~5 seconds.
onFlutterWidget(withValueKey("RegisterOneShotAlarm")).perform(click());

// The alarm count should be 0 after installation.
assertEquals(prefs.getLong(COUNT_KEY, -1), 0);

// Close the application to background it.
pressBackUnconditionally();

// The alarm should eventually fire, wake up the application, create a
// background isolate, and then increment the counter in the shared
// preferences. Timeout after 20s, just to be safe.
int tries = 0;
while ((prefs.getLong(COUNT_KEY, -1) == 0) && (tries < 200)) {
Thread.sleep(100);
++tries;
}
assertEquals(prefs.getLong(COUNT_KEY, -1), 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.

package io.flutter.plugins.androidalarmmanagerexample;

import androidx.annotation.NonNull;

public class DriverExtensionActivity extends MainActivity {
@Override
@NonNull
public String getDartEntrypointFunctionName() {
return "appMain";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
package io.flutter.plugins.androidalarmmanagerexample;

import androidx.test.rule.ActivityTestRule;
import dev.flutter.plugins.e2e.FlutterRunner;
import dev.flutter.plugins.e2e.FlutterTestRunner;
import org.junit.Rule;
import org.junit.runner.RunWith;

@RunWith(FlutterRunner.class)
@RunWith(FlutterTestRunner.class)
public class MainActivityTest {
@Rule public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class);
@Rule
public ActivityTestRule<MainActivity> rule =
new ActivityTestRule<>(MainActivity.class, true, false);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.androidalarmmanagerexample">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<application android:usesCleartextTraffic="true">
<activity
android:name=".DriverExtensionActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;
import io.flutter.plugins.androidalarmmanager.AndroidAlarmManagerPlugin;
import io.flutter.plugins.pathprovider.PathProviderPlugin;
import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin;

public class MainActivity extends FlutterActivity {
// TODO(bkonyi): Remove this once v2 of GeneratedPluginRegistrant rolls to stable. https://github.com/flutter/flutter/issues/42694
Expand All @@ -18,6 +19,7 @@ public void configureFlutterEngine(FlutterEngine flutterEngine) {
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
flutterEngine.getPlugins().add(new AndroidAlarmManagerPlugin());
flutterEngine.getPlugins().add(new E2EPlugin());
flutterEngine.getPlugins().add(new SharedPreferencesPlugin());
PathProviderPlugin.registerWith(
shimPluginRegistry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
}
Expand Down
164 changes: 144 additions & 20 deletions packages/android_alarm_manager/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,156 @@

// ignore_for_file: public_member_api_docs

import 'dart:async';
import 'dart:isolate';
import 'dart:math';
import 'dart:ui';

import 'package:android_alarm_manager/android_alarm_manager.dart';
import 'package:flutter/widgets.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/material.dart';

void printMessage(String msg) => print('[${DateTime.now()}] $msg');
/// The [SharedPreferences] key to access the alarm fire count.
const String countKey = 'count';

void printPeriodic() => printMessage("Periodic!");
void printOneShot() => printMessage("One shot!");
/// The name associated with the UI isolate's [SendPort].
const String isolateName = 'isolate';

Future<void> main() async {
final int periodicID = 0;
final int oneShotID = 1;
/// A port used to communicate from a background isolate to the UI isolate.
final ReceivePort port = ReceivePort();

/// Global [SharedPreferences] object.
SharedPreferences prefs;

Future<void> main() async {
// TODO(bkonyi): uncomment
WidgetsFlutterBinding.ensureInitialized();

// Start the AlarmManager service.
await AndroidAlarmManager.initialize();

printMessage("main run");
runApp(const Center(
child:
Text('See device log for output', textDirection: TextDirection.ltr)));
await AndroidAlarmManager.periodic(
const Duration(seconds: 5), periodicID, printPeriodic,
wakeup: true, exact: true);
await AndroidAlarmManager.oneShot(
const Duration(seconds: 5), oneShotID, printOneShot);
// Register the UI isolate's SendPort to allow for communication from the
// background isolate.
IsolateNameServer.registerPortWithName(
port.sendPort,
isolateName,
);
prefs = await SharedPreferences.getInstance();
if (!prefs.containsKey(countKey)) {
await prefs.setInt(countKey, 0);
}
runApp(AlarmManagerExampleApp());
}

/// Example app for Espresso plugin.
class AlarmManagerExampleApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: _AlarmHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class _AlarmHomePage extends StatefulWidget {
_AlarmHomePage({Key key, this.title}) : super(key: key);
final String title;

@override
_AlarmHomePageState createState() => _AlarmHomePageState();
}

class _AlarmHomePageState extends State<_AlarmHomePage> {
int _counter = 0;

@override
void initState() {
super.initState();
AndroidAlarmManager.initialize();

// Register for events from the background isolate. These messages will
// always coincide with an alarm firing.
port.listen((_) async => await _incrementCounter());
}

Future<void> _incrementCounter() async {
print('Increment counter!');

// Ensure we've loaded the updated count from the background isolate.
await prefs.reload();

setState(() {
_counter++;
});
}

// The background
static SendPort uiSendPort;

// The callback for our alarm
static Future<void> callback() async {
print('Alarm fired!');

// Get the previous cached count and increment it.
final prefs = await SharedPreferences.getInstance();
int currentCount = prefs.getInt(countKey);
await prefs.setInt(countKey, currentCount + 1);

// This will be null if we're running in the background.
uiSendPort ??= IsolateNameServer.lookupPortByName(isolateName);
uiSendPort?.send(null);
}

@override
Widget build(BuildContext context) {
// TODO(jackson): This has been deprecated and should be replaced
// with `headline4` when it's available on all the versions of
// Flutter that we test.
// ignore: deprecated_member_use
final textStyle = Theme.of(context).textTheme.display1;
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Alarm fired $_counter times',
style: textStyle,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Total alarms fired: ',
style: textStyle,
),
Text(
prefs.getInt(countKey).toString(),
key: ValueKey('BackgroundCountText'),
style: textStyle,
),
],
),
RaisedButton(
child: Text(
'Schedule OneShot Alarm',
),
key: ValueKey('RegisterOneShotAlarm'),
onPressed: () async {
await AndroidAlarmManager.oneShot(
const Duration(seconds: 5),
// Ensure we have a unique alarm ID.
Random().nextInt(pow(2, 31)),
callback,
exact: true,
wakeup: true,
);
},
),
],
),
),
);
}
}
5 changes: 3 additions & 2 deletions packages/android_alarm_manager/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ dependencies:
sdk: flutter
android_alarm_manager:
path: ../
e2e: ^0.2.1
shared_preferences: ^0.5.6
e2e: 0.3.0
path_provider: ^1.3.1


dev_dependencies:
espresso: ^0.0.1+3
flutter_driver:
sdk: flutter
flutter_test:
Expand Down
Loading