Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 4938112

Browse files
collinjacksonmithun-mondal
authored andcommitted
[firebase_messaging] add integration tests (flutter#1816)
* Initial firebase_messaging integration tests
1 parent ac0dd77 commit 4938112

5 files changed

Lines changed: 54 additions & 42 deletions

File tree

packages/firebase_messaging/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 5.0.6
2+
3+
* Additional integration tests.
4+
15
## 5.0.5
26

37
* On Android, fix crash when calling `deleteInstanceID` with latest Flutter engine.

packages/firebase_messaging/example/pubspec.yaml

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,12 @@ dependencies:
88
path: ../
99
firebase_core: ^0.4.0
1010

11-
# For information on the generic Dart part of this file, see the
12-
# following page: https://www.dartlang.org/tools/pub/pubspec
11+
dev_dependencies:
12+
flutter_test:
13+
sdk: flutter
14+
flutter_driver:
15+
sdk: flutter
16+
test: any
1317

14-
# The following section is specific to Flutter.
1518
flutter:
16-
17-
# The following line ensures that the Material Icons font is
18-
# included with your application, so that you can use the icons in
19-
# the Icons class.
2019
uses-material-design: true
21-
22-
# To add assets to your application, add an assets section here, in
23-
# this "flutter" section, as in:
24-
# assets:
25-
# - images/a_dot_burr.jpeg
26-
# - images/a_dot_ham.jpeg
27-
28-
# To add assets from package dependencies, first ensure the asset
29-
# is in the lib/ directory of the dependency. Then,
30-
# refer to the asset with a path prefixed with
31-
# `packages/PACKAGE_NAME/`. Note: the `lib/` is implied, do not
32-
# include `lib/` in the asset path.
33-
#
34-
# Here is an example:
35-
#
36-
# assets:
37-
# - packages/PACKAGE_NAME/path/to/asset
38-
39-
# To add custom fonts to your application, add a fonts section here,
40-
# in this "flutter" section. Each entry in this list should have a
41-
# "family" key with the font family name, and a "fonts" key with a
42-
# list giving the asset and other descriptors for the font. For
43-
# example:
44-
# fonts:
45-
# - family: Schyler
46-
# fonts:
47-
# - asset: fonts/Schyler-Regular.ttf
48-
# - asset: fonts/Schyler-Italic.ttf
49-
# style: italic
50-
# - family: Trajan Pro
51-
# fonts:
52-
# - asset: fonts/TrajanPro.ttf
53-
# - asset: fonts/TrajanPro_Bold.ttf
54-
# weight: 700
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import 'dart:async';
2+
import 'package:flutter_driver/driver_extension.dart';
3+
import 'package:flutter_test/flutter_test.dart';
4+
import 'package:firebase_messaging/firebase_messaging.dart';
5+
6+
void main() {
7+
final Completer<String> completer = Completer<String>();
8+
enableFlutterDriverExtension(handler: (_) => completer.future);
9+
tearDownAll(() => completer.complete(null));
10+
11+
group('$FirebaseMessaging', () {
12+
final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
13+
14+
test('autoInitEnabled', () async {
15+
await firebaseMessaging.setAutoInitEnabled(false);
16+
expect(await firebaseMessaging.autoInitEnabled(), false);
17+
await firebaseMessaging.setAutoInitEnabled(true);
18+
expect(await firebaseMessaging.autoInitEnabled(), true);
19+
});
20+
21+
test('subscribeToTopic', () async {
22+
firebaseMessaging.subscribeToTopic('foo');
23+
});
24+
25+
test('unsubscribeFromTopic', () async {
26+
firebaseMessaging.unsubscribeFromTopic('foo');
27+
});
28+
29+
test('deleteInstanceID', () async {
30+
final bool result = await firebaseMessaging.deleteInstanceID();
31+
expect(result, isTrue);
32+
});
33+
});
34+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import 'package:flutter_driver/flutter_driver.dart';
2+
3+
Future<void> main() async {
4+
final FlutterDriver driver = await FlutterDriver.connect();
5+
await driver.requestData(null, timeout: const Duration(minutes: 1));
6+
driver.close();
7+
}

packages/firebase_messaging/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for Firebase Cloud Messaging, a cross-platform
33
messaging solution that lets you reliably deliver messages on Android and iOS.
44
author: Flutter Team <flutter-dev@googlegroups.com>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_messaging
6-
version: 5.0.5
6+
version: 5.0.6
77

88
flutter:
99
plugin:
@@ -23,6 +23,8 @@ dev_dependencies:
2323
flutter_test:
2424
sdk: flutter
2525
firebase_core: ^0.4.0
26+
flutter_driver:
27+
sdk: flutter
2628

2729
environment:
2830
sdk: ">=2.0.0-dev.28.0 <3.0.0"

0 commit comments

Comments
 (0)