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
11 changes: 8 additions & 3 deletions tests/integration_test/e2e_test.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. 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:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'firebase_core/firebase_core_e2e_test.dart' as firebase_core;

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

// ignore: unnecessary_lambdas
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line will be remove when I migrated a second package.

group('FlutterFire', () {
test('dummy test', () {
expect(true, true);
});
firebase_core.main();
});
}
80 changes: 80 additions & 0 deletions tests/integration_test/firebase_core/firebase_core_e2e_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
Copy link
Contributor Author

@nilsreichardt nilsreichardt Jun 19, 2022

Choose a reason for hiding this comment

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

A difference to the Flutter Driver tests is that I called the file firebase_core_e2e_test.dart instead of firebase_core_e2e.dart.

This has the advantage that IDEs detects that this is a test file. Therefore, you are able to easily start and debug the tests via the IDE.

image

// for details. 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:firebase_core/firebase_core.dart';
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:tests/firebase_options.dart';
Copy link
Contributor Author

@nilsreichardt nilsreichardt Jun 19, 2022

Choose a reason for hiding this comment

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

Another difference to the Flutter Drivers tests is that I'm using the firebase_options.dart file from the lib instead of copying it again in the integration_test folder (like it has been done in the test_driver folder).


void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('firebase_core', () {
String testAppName = '[DEFAULT]';

setUpAll(() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
});

test('Firebase.apps', () async {
List<FirebaseApp> apps = Firebase.apps;
expect(apps.length, 1);
expect(apps[0].name, testAppName);
expect(apps[0].options, DefaultFirebaseOptions.currentPlatform);
});

test('Firebase.app()', () async {
FirebaseApp app = Firebase.app(testAppName);

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);

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 {
FirebaseApp app = Firebase.app(testAppName);
bool enabled = app.isAutomaticDataCollectionEnabled;

await app.setAutomaticDataCollectionEnabled(!enabled);

expect(app.isAutomaticDataCollectionEnabled, !enabled);
});

test('FirebaseApp.setAutomaticResourceManagementEnabled()', () async {
FirebaseApp app = Firebase.app(testAppName);

await app.setAutomaticResourceManagementEnabled(true);
});
});
}