Skip to content
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
1 change: 1 addition & 0 deletions packages/firebase_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Add integration tests based on upstream firebase_core v2.17.0.
* Update minimum Flutter and Dart version to 3.13 and 3.1.
* Fix new lint warnings.
* Update code format.
Expand Down
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.

Copy link
Copy Markdown
Member

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

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);
});
});
}
31 changes: 31 additions & 0 deletions packages/firebase_core/example/lib/firebase_options.dart
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

9 changes: 3 additions & 6 deletions packages/firebase_core/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ import 'dart:developer';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

import 'firebase_options.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({super.key});

String get name => 'foo';

FirebaseOptions get firebaseOptions => const FirebaseOptions(
appId: '1:448618578101:ios:0b650370bb29e29cac3efc',
apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0',
projectId: 'react-native-firebase-testing',
messagingSenderId: '448618578101',
);
FirebaseOptions get firebaseOptions => DefaultFirebaseOptions.currentPlatform;

Future<void> initializeDefault() async {
final FirebaseApp app = await Firebase.initializeApp(
Expand Down
11 changes: 11 additions & 0 deletions packages/firebase_core/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ dependencies:
path: ../
flutter:
sdk: flutter

dev_dependencies:
firebase_core_platform_interface: ^4.5.2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.
Please check whether this dependency is required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

info • integration_test/firebase_core_test.dart:11:8 • The imported package 'firebase_core_platform_interface' isn't a dependency of the importing package. Try adding a dependency for 'firebase_core_platform_interface' in the 'pubspec.yaml' file. • depend_on_referenced_packages

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();
1 change: 1 addition & 0 deletions packages/firebase_core/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ flutter:

false_secrets:
- /example/lib/main.dart
- /example/lib/firebase_options.dart
Loading