-
Notifications
You must be signed in to change notification settings - Fork 52
[firebase_core] Add integration tests #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3e1f347
f597069
56b8331
ad75a99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // Integration tests ported from upstream firebase_core v2.17.0: | ||
| // https://github.com/firebase/flutterfire/blob/firebase_core-v2.17.0/tests/integration_test/firebase_core/firebase_core_e2e_test.dart | ||
| // Originally authored by the Chromium project authors under a BSD-style | ||
| // license. | ||
|
|
||
| import 'package:firebase_core/firebase_core.dart'; | ||
| import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'; | ||
| import 'package:firebase_core_tizen_example/firebase_options.dart'; | ||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
|
|
||
| void main() { | ||
| IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| group('firebase_core', () { | ||
| const String testAppName = '[DEFAULT]'; | ||
|
|
||
| setUpAll(() async { | ||
| await Firebase.initializeApp( | ||
| options: DefaultFirebaseOptions.currentPlatform, | ||
| ); | ||
| }); | ||
|
|
||
| test('Firebase.apps', () async { | ||
| final List<FirebaseApp> apps = Firebase.apps; | ||
| expect(apps.length, 1); | ||
| expect(apps[0].name, testAppName); | ||
| expect(apps[0].options, DefaultFirebaseOptions.currentPlatform); | ||
| }); | ||
|
|
||
| test('Firebase.app()', () async { | ||
| final FirebaseApp app = Firebase.app(); | ||
| expect(app.name, testAppName); | ||
| expect(app.options, DefaultFirebaseOptions.currentPlatform); | ||
| }); | ||
|
|
||
| test('Firebase.app() Exception', () async { | ||
| expect( | ||
| () => Firebase.app('NoApp'), | ||
| throwsA(noAppExists('NoApp')), | ||
| ); | ||
| }); | ||
|
|
||
| test( | ||
| 'FirebaseApp.delete()', | ||
| () async { | ||
| await Firebase.initializeApp( | ||
| name: 'SecondaryApp', | ||
| options: DefaultFirebaseOptions.currentPlatform, | ||
| ); | ||
|
|
||
| expect(Firebase.apps.length, 2); | ||
|
|
||
| final FirebaseApp app = Firebase.app('SecondaryApp'); | ||
|
|
||
| await app.delete(); | ||
|
|
||
| expect(Firebase.apps.length, 1); | ||
| // TODO(russellwheatley): test randomly causes an auth sign-in failure due to duplicate accounts. | ||
| }, | ||
| skip: TargetPlatform.android == defaultTargetPlatform, | ||
| ); | ||
|
|
||
| test('FirebaseApp.setAutomaticDataCollectionEnabled()', () async { | ||
| final FirebaseApp app = Firebase.app(); | ||
| await app.setAutomaticDataCollectionEnabled(false); | ||
|
|
||
| expect(app.isAutomaticDataCollectionEnabled, false); | ||
|
|
||
| await app.setAutomaticDataCollectionEnabled(true); | ||
|
|
||
| expect(app.isAutomaticDataCollectionEnabled, true); | ||
| }); | ||
|
|
||
| test('FirebaseApp.setAutomaticResourceManagementEnabled()', () async { | ||
| final FirebaseApp app = Firebase.app(); | ||
|
|
||
| await app.setAutomaticResourceManagementEnabled(true); | ||
| }); | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members, no_default_cases, public_member_api_docs | ||
| import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; | ||
| import 'package:flutter/foundation.dart' | ||
| show TargetPlatform, defaultTargetPlatform, kIsWeb; | ||
|
|
||
| class DefaultFirebaseOptions { | ||
| static FirebaseOptions get currentPlatform { | ||
| if (kIsWeb) { | ||
| throw UnsupportedError('Web is not supported.'); | ||
| } | ||
| switch (defaultTargetPlatform) { | ||
| case TargetPlatform.linux: // Tizen reports as TargetPlatform.linux | ||
| return linux; | ||
| default: | ||
| throw UnsupportedError( | ||
| 'DefaultFirebaseOptions are not supported for this platform.', | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| static const FirebaseOptions linux = FirebaseOptions( | ||
| apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', | ||
| appId: '1:448618578101:ios:0b650370bb29e29cac3efc', | ||
| messagingSenderId: '448618578101', | ||
| projectId: 'react-native-firebase-testing', | ||
| ); | ||
| } | ||
|
Comment on lines
+25
to
+31
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks to duplicate the values in the example's main. Please double-check if this is actually being used. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,14 @@ dependencies: | |
| path: ../ | ||
| flutter: | ||
| sdk: flutter | ||
|
|
||
| dev_dependencies: | ||
| firebase_core_platform_interface: ^4.5.2 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This dependency does not seems to be necessary. Even when I tested it, the integration_test tpk was generated successfully after removing this dependency.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the dependency still builds because firebase_core_platform_interface remains available transitively through firebase_core. However, the test directly imports it for the noAppExists matcher, so without the declaration flutter analyze reports a depend_on_referenced_packages violation (shown above), which the repo's analyze CI would flag. Upstream's tests/pubspec.yaml also declares it directly for the same reason, so I'd like to keep it. |
||
| flutter_driver: | ||
| sdk: flutter | ||
| flutter_test: | ||
| sdk: flutter | ||
| integration_test: | ||
| sdk: flutter | ||
| integration_test_tizen: | ||
| path: ../../integration_test/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // 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:integration_test/integration_test_driver.dart'; | ||
|
|
||
| Future<void> main() => integrationDriver(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,4 @@ flutter: | |
|
|
||
| false_secrets: | ||
| - /example/lib/main.dart | ||
| - /example/lib/firebase_options.dart | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the source location of this test is uncommon, adding the source url of the code to the PR message or code is useful for future updates.
https://github.com/firebase/flutterfire/blob/main/tests/integration_test/firebase_core/firebase_core_e2e_test.dart