Skip to content
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

fix(core): move test related files from src to test directory #17023

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/cloud_firestore/cloud_firestore/test/mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_functions/cloud_functions/test/mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import 'package:cloud_functions_platform_interface/src/firebase_functions_exception.dart';
import 'package:cloud_functions_platform_interface/src/method_channel/method_channel_firebase_functions.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

import 'package:firebase_analytics_platform_interface/firebase_analytics_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

import 'package:firebase_analytics_platform_interface/firebase_analytics_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

import 'package:firebase_app_check_platform_interface/firebase_app_check_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:firebase_app_check_platform_interface/firebase_app_check_platform_interface.dart';
import 'package:firebase_app_check_platform_interface/src/method_channel/method_channel_firebase_app_check.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import 'package:firebase_app_installations/firebase_app_installations.dart';
import 'package:firebase_app_installations_platform_interface/firebase_app_installations_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_auth/firebase_auth/test/mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart';
import 'package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart';
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
Copy link
Member

Choose a reason for hiding this comment

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

I think this is why we previously had flutter_test in dependencies as opposed to dev dependencies so we can share it with other packages. But, I don't think this matters because it will be excluded when publishing to pub.dev. Therefore, relative paths should be fine for other packages

Copy link
Member

Choose a reason for hiding this comment

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

Just to double check, I'll see if @Lyokone has any feedback on the matter 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Hum I'm wondering how it will fix the issue, we have not changed anything in the pubspec.yaml?

import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Lyokone, I have done that here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice missed this file :)

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ dependencies:
collection: ^1.0.0
flutter:
sdk: flutter
# Needed to export the mocks
flutter_test:
sdk: flutter
meta: ^1.8.0
plugin_platform_interface: ^2.1.3

dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.4.0
pigeon: 9.2.5
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// found in the LICENSE file.

import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import 'test.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../test.dart';

class MockFirebaseApp implements TestFirebaseCoreHostApi {
@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
// ignore_for_file: avoid_relative_lib_imports
import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart';
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

import 'messages.pigeon.dart';

class _TestFirebaseCoreHostApiCodec extends StandardMessageCodec {
const _TestFirebaseCoreHostApiCodec();
@override
Expand Down Expand Up @@ -47,35 +46,47 @@ abstract class TestFirebaseCoreHostApi {
static const MessageCodec<Object?> codec = _TestFirebaseCoreHostApiCodec();

Future<PigeonInitializeResponse> initializeApp(
String appName, PigeonFirebaseOptions initializeAppRequest);
String appName,
PigeonFirebaseOptions initializeAppRequest,
);

Future<List<PigeonInitializeResponse?>> initializeCore();

Future<PigeonFirebaseOptions> optionsFromResource();

static void setup(TestFirebaseCoreHostApi? api,
{BinaryMessenger? binaryMessenger}) {
static void setup(
TestFirebaseCoreHostApi? api, {
BinaryMessenger? binaryMessenger,
}) {
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp', codec,
binaryMessenger: binaryMessenger);
'dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp',
codec,
binaryMessenger: binaryMessenger,
);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel, null);
} else {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp was null.');
assert(
message != null,
'Argument for dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp was null.',
);
final List<Object?> args = (message as List<Object?>?)!;
final String? arg_appName = (args[0] as String?);
assert(arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp was null, expected non-null String.');
assert(
arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp was null, expected non-null String.',
);
final PigeonFirebaseOptions? arg_initializeAppRequest =
(args[1] as PigeonFirebaseOptions?);
assert(arg_initializeAppRequest != null,
'Argument for dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp was null, expected non-null PigeonFirebaseOptions.');
assert(
arg_initializeAppRequest != null,
'Argument for dev.flutter.pigeon.FirebaseCoreHostApi.initializeApp was null, expected non-null PigeonFirebaseOptions.',
);
final PigeonInitializeResponse output =
await api.initializeApp(arg_appName!, arg_initializeAppRequest!);
return <Object?>[output];
Expand All @@ -84,8 +95,10 @@ abstract class TestFirebaseCoreHostApi {
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FirebaseCoreHostApi.initializeCore', codec,
binaryMessenger: binaryMessenger);
'dev.flutter.pigeon.FirebaseCoreHostApi.initializeCore',
codec,
binaryMessenger: binaryMessenger,
);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel, null);
Expand All @@ -102,8 +115,10 @@ abstract class TestFirebaseCoreHostApi {
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FirebaseCoreHostApi.optionsFromResource', codec,
binaryMessenger: binaryMessenger);
'dev.flutter.pigeon.FirebaseCoreHostApi.optionsFromResource',
codec,
binaryMessenger: binaryMessenger,
);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel, null);
Expand All @@ -128,83 +143,111 @@ abstract class TestFirebaseAppHostApi {
Future<void> setAutomaticDataCollectionEnabled(String appName, bool enabled);

Future<void> setAutomaticResourceManagementEnabled(
String appName, bool enabled);
String appName,
bool enabled,
);

Future<void> delete(String appName);

static void setup(TestFirebaseAppHostApi? api,
{BinaryMessenger? binaryMessenger}) {
static void setup(
TestFirebaseAppHostApi? api, {
BinaryMessenger? binaryMessenger,
}) {
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled',
codec,
binaryMessenger: binaryMessenger);
'dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled',
codec,
binaryMessenger: binaryMessenger,
);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel, null);
} else {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled was null.');
assert(
message != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled was null.',
);
final List<Object?> args = (message as List<Object?>?)!;
final String? arg_appName = (args[0] as String?);
assert(arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled was null, expected non-null String.');
assert(
arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled was null, expected non-null String.',
);
final bool? arg_enabled = (args[1] as bool?);
assert(arg_enabled != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled was null, expected non-null bool.');
assert(
arg_enabled != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticDataCollectionEnabled was null, expected non-null bool.',
);
await api.setAutomaticDataCollectionEnabled(
arg_appName!, arg_enabled!);
arg_appName!,
arg_enabled!,
);
return <Object?>[];
});
}
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled',
codec,
binaryMessenger: binaryMessenger);
'dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled',
codec,
binaryMessenger: binaryMessenger,
);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel, null);
} else {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled was null.');
assert(
message != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled was null.',
);
final List<Object?> args = (message as List<Object?>?)!;
final String? arg_appName = (args[0] as String?);
assert(arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled was null, expected non-null String.');
assert(
arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled was null, expected non-null String.',
);
final bool? arg_enabled = (args[1] as bool?);
assert(arg_enabled != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled was null, expected non-null bool.');
assert(
arg_enabled != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.setAutomaticResourceManagementEnabled was null, expected non-null bool.',
);
await api.setAutomaticResourceManagementEnabled(
arg_appName!, arg_enabled!);
arg_appName!,
arg_enabled!,
);
return <Object?>[];
});
}
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.FirebaseAppHostApi.delete', codec,
binaryMessenger: binaryMessenger);
'dev.flutter.pigeon.FirebaseAppHostApi.delete',
codec,
binaryMessenger: binaryMessenger,
);
if (api == null) {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel, null);
} else {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.delete was null.');
assert(
message != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.delete was null.',
);
final List<Object?> args = (message as List<Object?>?)!;
final String? arg_appName = (args[0] as String?);
assert(arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.delete was null, expected non-null String.');
assert(
arg_appName != null,
'Argument for dev.flutter.pigeon.FirebaseAppHostApi.delete was null, expected non-null String.',
);
await api.delete(arg_appName!);
return <Object?>[];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
library;

export 'package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart';
export 'package:firebase_core_platform_interface/src/pigeon/mocks.dart';
export 'package:firebase_core_platform_interface/src/pigeon/test_api.dart';
export 'pigeon/mocks.dart';
export 'pigeon/test_api.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// found in the LICENSE file.

import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:firebase_crashlytics_platform_interface/firebase_crashlytics_platform_interface.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// found in the LICENSE file.

import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:firebase_crashlytics_platform_interface/src/method_channel/method_channel_crashlytics.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:firebase_core_platform_interface/test.dart';
import '../../../firebase_core/firebase_core_platform_interface/test/test.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Loading
Loading