|
| 1 | +// Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +// Integration tests ported from upstream firebase_core v2.17.0: |
| 6 | +// https://github.com/firebase/flutterfire/blob/firebase_core-v2.17.0/tests/integration_test/firebase_core/firebase_core_e2e_test.dart |
| 7 | +// Originally authored by the Chromium project authors under a BSD-style |
| 8 | +// license. |
| 9 | + |
| 10 | +import 'package:firebase_core/firebase_core.dart'; |
| 11 | +import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'; |
| 12 | +import 'package:firebase_core_tizen_example/firebase_options.dart'; |
| 13 | +import 'package:flutter/foundation.dart'; |
| 14 | +import 'package:flutter_test/flutter_test.dart'; |
| 15 | +import 'package:integration_test/integration_test.dart'; |
| 16 | + |
| 17 | +void main() { |
| 18 | + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 19 | + |
| 20 | + group('firebase_core', () { |
| 21 | + const String testAppName = '[DEFAULT]'; |
| 22 | + |
| 23 | + setUpAll(() async { |
| 24 | + await Firebase.initializeApp( |
| 25 | + options: DefaultFirebaseOptions.currentPlatform, |
| 26 | + ); |
| 27 | + }); |
| 28 | + |
| 29 | + test('Firebase.apps', () async { |
| 30 | + final List<FirebaseApp> apps = Firebase.apps; |
| 31 | + expect(apps.length, 1); |
| 32 | + expect(apps[0].name, testAppName); |
| 33 | + expect(apps[0].options, DefaultFirebaseOptions.currentPlatform); |
| 34 | + }); |
| 35 | + |
| 36 | + test('Firebase.app()', () async { |
| 37 | + final FirebaseApp app = Firebase.app(); |
| 38 | + expect(app.name, testAppName); |
| 39 | + expect(app.options, DefaultFirebaseOptions.currentPlatform); |
| 40 | + }); |
| 41 | + |
| 42 | + test('Firebase.app() Exception', () async { |
| 43 | + expect( |
| 44 | + () => Firebase.app('NoApp'), |
| 45 | + throwsA(noAppExists('NoApp')), |
| 46 | + ); |
| 47 | + }); |
| 48 | + |
| 49 | + test( |
| 50 | + 'FirebaseApp.delete()', |
| 51 | + () async { |
| 52 | + await Firebase.initializeApp( |
| 53 | + name: 'SecondaryApp', |
| 54 | + options: DefaultFirebaseOptions.currentPlatform, |
| 55 | + ); |
| 56 | + |
| 57 | + expect(Firebase.apps.length, 2); |
| 58 | + |
| 59 | + final FirebaseApp app = Firebase.app('SecondaryApp'); |
| 60 | + |
| 61 | + await app.delete(); |
| 62 | + |
| 63 | + expect(Firebase.apps.length, 1); |
| 64 | + // TODO(russellwheatley): test randomly causes an auth sign-in failure due to duplicate accounts. |
| 65 | + }, |
| 66 | + skip: TargetPlatform.android == defaultTargetPlatform, |
| 67 | + ); |
| 68 | + |
| 69 | + test('FirebaseApp.setAutomaticDataCollectionEnabled()', () async { |
| 70 | + final FirebaseApp app = Firebase.app(); |
| 71 | + await app.setAutomaticDataCollectionEnabled(false); |
| 72 | + |
| 73 | + expect(app.isAutomaticDataCollectionEnabled, false); |
| 74 | + |
| 75 | + await app.setAutomaticDataCollectionEnabled(true); |
| 76 | + |
| 77 | + expect(app.isAutomaticDataCollectionEnabled, true); |
| 78 | + }); |
| 79 | + |
| 80 | + test('FirebaseApp.setAutomaticResourceManagementEnabled()', () async { |
| 81 | + final FirebaseApp app = Firebase.app(); |
| 82 | + |
| 83 | + await app.setAutomaticResourceManagementEnabled(true); |
| 84 | + }); |
| 85 | + }); |
| 86 | +} |
0 commit comments