diff --git a/.github/workflows/e2e_tests.yaml b/.github/workflows/e2e_tests.yaml index fa284b4c49bc..bd662bb647e8 100644 --- a/.github/workflows/e2e_tests.yaml +++ b/.github/workflows/e2e_tests.yaml @@ -7,22 +7,22 @@ concurrency: on: pull_request: paths-ignore: - - "docs/**" - - "website/**" - - "**/example/**" - - "**/flutterfire_ui/**" - - "**/cloud_firestore_odm/**" - - "**.md" + - 'docs/**' + - 'website/**' + - '**/example/**' + - '**/flutterfire_ui/**' + - '**/cloud_firestore_odm/**' + - '**.md' push: branches: - master paths-ignore: - - "docs/**" - - "website/**" - - "**/example/**" - - "**/flutterfire_ui/**" - - "**/cloud_firestore_odm/**" - - "**.md" + - 'docs/**' + - 'website/**' + - '**/example/**' + - '**/flutterfire_ui/**' + - '**/cloud_firestore_odm/**' + - '**.md' jobs: android: @@ -30,17 +30,18 @@ jobs: timeout-minutes: 45 strategy: matrix: - working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example'] + working_directory: + ['tests', 'packages/cloud_firestore/cloud_firestore/example'] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c name: Install Node.js 16 with: - node-version: "16" + node-version: '16' - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 with: - distribution: "temurin" - java-version: "11" + distribution: 'temurin' + java-version: '11' - uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 name: Gradle Cache with: @@ -69,9 +70,9 @@ jobs: with: run-bootstrap: false melos-version: '3.0.1' - - name: "Bootstrap package" + - name: 'Bootstrap package' run: melos bootstrap --scope tests - - name: "Install Tools" + - name: 'Install Tools' run: | sudo npm i -g firebase-tools - name: Start Firebase Emulator @@ -81,37 +82,38 @@ jobs: run: | echo "List installed packages" $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed - + echo "Installing system image" echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-33;google_apis;x86_64" - + echo "Creating AVD" echo "no" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n test_emulator -k "system-images;android-33;google_apis;x86_64" --force echo "Starting emulator" $ANDROID_SDK_ROOT/emulator/emulator -avd test_emulator -no-audio -no-boot-anim -no-window & adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82' - - name: "E2E Tests" + - name: 'E2E Tests' working-directory: ${{ matrix.working_directory }} run: | - flutter test integration_test/e2e_test.dart --dart-define=CI=true + flutter test integration_test/e2e_test.dart --dart-define=CI=true ios: runs-on: macos-13 timeout-minutes: 45 strategy: matrix: - working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example'] + working_directory: + ['tests', 'packages/cloud_firestore/cloud_firestore/example'] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c name: Install Node.js 16 with: - node-version: "16" + node-version: '16' - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 with: - distribution: "temurin" - java-version: "11" + distribution: 'temurin' + java-version: '11' - uses: hendrikmuhs/ccache-action@fba817f3c0db4f854d7a3ee688241d6754da166e name: Xcode Compile Cache with: @@ -138,12 +140,12 @@ jobs: with: run-bootstrap: false melos-version: '3.0.1' - - name: "Bootstrap package" + - name: 'Bootstrap package' run: melos bootstrap --scope tests - - name: "Install Tools" + - name: 'Install Tools' run: | sudo npm i -g firebase-tools - - name: "Build Application" + - name: 'Build Application' working-directory: ${{ matrix.working_directory }} run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" @@ -156,7 +158,7 @@ jobs: ccache -s - name: Start Firebase Emulator run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh - - name: "E2E Tests" + - name: 'E2E Tests' working-directory: ${{ matrix.working_directory }} run: | # Boot simulator and wait for System app to be ready. @@ -178,17 +180,18 @@ jobs: timeout-minutes: 45 strategy: matrix: - working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example'] + working_directory: + ['tests', 'packages/cloud_firestore/cloud_firestore/example'] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c name: Install Node.js 16 with: - node-version: "16" + node-version: '16' - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 with: - distribution: "temurin" - java-version: "11" + distribution: 'temurin' + java-version: '11' - uses: hendrikmuhs/ccache-action@fba817f3c0db4f854d7a3ee688241d6754da166e name: Xcode Compile Cache with: @@ -215,12 +218,12 @@ jobs: with: run-bootstrap: false melos-version: '3.0.1' - - name: "Bootstrap package" + - name: 'Bootstrap package' run: melos bootstrap --scope tests - - name: "Install Tools" + - name: 'Install Tools' run: | sudo npm i -g firebase-tools - - name: "Build Application" + - name: 'Build Application' working-directory: ${{ matrix.working_directory }} run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" @@ -233,7 +236,7 @@ jobs: ccache -s - name: Start Firebase Emulator run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh - - name: "E2E Tests" + - name: 'E2E Tests' working-directory: ${{ matrix.working_directory }} run: | flutter test \ @@ -246,17 +249,18 @@ jobs: timeout-minutes: 15 strategy: matrix: - working_directory: ['tests', 'packages/cloud_firestore/cloud_firestore/example'] + working_directory: + ['tests', 'packages/cloud_firestore/cloud_firestore/example'] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c name: Install Node.js 16 with: - node-version: "16" + node-version: '16' - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 with: - distribution: "temurin" - java-version: "11" + distribution: 'temurin' + java-version: '11' - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d with: channel: 'stable' @@ -265,9 +269,9 @@ jobs: with: run-bootstrap: false melos-version: '3.0.1' - - name: "Bootstrap package" + - name: 'Bootstrap package' run: melos bootstrap --scope tests - - name: "Install Tools" + - name: 'Install Tools' run: | sudo npm i -g firebase-tools - name: Cache Firebase Emulator @@ -278,7 +282,7 @@ jobs: restore-keys: firebase-emulators-v1 - name: Start Firebase Emulator run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh - - name: "E2E Tests" + - name: 'E2E Tests' working-directory: ${{ matrix.working_directory }} # Web devices are not supported for the `flutter test` command yet. As a # workaround we can use the `flutter drive` command. Tracking issue: diff --git a/.github/workflows/firebase_firestore_odm.yaml b/.github/workflows/firebase_firestore_odm.yaml index 24444046b32c..db044852862c 100644 --- a/.github/workflows/firebase_firestore_odm.yaml +++ b/.github/workflows/firebase_firestore_odm.yaml @@ -7,19 +7,19 @@ concurrency: on: pull_request: paths: - - "packages/cloud_firestore/**" - - "packages/cloud_firestore_odm/**" - - ".github/workflows/firebase_firestore_odm.yaml" + - 'packages/cloud_firestore/**' + - 'packages/cloud_firestore_odm/**' + - '.github/workflows/firebase_firestore_odm.yaml' push: branches: - master paths-ignore: - - "docs/**" - - "**.md" + - 'docs/**' + - '**.md' env: - FLUTTERFIRE_PLUGIN_SCOPE: "*cloud_firestore*" - FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE: "*cloud_firestore_odm_example*" + FLUTTERFIRE_PLUGIN_SCOPE: '*cloud_firestore*' + FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE: '*cloud_firestore_odm_example*' jobs: test: @@ -37,14 +37,14 @@ jobs: with: run-bootstrap: false melos-version: '3.0.1' - - name: "Bootstrap Workspace" + - name: 'Bootstrap Workspace' run: | melos bootstrap --scope="*firebase_core*" --scope="$FLUTTERFIRE_PLUGIN_SCOPE" melos run odm:example_build_runner:build melos run odm:generator_test_build_runner:build - - name: "Flutter Test" + - name: 'Flutter Test' run: melos run odm:test:flutter --no-select - - name: "Dart Test" + - name: 'Dart Test' run: melos run odm:test:dart --no-select integration_test: @@ -57,7 +57,7 @@ jobs: - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c name: Install Node.js 16 with: - node-version: "16" + node-version: '16' - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 with: distribution: 'temurin' @@ -70,17 +70,17 @@ jobs: with: run-bootstrap: false melos-version: '3.0.1' - - name: "Install Tools" + - name: 'Install Tools' run: | sudo npm i -g firebase-tools - - name: "Bootstrap Workspace" + - name: 'Bootstrap Workspace' run: | melos bootstrap --scope="*firebase_core*" --scope="$FLUTTERFIRE_PLUGIN_SCOPE" melos run odm:example_build_runner:build melos run odm:generator_test_build_runner:build - name: Start Firebase Emulator run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh - - name: "E2E Tests" + - name: 'E2E Tests' working-directory: packages/cloud_firestore_odm/cloud_firestore_odm/example # Web devices are not supported for the `flutter test` command yet. As a # workaround we can use the `flutter drive` command. Tracking issue: diff --git a/packages/_flutterfire_internals/pubspec.yaml b/packages/_flutterfire_internals/pubspec.yaml index 4372edab1c2d..bb00c7456bc3 100755 --- a/packages/_flutterfire_internals/pubspec.yaml +++ b/packages/_flutterfire_internals/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: firebase_core_platform_interface: ^4.6.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: flutter_test: diff --git a/packages/cloud_firestore/cloud_firestore/pubspec.yaml b/packages/cloud_firestore/cloud_firestore/pubspec.yaml index ca8d58be842d..a78d198d8368 100755 --- a/packages/cloud_firestore/cloud_firestore/pubspec.yaml +++ b/packages/cloud_firestore/cloud_firestore/pubspec.yaml @@ -11,8 +11,8 @@ false_secrets: - dartpad/** environment: - sdk: ">=2.18.0 <3.0.0" - flutter: ">=1.12.13+hotfix.5" + sdk: '>=2.18.0 <3.0.0' + flutter: '>=1.12.13+hotfix.5' dependencies: cloud_firestore_platform_interface: ^5.12.1 @@ -22,7 +22,7 @@ dependencies: firebase_core_platform_interface: ^4.6.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: flutter_test: diff --git a/packages/cloud_firestore/cloud_firestore/test/aggregate_query_test.dart b/packages/cloud_firestore/cloud_firestore/test/aggregate_query_test.dart index f34936909aee..f33ee993ef3a 100644 --- a/packages/cloud_firestore/cloud_firestore/test/aggregate_query_test.dart +++ b/packages/cloud_firestore/cloud_firestore/test/aggregate_query_test.dart @@ -7,8 +7,8 @@ import 'package:cloud_firestore_platform_interface/src/method_channel/method_cha import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_query.dart'; import 'package:cloud_firestore_platform_interface/src/method_channel/utils/firestore_message_codec.dart'; import 'package:firebase_core/firebase_core.dart'; -import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; import './mock.dart'; @@ -21,7 +21,9 @@ void main() { StandardMethodCodec(AggregateQueryMessageCodec()), ); - MethodChannelFirebaseFirestore.channel.setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel, + (call) async { if (call.method == 'AggregateQuery#count') { return { 'count': kCount, diff --git a/packages/cloud_firestore/cloud_firestore/test/document_reference_test.dart b/packages/cloud_firestore/cloud_firestore/test/document_reference_test.dart index c5003752a64c..15d2bc0c3b40 100644 --- a/packages/cloud_firestore/cloud_firestore/test/document_reference_test.dart +++ b/packages/cloud_firestore/cloud_firestore/test/document_reference_test.dart @@ -3,8 +3,8 @@ // BSD-style license that can be found in the LICENSE file. import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:firebase_core/firebase_core.dart'; import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -16,9 +16,14 @@ void main() { MethodChannelFirebaseFirestore.channel = const MethodChannel( 'plugins.flutter.io/firebase_firestore', StandardMethodCodec(TestFirestoreMessageCodec()), - )..setMockMethodCallHandler((call) async { - return null; - }); + ); + + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel, + (call) async { + return null; + }); + late FirebaseFirestore firestore; late FirebaseFirestore firestoreSecondary; diff --git a/packages/cloud_firestore/cloud_firestore/test/document_snapshot_test.dart b/packages/cloud_firestore/cloud_firestore/test/document_snapshot_test.dart index dc380b7aa4b0..89c24ebd524a 100644 --- a/packages/cloud_firestore/cloud_firestore/test/document_snapshot_test.dart +++ b/packages/cloud_firestore/cloud_firestore/test/document_snapshot_test.dart @@ -6,8 +6,8 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart'; import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart'; import 'package:firebase_core/firebase_core.dart'; -import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; import './mock.dart'; import './test_firestore_message_codec.dart'; @@ -19,7 +19,9 @@ void main() { StandardMethodCodec(TestFirestoreMessageCodec()), ); - MethodChannelFirebaseFirestore.channel.setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel, + (call) async { DocumentReferencePlatform ref = call.arguments['reference']; if (call.method == 'DocumentReference#get' && ref.path == 'doc/exists') { return { diff --git a/packages/cloud_firestore/cloud_firestore/test/write_batch_test.dart b/packages/cloud_firestore/cloud_firestore/test/write_batch_test.dart index 00b1a15acab0..ad701bcdf001 100644 --- a/packages/cloud_firestore/cloud_firestore/test/write_batch_test.dart +++ b/packages/cloud_firestore/cloud_firestore/test/write_batch_test.dart @@ -14,7 +14,9 @@ void main() { FirebaseFirestore? firestore; FirebaseFirestore? firestoreSecondary; - MethodChannelFirebaseFirestore.channel.setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel, + (call) async { String path = call.arguments['path']; if (call.method == 'DocumentReference#get' && path == 'doc/exists') { diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/utils/firestore_message_codec.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/utils/firestore_message_codec.dart index 658bdda3f4b7..9e62b4122935 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/utils/firestore_message_codec.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/utils/firestore_message_codec.dart @@ -111,7 +111,7 @@ class FirestoreMessageCodec extends StandardMessageCodec { writeValue(buffer, value.asMap); } else if (value is Iterable && value is! List) { super.writeValue(buffer, value.toList()); - } else if (value == double.nan) { + } else if (value is double && value.isNaN) { buffer.putUint8(_kNaN); } else if (value == double.infinity) { buffer.putUint8(_kInfinity); diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/pubspec.yaml b/packages/cloud_firestore/cloud_firestore_platform_interface/pubspec.yaml index 38fddedf820f..95f42df9d6c9 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/pubspec.yaml +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_document_reference_test.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_document_reference_test.dart index a97087f2e8ae..42cff090434d 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_document_reference_test.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_document_reference_test.dart @@ -94,7 +94,7 @@ void main() { log.add(call); if (call.method == 'DocumentReference#snapshots') { handleDocumentSnapshotsEventChannel(mockObserverId, log); - return Future.value(mockObserverId); + return mockObserverId; } }); }); diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_query_test.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_query_test.dart index a1165e29c56a..a973f201b9b7 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_query_test.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/test/method_channel_tests/method_channel_query_test.dart @@ -122,8 +122,9 @@ void main() { }); group('get()', () { setUp(() async { - MethodChannelFirebaseFirestore.channel - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel, + (MethodCall methodCall) async { switch (methodCall.method) { case 'Query#get': MethodChannelQuery query = methodCall.arguments['query']; diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/test/utils/test_common.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/test/utils/test_common.dart index 00e23550932d..c23b7d952458 100644 --- a/packages/cloud_firestore/cloud_firestore_platform_interface/test/utils/test_common.dart +++ b/packages/cloud_firestore/cloud_firestore_platform_interface/test/utils/test_common.dart @@ -40,8 +40,9 @@ void initializeMethodChannel() { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseFirestore.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseFirestore.channel, + (call) async { return await methodCallCallback(call); }); @@ -50,12 +51,13 @@ void handleDocumentSnapshotsEventChannel( final name = 'plugins.flutter.io/firebase_firestore/document/$id'; const codec = StandardMethodCodec(TestFirestoreMessageCodec()); - MethodChannel(name, codec) - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannel(name, codec), + (MethodCall methodCall) async { log.add(methodCall); switch (methodCall.method) { case 'listen': - await ServicesBinding.instance.defaultBinaryMessenger + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( name, codec.encodeSuccessEnvelope( @@ -74,6 +76,7 @@ void handleDocumentSnapshotsEventChannel( default: return null; } + return null; }); } @@ -81,12 +84,13 @@ void handleQuerySnapshotsEventChannel(final String id, List log) { final name = 'plugins.flutter.io/firebase_firestore/query/$id'; const codec = StandardMethodCodec(TestFirestoreMessageCodec()); - MethodChannel(name, codec) - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannel(name, codec), + (MethodCall methodCall) async { log.add(methodCall); switch (methodCall.method) { case 'listen': - await ServicesBinding.instance.defaultBinaryMessenger + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( name, codec.encodeSuccessEnvelope( @@ -105,6 +109,7 @@ void handleQuerySnapshotsEventChannel(final String id, List log) { default: return null; } + return null; }); } @@ -112,11 +117,12 @@ void handleSnapshotsInSyncEventChannel(final String id) { final name = 'plugins.flutter.io/firebase_firestore/snapshotsInSync/$id'; const codec = StandardMethodCodec(TestFirestoreMessageCodec()); - MethodChannel(name, codec) - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannel(name, codec), + (MethodCall methodCall) async { switch (methodCall.method) { case 'listen': - await ServicesBinding.instance.defaultBinaryMessenger + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( name, codec.encodeSuccessEnvelope({}), (_) {}); break; @@ -124,6 +130,7 @@ void handleSnapshotsInSyncEventChannel(final String id) { default: return null; } + return null; }); } @@ -135,11 +142,12 @@ void handleTransactionEventChannel( final name = 'plugins.flutter.io/firebase_firestore/transaction/$id'; const codec = StandardMethodCodec(TestFirestoreMessageCodec()); - MethodChannel(name, codec) - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannel(name, codec), + (MethodCall methodCall) async { switch (methodCall.method) { case 'listen': - await ServicesBinding.instance.defaultBinaryMessenger + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( name, codec.encodeSuccessEnvelope({ @@ -149,11 +157,12 @@ void handleTransactionEventChannel( ); if (throwException!) { - await ServicesBinding.instance.defaultBinaryMessenger + await TestDefaultBinaryMessengerBinding + .instance?.defaultBinaryMessenger .handlePlatformMessage( name, codec.encodeSuccessEnvelope({ - 'appName': app.name, + 'appName': app?.name, 'error': { 'code': 'unknown', }, @@ -161,7 +170,7 @@ void handleTransactionEventChannel( (_) {}, ); } - await ServicesBinding.instance.defaultBinaryMessenger + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( name, codec.encodeSuccessEnvelope({ @@ -175,5 +184,6 @@ void handleTransactionEventChannel( default: return null; } + return null; }); } diff --git a/packages/cloud_firestore_odm/analysis_options.yaml b/packages/cloud_firestore_odm/analysis_options.yaml index 8aa2ce5c8686..1f0da4bf6695 100644 --- a/packages/cloud_firestore_odm/analysis_options.yaml +++ b/packages/cloud_firestore_odm/analysis_options.yaml @@ -16,9 +16,7 @@ include: all_lint_rules.yaml analyzer: - strong-mode: - implicit-casts: false - implicit-dynamic: false + strict-casts: true errors: # So we can run ODM dart tests in the melos workspace - otherwise dart test will # source the ODM package from pub - which won't have the local changes @@ -30,8 +28,8 @@ analyzer: # in this file included_file_warning: ignore exclude: - - "**.freezed.dart" - - "**.g.dart" + - '**.freezed.dart' + - '**.g.dart' linter: rules: diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/freezed.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/freezed.dart index 4e4f34bc134d..4453f8be6a69 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/freezed.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/freezed.dart @@ -18,7 +18,7 @@ class Person with _$Person { factory Person({ required String firstName, @JsonKey(name: 'LAST_NAME') required String lastName, - @JsonKey(ignore: true) int? ignored, + @JsonKey(includeFromJson: false, includeToJson: false) int? ignored, }) = _Person; factory Person.fromJson(Map json) => _$PersonFromJson(json); diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/pubspec.yaml b/packages/cloud_firestore_odm/cloud_firestore_odm/example/pubspec.yaml index 86adcfd94a99..85de81628d23 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/pubspec.yaml +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/pubspec.yaml @@ -11,9 +11,9 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - freezed_annotation: ^2.0.0 - json_annotation: ^4.6.0 - meta: ^1.3.0 + freezed_annotation: ^2.2.0 + json_annotation: ^4.8.0 + meta: ^1.8.0 dev_dependencies: build_runner: ^2.0.0 @@ -21,11 +21,11 @@ dev_dependencies: cloud_firestore_odm_generator_integration_test: any flutter_test: sdk: flutter - freezed: ^2.0.0 + freezed: ^2.3.2 http: ^0.13.5 integration_test: sdk: flutter - json_serializable: ^6.3.0 + json_serializable: ^6.6.1 mockito: ^5.0.0 flutter: diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml index 75b0e309fd4a..7d7928f5a0ba 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: flutter: sdk: flutter json_annotation: ^4.5.0 - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: flutter_test: diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart index 4e4f34bc134d..4453f8be6a69 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart @@ -18,7 +18,7 @@ class Person with _$Person { factory Person({ required String firstName, @JsonKey(name: 'LAST_NAME') required String lastName, - @JsonKey(ignore: true) int? ignored, + @JsonKey(includeFromJson: false, includeToJson: false) int? ignored, }) = _Person; factory Person.fromJson(Map json) => _$PersonFromJson(json); diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml index 7937c1144a1e..c82080285fb5 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml @@ -10,17 +10,17 @@ dependencies: cloud_firestore_odm: ^1.0.0-dev.56 flutter: sdk: flutter - freezed_annotation: ^2.0.0 - json_annotation: ^4.6.0 - meta: ^1.3.0 + freezed_annotation: ^2.2.0 + json_annotation: ^4.8.0 + meta: ^1.8.0 dev_dependencies: build_runner: ^2.0.0 cloud_firestore_odm_generator: ^1.0.0-dev.56 flutter_test: sdk: flutter - freezed: ^2.0.0 - json_serializable: '>=6.3.0 <7.0.0' + freezed: ^2.3.2 + json_serializable: '>=6.6.1 <7.0.0' flutter: uses-material-design: false diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart index 8d89d25aac0b..8198d4f1d6a8 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -457,8 +457,13 @@ extension on Element { final jsonKeys = checker.annotationsOf(this); for (final jsonKey in jsonKeys) { - final ignore = jsonKey.getField('ignore')?.toBoolValue(); - if (ignore ?? false) { + final ignore = jsonKey.getField('ignore')?.toBoolValue() ?? false; + + // ignore is deprecated in favor of includeFromJson and includeToJson + final jsonIncluded = + (jsonKey.getField('includeFromJson')?.toBoolValue() ?? true) && + (jsonKey.getField('includeToJson')?.toBoolValue() ?? true); + if (ignore || !jsonIncluded) { return true; } } diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/pubspec.yaml b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/pubspec.yaml index b03a290dbabd..40c6f4ffc59c 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: collection: ^1.15.0 freezed_annotation: '>=1.0.0 <3.0.0' json_annotation: ^4.6.0 - meta: ^1.3.0 + meta: ^1.8.0 recase: ^4.0.0 source_gen: ^1.0.0 diff --git a/packages/cloud_functions/cloud_functions/example/pubspec.yaml b/packages/cloud_functions/cloud_functions/example/pubspec.yaml index aa7d80bfbee6..df7419a27f73 100644 --- a/packages/cloud_functions/cloud_functions/example/pubspec.yaml +++ b/packages/cloud_functions/cloud_functions/example/pubspec.yaml @@ -7,7 +7,6 @@ environment: dependencies: cloud_functions: ^4.1.1 - cupertino_icons: ^0.1.2 firebase_core: ^2.10.0 flutter: sdk: flutter diff --git a/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml b/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml index 45bbb3335fc7..038746984bbd 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml +++ b/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/cloud_functions/cloud_functions_platform_interface/test/mock.dart b/packages/cloud_functions/cloud_functions_platform_interface/test/mock.dart index ea76d17f07d6..5bf97bb76c4c 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/test/mock.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/test/mock.dart @@ -22,8 +22,9 @@ void setupFirebaseFunctionsMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseFunctions.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseFunctions.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_analytics/firebase_analytics/test/mock.dart b/packages/firebase_analytics/firebase_analytics/test/mock.dart index e17dc24d4d25..71ee6723ace5 100644 --- a/packages/firebase_analytics/firebase_analytics/test/mock.dart +++ b/packages/firebase_analytics/firebase_analytics/test/mock.dart @@ -16,8 +16,9 @@ void setupFirebaseAnalyticsMocks([Callback? customHandlers]) { setupFirebaseCoreMocks(); - MethodChannelFirebaseAnalytics.channel - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAnalytics.channel, + (MethodCall methodCall) async { methodCallLog.add(methodCall); switch (methodCall.method) { case 'Analytics#getAppInstanceId': diff --git a/packages/firebase_analytics/firebase_analytics_platform_interface/pubspec.yaml b/packages/firebase_analytics/firebase_analytics_platform_interface/pubspec.yaml index ef16cd6018da..169924899393 100644 --- a/packages/firebase_analytics/firebase_analytics_platform_interface/pubspec.yaml +++ b/packages/firebase_analytics/firebase_analytics_platform_interface/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_analytics/firebase_analytics_platform_interface/test/mock.dart b/packages/firebase_analytics/firebase_analytics_platform_interface/test/mock.dart index 669fbc048abf..5a5150d3bd11 100644 --- a/packages/firebase_analytics/firebase_analytics_platform_interface/test/mock.dart +++ b/packages/firebase_analytics/firebase_analytics_platform_interface/test/mock.dart @@ -17,8 +17,9 @@ void setupFirebaseAnalyticsMocks([Callback? customHandlers]) { setupFirebaseCoreMocks(); - MethodChannelFirebaseAnalytics.channel - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAnalytics.channel, + (MethodCall methodCall) async { methodCallLog.add(methodCall); switch (methodCall.method) { case 'Analytics#getAppInstanceId': @@ -31,7 +32,8 @@ void setupFirebaseAnalyticsMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseAnalytics.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAnalytics.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_analytics/firebase_analytics_web/pubspec.yaml b/packages/firebase_analytics/firebase_analytics_web/pubspec.yaml index e87fc80bc48c..1cd12c496815 100644 --- a/packages/firebase_analytics/firebase_analytics_web/pubspec.yaml +++ b/packages/firebase_analytics/firebase_analytics_web/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: js: ^0.6.3 dev_dependencies: + build_runner: ^2.3.3 flutter_test: sdk: flutter mockito: ^5.0.0 diff --git a/packages/firebase_analytics/firebase_analytics_web/test/firebase_analytics_web_test.dart b/packages/firebase_analytics/firebase_analytics_web/test/firebase_analytics_web_test.dart index 6d1972a50ea1..48e0c7317c9b 100644 --- a/packages/firebase_analytics/firebase_analytics_web/test/firebase_analytics_web_test.dart +++ b/packages/firebase_analytics/firebase_analytics_web/test/firebase_analytics_web_test.dart @@ -5,17 +5,19 @@ import 'package:firebase_analytics_web/firebase_analytics_web.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -class MockAnalytics extends Mock implements FirebaseAnalyticsWeb {} +@GenerateNiceMocks([MockSpec()]) +import 'firebase_analytics_web_test.mocks.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('$FirebaseAnalyticsWeb', () { - late MockAnalytics analytics; + late MockFirebaseAnalyticsWeb analytics; setUp(() { - analytics = MockAnalytics(); + analytics = MockFirebaseAnalyticsWeb(); }); test('logEvent', () { diff --git a/packages/firebase_analytics/firebase_analytics_web/test/firebase_analytics_web_test.mocks.dart b/packages/firebase_analytics/firebase_analytics_web/test/firebase_analytics_web_test.mocks.dart new file mode 100644 index 000000000000..a8ebf4bd8d12 --- /dev/null +++ b/packages/firebase_analytics/firebase_analytics_web/test/firebase_analytics_web_test.mocks.dart @@ -0,0 +1,248 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Mocks generated by Mockito 5.4.0 from annotations +// in firebase_analytics_web/test/firebase_analytics_web_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i5; + +import 'package:firebase_analytics_platform_interface/firebase_analytics_platform_interface.dart' + as _i3; +import 'package:firebase_analytics_web/firebase_analytics_web.dart' as _i4; +import 'package:firebase_core/firebase_core.dart' as _i2; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeFirebaseApp_0 extends _i1.SmartFake implements _i2.FirebaseApp { + _FakeFirebaseApp_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFirebaseAnalyticsPlatform_1 extends _i1.SmartFake + implements _i3.FirebaseAnalyticsPlatform { + _FakeFirebaseAnalyticsPlatform_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [FirebaseAnalyticsWeb]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFirebaseAnalyticsWeb extends _i1.Mock + implements _i4.FirebaseAnalyticsWeb { + @override + set appInstance(_i2.FirebaseApp? _appInstance) => super.noSuchMethod( + Invocation.setter( + #appInstance, + _appInstance, + ), + returnValueForMissingStub: null, + ); + @override + _i2.FirebaseApp get app => (super.noSuchMethod( + Invocation.getter(#app), + returnValue: _FakeFirebaseApp_0( + this, + Invocation.getter(#app), + ), + returnValueForMissingStub: _FakeFirebaseApp_0( + this, + Invocation.getter(#app), + ), + ) as _i2.FirebaseApp); + @override + _i3.FirebaseAnalyticsPlatform delegateFor({_i2.FirebaseApp? app}) => + (super.noSuchMethod( + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + returnValue: _FakeFirebaseAnalyticsPlatform_1( + this, + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + ), + returnValueForMissingStub: _FakeFirebaseAnalyticsPlatform_1( + this, + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + ), + ) as _i3.FirebaseAnalyticsPlatform); + @override + _i5.Future isSupported() => (super.noSuchMethod( + Invocation.method( + #isSupported, + [], + ), + returnValue: _i5.Future.value(false), + returnValueForMissingStub: _i5.Future.value(false), + ) as _i5.Future); + @override + _i5.Future logEvent({ + required String? name, + Map? parameters, + _i3.AnalyticsCallOptions? callOptions, + }) => + (super.noSuchMethod( + Invocation.method( + #logEvent, + [], + { + #name: name, + #parameters: parameters, + #callOptions: callOptions, + }, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setConsent({ + bool? adStorageConsentGranted, + bool? analyticsStorageConsentGranted, + }) => + (super.noSuchMethod( + Invocation.method( + #setConsent, + [], + { + #adStorageConsentGranted: adStorageConsentGranted, + #analyticsStorageConsentGranted: analyticsStorageConsentGranted, + }, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setAnalyticsCollectionEnabled(bool? enabled) => + (super.noSuchMethod( + Invocation.method( + #setAnalyticsCollectionEnabled, + [enabled], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setUserId({ + String? id, + _i3.AnalyticsCallOptions? callOptions, + }) => + (super.noSuchMethod( + Invocation.method( + #setUserId, + [], + { + #id: id, + #callOptions: callOptions, + }, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setCurrentScreen({ + String? screenName, + String? screenClassOverride, + _i3.AnalyticsCallOptions? callOptions, + }) => + (super.noSuchMethod( + Invocation.method( + #setCurrentScreen, + [], + { + #screenName: screenName, + #screenClassOverride: screenClassOverride, + #callOptions: callOptions, + }, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future resetAnalyticsData() => (super.noSuchMethod( + Invocation.method( + #resetAnalyticsData, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setUserProperty({ + required String? name, + required String? value, + _i3.AnalyticsCallOptions? callOptions, + }) => + (super.noSuchMethod( + Invocation.method( + #setUserProperty, + [], + { + #name: name, + #value: value, + #callOptions: callOptions, + }, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setSessionTimeoutDuration(Duration? timeout) => + (super.noSuchMethod( + Invocation.method( + #setSessionTimeoutDuration, + [timeout], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setDefaultEventParameters( + Map? defaultParameters) => + (super.noSuchMethod( + Invocation.method( + #setDefaultEventParameters, + [defaultParameters], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future getAppInstanceId() => (super.noSuchMethod( + Invocation.method( + #getAppInstanceId, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); +} diff --git a/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml b/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml index f9ddeacab025..144ed04fb512 100644 --- a/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml +++ b/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml @@ -10,7 +10,6 @@ environment: dependencies: cloud_firestore: ^4.5.3 - cupertino_icons: ^0.1.2 firebase_app_check: ^0.1.2+3 firebase_core: ^2.10.0 flutter: diff --git a/packages/firebase_app_check/firebase_app_check/test/mock.dart b/packages/firebase_app_check/firebase_app_check/test/mock.dart index d4eb22498512..ecb308fa5bd3 100644 --- a/packages/firebase_app_check/firebase_app_check/test/mock.dart +++ b/packages/firebase_app_check/firebase_app_check/test/mock.dart @@ -16,8 +16,9 @@ void setupFirebaseAppCheckMocks([Callback? customHandlers]) { setupFirebaseCoreMocks(); - MethodChannelFirebaseAppCheck.channel - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAppCheck.channel, + (MethodCall methodCall) async { if (methodCall.method != 'FirebaseAppCheck#registerTokenListener') { methodCallLog.add(methodCall); } diff --git a/packages/firebase_app_check/firebase_app_check_platform_interface/pubspec.yaml b/packages/firebase_app_check/firebase_app_check_platform_interface/pubspec.yaml index acbd4614f427..a1de7b733a95 100644 --- a/packages/firebase_app_check/firebase_app_check_platform_interface/pubspec.yaml +++ b/packages/firebase_app_check/firebase_app_check_platform_interface/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_app_check/firebase_app_check_platform_interface/test/mock.dart b/packages/firebase_app_check/firebase_app_check_platform_interface/test/mock.dart index 4ed6f1533489..836e5ac40f8b 100644 --- a/packages/firebase_app_check/firebase_app_check_platform_interface/test/mock.dart +++ b/packages/firebase_app_check/firebase_app_check_platform_interface/test/mock.dart @@ -18,8 +18,9 @@ void setupFirebaseAppCheckMocks([Callback? customHandlers]) { setupFirebaseCoreMocks(); - MethodChannelFirebaseAppCheck.channel - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAppCheck.channel, + (MethodCall methodCall) async { methodCallLog.add(methodCall); switch (methodCall.method) { default: @@ -29,7 +30,8 @@ void setupFirebaseAppCheckMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseAppCheck.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAppCheck.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml b/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml index 0189d9ff666d..9ed1509c0b38 100644 --- a/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml +++ b/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml @@ -19,6 +19,7 @@ dependencies: js: ^0.6.3 dev_dependencies: + build_runner: ^2.3.3 firebase_app_check: ^0.1.2+3 firebase_core_platform_interface: ^4.6.0 flutter_test: diff --git a/packages/firebase_app_check/firebase_app_check_web/test/firebase_app_check_web_test.dart b/packages/firebase_app_check/firebase_app_check_web/test/firebase_app_check_web_test.dart index 6e466fdc0e76..f63ea65936d7 100644 --- a/packages/firebase_app_check/firebase_app_check_web/test/firebase_app_check_web_test.dart +++ b/packages/firebase_app_check/firebase_app_check_web/test/firebase_app_check_web_test.dart @@ -5,17 +5,19 @@ import 'package:firebase_app_check_web/firebase_app_check_web.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -class MockFirebaseAppCheck extends Mock implements FirebaseAppCheckWeb {} +@GenerateNiceMocks([MockSpec()]) +import 'firebase_app_check_web_test.mocks.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('$FirebaseAppCheckWeb', () { - late MockFirebaseAppCheck appCheck; + late MockFirebaseAppCheckWeb appCheck; setUp(() { - appCheck = MockFirebaseAppCheck(); + appCheck = MockFirebaseAppCheckWeb(); }); test('instance', () { diff --git a/packages/firebase_app_check/firebase_app_check_web/test/firebase_app_check_web_test.mocks.dart b/packages/firebase_app_check/firebase_app_check_web/test/firebase_app_check_web_test.mocks.dart new file mode 100644 index 000000000000..4cc27eabeacf --- /dev/null +++ b/packages/firebase_app_check/firebase_app_check_web/test/firebase_app_check_web_test.mocks.dart @@ -0,0 +1,168 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Mocks generated by Mockito 5.4.0 from annotations +// in firebase_app_check_web/test/firebase_app_check_web_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i5; + +import 'package:firebase_app_check_platform_interface/firebase_app_check_platform_interface.dart' + as _i3; +import 'package:firebase_app_check_web/firebase_app_check_web.dart' as _i4; +import 'package:firebase_core/firebase_core.dart' as _i2; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeFirebaseApp_0 extends _i1.SmartFake implements _i2.FirebaseApp { + _FakeFirebaseApp_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFirebaseAppCheckPlatform_1 extends _i1.SmartFake + implements _i3.FirebaseAppCheckPlatform { + _FakeFirebaseAppCheckPlatform_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFirebaseAppCheckWeb_2 extends _i1.SmartFake + implements _i4.FirebaseAppCheckWeb { + _FakeFirebaseAppCheckWeb_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [FirebaseAppCheckWeb]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFirebaseAppCheckWeb extends _i1.Mock + implements _i4.FirebaseAppCheckWeb { + @override + _i5.Stream get onTokenChange => (super.noSuchMethod( + Invocation.getter(#onTokenChange), + returnValue: _i5.Stream.empty(), + returnValueForMissingStub: _i5.Stream.empty(), + ) as _i5.Stream); + @override + _i2.FirebaseApp get app => (super.noSuchMethod( + Invocation.getter(#app), + returnValue: _FakeFirebaseApp_0( + this, + Invocation.getter(#app), + ), + returnValueForMissingStub: _FakeFirebaseApp_0( + this, + Invocation.getter(#app), + ), + ) as _i2.FirebaseApp); + @override + _i3.FirebaseAppCheckPlatform delegateFor({required _i2.FirebaseApp? app}) => + (super.noSuchMethod( + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + returnValue: _FakeFirebaseAppCheckPlatform_1( + this, + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + ), + returnValueForMissingStub: _FakeFirebaseAppCheckPlatform_1( + this, + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + ), + ) as _i3.FirebaseAppCheckPlatform); + @override + _i4.FirebaseAppCheckWeb setInitialValues() => (super.noSuchMethod( + Invocation.method( + #setInitialValues, + [], + ), + returnValue: _FakeFirebaseAppCheckWeb_2( + this, + Invocation.method( + #setInitialValues, + [], + ), + ), + returnValueForMissingStub: _FakeFirebaseAppCheckWeb_2( + this, + Invocation.method( + #setInitialValues, + [], + ), + ), + ) as _i4.FirebaseAppCheckWeb); + @override + _i5.Future activate({ + String? webRecaptchaSiteKey, + _i3.AndroidProvider? androidProvider, + _i3.AppleProvider? appleProvider, + }) => + (super.noSuchMethod( + Invocation.method( + #activate, + [], + { + #webRecaptchaSiteKey: webRecaptchaSiteKey, + #androidProvider: androidProvider, + #appleProvider: appleProvider, + }, + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future getToken(bool? forceRefresh) => (super.noSuchMethod( + Invocation.method( + #getToken, + [forceRefresh], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setTokenAutoRefreshEnabled( + bool? isTokenAutoRefreshEnabled) => + (super.noSuchMethod( + Invocation.method( + #setTokenAutoRefreshEnabled, + [isTokenAutoRefreshEnabled], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); +} diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml index 613dbb0469fc..ad7db455d9fe 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_auth/firebase_auth/pubspec.yaml b/packages/firebase_auth/firebase_auth/pubspec.yaml index d1b1bc22ad43..2220e8a2832b 100755 --- a/packages/firebase_auth/firebase_auth/pubspec.yaml +++ b/packages/firebase_auth/firebase_auth/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: firebase_core_platform_interface: ^4.6.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: async: ^2.5.0 diff --git a/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart b/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart index 0b16e535cdbf..b242dac2c1ce 100644 --- a/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart +++ b/packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart @@ -171,7 +171,9 @@ void main() { when(mockAuthPlatform.userChanges()).thenAnswer((_) => Stream.fromIterable([mockUserPlatform!])); - MethodChannelFirebaseAuth.channel.setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAuth.channel, + (call) async { return {'user': user}; }); }); diff --git a/packages/firebase_auth/firebase_auth/test/user_test.dart b/packages/firebase_auth/firebase_auth/test/user_test.dart index fc4a6d203c0f..def2c50a235b 100644 --- a/packages/firebase_auth/firebase_auth/test/user_test.dart +++ b/packages/firebase_auth/firebase_auth/test/user_test.dart @@ -130,7 +130,9 @@ void main() { languageCode: anyNamed('languageCode'), )).thenAnswer((_) => mockAuthPlatform); - MethodChannelFirebaseAuth.channel.setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAuth.channel, + (call) async { switch (call.method) { default: return {'user': user}; diff --git a/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml b/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml index bacca142fdb5..12a20a991f74 100644 --- a/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml +++ b/packages/firebase_auth/firebase_auth_platform_interface/pubspec.yaml @@ -16,12 +16,12 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: firebase_core_platform_interface: ^4.6.0 flutter_test: sdk: flutter - mockito: ^5.0.0 - pigeon: ^3.2.0 + mockito: ^5.4.0 + pigeon: ^9.2.5 diff --git a/packages/firebase_auth/firebase_auth_platform_interface/test/mock.dart b/packages/firebase_auth/firebase_auth_platform_interface/test/mock.dart index 486d5832733b..ff92d05760a8 100644 --- a/packages/firebase_auth/firebase_auth_platform_interface/test/mock.dart +++ b/packages/firebase_auth/firebase_auth_platform_interface/test/mock.dart @@ -27,7 +27,9 @@ void handleEventChannel( final String name, [ List? log, ]) { - MethodChannel(name).setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannel(name), + (MethodCall methodCall) async { log?.add(methodCall); switch (methodCall.method) { case 'listen': @@ -36,6 +38,7 @@ void handleEventChannel( default: return null; } + return null; }); } @@ -43,7 +46,8 @@ Future injectEventChannelResponse( String channelName, Map event, ) async { - await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .handlePlatformMessage( channelName, MethodChannelFirebaseAuth.channel.codec.encodeSuccessEnvelope(event), (_) {}, @@ -51,12 +55,15 @@ Future injectEventChannelResponse( } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseAuth.channel.setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseAuth.channel, + (call) async { return await methodCallCallback(call); }); Future simulateEvent(String name, Map? user) async { - await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .handlePlatformMessage( MethodChannelFirebaseAuth.channel.name, MethodChannelFirebaseAuth.channel.codec.encodeMethodCall( MethodCall( diff --git a/packages/firebase_auth/firebase_auth_web/pubspec.yaml b/packages/firebase_auth/firebase_auth_web/pubspec.yaml index 7fcf2d960cbf..e188596757ad 100644 --- a/packages/firebase_auth/firebase_auth_web/pubspec.yaml +++ b/packages/firebase_auth/firebase_auth_web/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: http_parser: ^4.0.0 intl: ^0.17.0 js: ^0.6.3 - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: firebase_auth: ^4.4.2 diff --git a/packages/firebase_core/firebase_core/pubspec.yaml b/packages/firebase_core/firebase_core/pubspec.yaml index bfd4dc6a0144..22a2062961d6 100644 --- a/packages/firebase_core/firebase_core/pubspec.yaml +++ b/packages/firebase_core/firebase_core/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: firebase_core_web: ^2.3.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: flutter_test: diff --git a/packages/firebase_core/firebase_core_platform_interface/pubspec.yaml b/packages/firebase_core/firebase_core_platform_interface/pubspec.yaml index 3194c68374ee..18bf125efbe6 100644 --- a/packages/firebase_core/firebase_core_platform_interface/pubspec.yaml +++ b/packages/firebase_core/firebase_core_platform_interface/pubspec.yaml @@ -17,9 +17,9 @@ dependencies: # Needed to export the mocks flutter_test: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: - mockito: ^5.0.0 - pigeon: ^3.1.5 + mockito: ^5.4.0 + pigeon: ^9.2.5 diff --git a/packages/firebase_core/firebase_core_web/pubspec.yaml b/packages/firebase_core/firebase_core_web/pubspec.yaml index cce44a3faa4d..e4520ca8389d 100644 --- a/packages/firebase_core/firebase_core_web/pubspec.yaml +++ b/packages/firebase_core/firebase_core_web/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: flutter_web_plugins: sdk: flutter js: ^0.6.3 - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: firebase_core: ^2.10.0 diff --git a/packages/firebase_crashlytics/firebase_crashlytics/test/mock.dart b/packages/firebase_crashlytics/firebase_crashlytics/test/mock.dart index 0111be655c0c..f6b82ed91a83 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/test/mock.dart +++ b/packages/firebase_crashlytics/firebase_crashlytics/test/mock.dart @@ -70,8 +70,9 @@ void setupFirebaseCrashlyticsMocks([Callback? customHandlers]) { TestFirebaseCoreHostApi.setup(MockFirebaseAppWithCollectionEnabled()); - MethodChannelFirebaseCrashlytics.channel - .setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseCrashlytics.channel, + (MethodCall methodCall) async { methodCallLog.add(methodCall); switch (methodCall.method) { case 'Crashlytics#checkForUnsentReports': diff --git a/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/pubspec.yaml b/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/pubspec.yaml index cb4050744a56..2801506943ef 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/pubspec.yaml +++ b/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/test/mock.dart b/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/test/mock.dart index 41c2ce6bd27c..af68cf454d38 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/test/mock.dart +++ b/packages/firebase_crashlytics/firebase_crashlytics_platform_interface/test/mock.dart @@ -18,8 +18,9 @@ void setupFirebaseCrashlyticsMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseCrashlytics.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseCrashlytics.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_database/firebase_database_platform_interface/pubspec.yaml b/packages/firebase_database/firebase_database_platform_interface/pubspec.yaml index cdc247c82bae..1317d0ca1f96 100755 --- a/packages/firebase_database/firebase_database_platform_interface/pubspec.yaml +++ b/packages/firebase_database/firebase_database_platform_interface/pubspec.yaml @@ -9,7 +9,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_database/firebase_database_platform_interface/test/method_channel_test.dart b/packages/firebase_database/firebase_database_platform_interface/test/method_channel_test.dart index 97690171b964..8a517dcd56fa 100755 --- a/packages/firebase_database/firebase_database_platform_interface/test/method_channel_test.dart +++ b/packages/firebase_database/firebase_database_platform_interface/test/method_channel_test.dart @@ -16,7 +16,7 @@ import 'test_common.dart'; void main() { initializeMethodChannel(); late FirebaseApp app; - late BinaryMessenger messenger; + late TestDefaultBinaryMessenger? messenger; setUpAll(() async { app = await Firebase.initializeApp( @@ -29,7 +29,8 @@ void main() { ), ); - messenger = ServicesBinding.instance.defaultBinaryMessenger; + messenger = + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger; }); group('MethodChannelDatabase', () { @@ -44,7 +45,8 @@ void main() { setUp(() async { database = MethodChannelDatabase(app: app, databaseURL: databaseURL); - channel.setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (MethodCall methodCall) async { log.add(methodCall); switch (methodCall.method) { @@ -58,7 +60,7 @@ void main() { String key, dynamic data, ) async { - await messenger.handlePlatformMessage( + await messenger?.handlePlatformMessage( channel.name, channel.codec.encodeMethodCall( MethodCall( @@ -451,7 +453,9 @@ void main() { final QueryPlatform query = database.ref('some/path'); Future simulateError(String errorMessage) async { - await eventChannel.binaryMessenger.handlePlatformMessage( + await TestDefaultBinaryMessengerBinding + .instance?.defaultBinaryMessenger + .handlePlatformMessage( eventChannel.name, eventChannel.codec.encodeErrorEnvelope( code: errorCode, @@ -497,7 +501,9 @@ void main() { final QueryPlatform query = database.ref(path); Future simulateEvent(Map event) async { - await eventChannel.binaryMessenger.handlePlatformMessage( + await TestDefaultBinaryMessengerBinding + .instance?.defaultBinaryMessenger + .handlePlatformMessage( eventChannel.name, eventChannel.codec.encodeSuccessEnvelope(event), (_) {}, diff --git a/packages/firebase_dynamic_links/firebase_dynamic_links/example/lib/main.dart b/packages/firebase_dynamic_links/firebase_dynamic_links/example/lib/main.dart index 920dad7014a6..8d2adf2abb49 100644 --- a/packages/firebase_dynamic_links/firebase_dynamic_links/example/lib/main.dart +++ b/packages/firebase_dynamic_links/firebase_dynamic_links/example/lib/main.dart @@ -164,10 +164,12 @@ class _MainScreenState extends State<_MainScreen> { } }, onLongPress: () { - Clipboard.setData(ClipboardData(text: _linkMessage)); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Copied Link!')), - ); + if (_linkMessage != null) { + Clipboard.setData(ClipboardData(text: _linkMessage)); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Copied Link!')), + ); + } }, child: Text( _linkMessage ?? '', diff --git a/packages/firebase_dynamic_links/firebase_dynamic_links/pubspec.yaml b/packages/firebase_dynamic_links/firebase_dynamic_links/pubspec.yaml index 825f4282e461..b349b75b0246 100644 --- a/packages/firebase_dynamic_links/firebase_dynamic_links/pubspec.yaml +++ b/packages/firebase_dynamic_links/firebase_dynamic_links/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: firebase_dynamic_links_platform_interface: ^0.2.4+1 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/pubspec.yaml b/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/pubspec.yaml index ba7487614c42..4a25de1446d9 100644 --- a/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/pubspec.yaml +++ b/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/test/mock.dart b/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/test/mock.dart index 4791fd3e189c..11329979e0e6 100644 --- a/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/test/mock.dart +++ b/packages/firebase_dynamic_links/firebase_dynamic_links_platform_interface/test/mock.dart @@ -21,8 +21,9 @@ void setupFirebaseDynamicLinksMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseDynamicLinks.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseDynamicLinks.channel, + (call) async { return await methodCallCallback(call); }); @@ -30,7 +31,9 @@ void handleEventChannel( final String name, [ List? log, ]) { - MethodChannel(name).setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannel(name), + (MethodCall methodCall) async { log?.add(methodCall); switch (methodCall.method) { case 'listen': @@ -39,6 +42,7 @@ void handleEventChannel( default: return null; } + return null; }); } @@ -46,7 +50,8 @@ Future injectEventChannelResponse( String channelName, Map event, ) async { - await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( + await TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .handlePlatformMessage( channelName, MethodChannelFirebaseDynamicLinks.channel.codec .encodeSuccessEnvelope(event), diff --git a/packages/firebase_in_app_messaging/firebase_in_app_messaging/example/pubspec.yaml b/packages/firebase_in_app_messaging/firebase_in_app_messaging/example/pubspec.yaml index 005a3b7c1931..1b85b2cbdac2 100644 --- a/packages/firebase_in_app_messaging/firebase_in_app_messaging/example/pubspec.yaml +++ b/packages/firebase_in_app_messaging/firebase_in_app_messaging/example/pubspec.yaml @@ -6,7 +6,6 @@ environment: sdk: '>=2.18.0 <3.0.0' dependencies: - cupertino_icons: ^1.0.2 firebase_analytics: ^10.2.1 firebase_core: ^2.10.0 firebase_in_app_messaging: ^0.7.1+1 diff --git a/packages/firebase_in_app_messaging/firebase_in_app_messaging/pubspec.yaml b/packages/firebase_in_app_messaging/firebase_in_app_messaging/pubspec.yaml index 31c2ec5e26aa..524ebed289a9 100644 --- a/packages/firebase_in_app_messaging/firebase_in_app_messaging/pubspec.yaml +++ b/packages/firebase_in_app_messaging/firebase_in_app_messaging/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: firebase_in_app_messaging_platform_interface: ^0.2.2+1 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: flutter_test: diff --git a/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/pubspec.yaml b/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/pubspec.yaml index 395c5f412e9c..87da8191ab14 100644 --- a/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/pubspec.yaml +++ b/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/test/mock.dart b/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/test/mock.dart index ef30220b871b..ddbcf4213655 100644 --- a/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/test/mock.dart +++ b/packages/firebase_in_app_messaging/firebase_in_app_messaging_platform_interface/test/mock.dart @@ -21,7 +21,8 @@ void setupFirebaseInAppMessagingMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseInAppMessaging.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseInAppMessaging.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_messaging/firebase_messaging/pubspec.yaml b/packages/firebase_messaging/firebase_messaging/pubspec.yaml index 9c847e2de9e2..57663041cd46 100644 --- a/packages/firebase_messaging/firebase_messaging/pubspec.yaml +++ b/packages/firebase_messaging/firebase_messaging/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: firebase_messaging_web: ^3.3.1 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: async: ^2.5.0 diff --git a/packages/firebase_messaging/firebase_messaging_platform_interface/pubspec.yaml b/packages/firebase_messaging/firebase_messaging_platform_interface/pubspec.yaml index 29674778b7ae..e1b543cd67b4 100644 --- a/packages/firebase_messaging/firebase_messaging_platform_interface/pubspec.yaml +++ b/packages/firebase_messaging/firebase_messaging_platform_interface/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_messaging/firebase_messaging_platform_interface/test/mock.dart b/packages/firebase_messaging/firebase_messaging_platform_interface/test/mock.dart index 23bcbe570c08..dff5f9b979da 100644 --- a/packages/firebase_messaging/firebase_messaging_platform_interface/test/mock.dart +++ b/packages/firebase_messaging/firebase_messaging_platform_interface/test/mock.dart @@ -17,8 +17,9 @@ void setupFirebaseMessagingMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseMessaging.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseMessaging.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_messaging/firebase_messaging_web/pubspec.yaml b/packages/firebase_messaging/firebase_messaging_web/pubspec.yaml index c6a2bd079452..e2fa2bee0aef 100644 --- a/packages/firebase_messaging/firebase_messaging_web/pubspec.yaml +++ b/packages/firebase_messaging/firebase_messaging_web/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: flutter_web_plugins: sdk: flutter js: ^0.6.3 - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: firebase_core_platform_interface: ^4.6.0 diff --git a/packages/firebase_ml_model_downloader/firebase_ml_model_downloader/example/pubspec.yaml b/packages/firebase_ml_model_downloader/firebase_ml_model_downloader/example/pubspec.yaml index 744090056f05..e2cd65f35e03 100644 --- a/packages/firebase_ml_model_downloader/firebase_ml_model_downloader/example/pubspec.yaml +++ b/packages/firebase_ml_model_downloader/firebase_ml_model_downloader/example/pubspec.yaml @@ -1,73 +1,19 @@ name: firebase_ml_model_downloader_example description: Demonstrates how to use the firebase_ml_model_downloader plugin. -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: 'none' environment: sdk: '>=2.18.0 <3.0.0' -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter firebase_ml_model_downloader: ^0.2.1+1 - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 dev_dependencies: - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^1.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/pubspec.yaml b/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/pubspec.yaml index 687f17e0b2c1..2b4015dbd3e2 100644 --- a/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/pubspec.yaml +++ b/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/test/mock.dart b/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/test/mock.dart index f563d43e22e2..306353f0eed4 100644 --- a/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/test/mock.dart +++ b/packages/firebase_ml_model_downloader/firebase_ml_model_downloader_platform_interface/test/mock.dart @@ -16,8 +16,9 @@ void setupFirebaseModelDownloaderMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseModelDownloader.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseModelDownloader.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_performance/firebase_performance_platform_interface/test/mock.dart b/packages/firebase_performance/firebase_performance_platform_interface/test/mock.dart index 0796325febbe..aa1c0b628824 100644 --- a/packages/firebase_performance/firebase_performance_platform_interface/test/mock.dart +++ b/packages/firebase_performance/firebase_performance_platform_interface/test/mock.dart @@ -20,8 +20,9 @@ void setupFirebasePerformanceMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebasePerformance.channel - .setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebasePerformance.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_performance/firebase_performance_web/pubspec.yaml b/packages/firebase_performance/firebase_performance_web/pubspec.yaml index 740c029898a5..44e7bcb8fc26 100644 --- a/packages/firebase_performance/firebase_performance_web/pubspec.yaml +++ b/packages/firebase_performance/firebase_performance_web/pubspec.yaml @@ -19,6 +19,7 @@ dependencies: js: ^0.6.3 dev_dependencies: + build_runner: ^2.3.3 flutter_test: sdk: flutter mockito: ^5.0.10 diff --git a/packages/firebase_performance/firebase_performance_web/test/firebase_performance_web_test.dart b/packages/firebase_performance/firebase_performance_web/test/firebase_performance_web_test.dart index bbf1caf059ce..338d910ae3e3 100644 --- a/packages/firebase_performance/firebase_performance_web/test/firebase_performance_web_test.dart +++ b/packages/firebase_performance/firebase_performance_web/test/firebase_performance_web_test.dart @@ -9,11 +9,11 @@ import 'package:firebase_performance_web/firebase_performance_web.dart'; import 'package:firebase_performance_web/src/interop/performance.dart'; import 'package:firebase_performance_web/src/trace.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -class MockPerformance extends Mock implements Performance {} - -class MockTrace extends Mock implements Trace {} +@GenerateNiceMocks([MockSpec(), MockSpec()]) +import 'firebase_performance_web_test.mocks.dart'; void main() { group('FirebasePerformanceWeb', () { diff --git a/packages/firebase_performance/firebase_performance_web/test/firebase_performance_web_test.mocks.dart b/packages/firebase_performance/firebase_performance_web/test/firebase_performance_web_test.mocks.dart new file mode 100644 index 000000000000..591c1d769e64 --- /dev/null +++ b/packages/firebase_performance/firebase_performance_web/test/firebase_performance_web_test.mocks.dart @@ -0,0 +1,242 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Mocks generated by Mockito 5.4.0 from annotations +// in firebase_performance_web/test/firebase_performance_web_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:firebase_core_web/firebase_core_web_interop.dart' as _i2; +import 'package:firebase_performance_web/src/interop/performance.dart' as _i4; +import 'package:firebase_performance_web/src/interop/performance_interop.dart' + as _i3; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeApp_0 extends _i1.SmartFake implements _i2.App { + _FakeApp_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakePerformanceJsImpl_1 extends _i1.SmartFake + implements _i3.PerformanceJsImpl { + _FakePerformanceJsImpl_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeTrace_2 extends _i1.SmartFake implements _i4.Trace { + _FakeTrace_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeTraceJsImpl_3 extends _i1.SmartFake implements _i3.TraceJsImpl { + _FakeTraceJsImpl_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [Performance]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockPerformance extends _i1.Mock implements _i4.Performance { + @override + _i2.App get app => (super.noSuchMethod( + Invocation.getter(#app), + returnValue: _FakeApp_0( + this, + Invocation.getter(#app), + ), + returnValueForMissingStub: _FakeApp_0( + this, + Invocation.getter(#app), + ), + ) as _i2.App); + @override + bool get instrumentationEnabled => (super.noSuchMethod( + Invocation.getter(#instrumentationEnabled), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + @override + bool get dataCollectionEnabled => (super.noSuchMethod( + Invocation.getter(#dataCollectionEnabled), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + @override + _i3.PerformanceJsImpl get jsObject => (super.noSuchMethod( + Invocation.getter(#jsObject), + returnValue: _FakePerformanceJsImpl_1( + this, + Invocation.getter(#jsObject), + ), + returnValueForMissingStub: _FakePerformanceJsImpl_1( + this, + Invocation.getter(#jsObject), + ), + ) as _i3.PerformanceJsImpl); + @override + _i4.Trace trace(String? traceName) => (super.noSuchMethod( + Invocation.method( + #trace, + [traceName], + ), + returnValue: _FakeTrace_2( + this, + Invocation.method( + #trace, + [traceName], + ), + ), + returnValueForMissingStub: _FakeTrace_2( + this, + Invocation.method( + #trace, + [traceName], + ), + ), + ) as _i4.Trace); +} + +/// A class which mocks [Trace]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockTrace extends _i1.Mock implements _i4.Trace { + @override + _i3.TraceJsImpl get jsObject => (super.noSuchMethod( + Invocation.getter(#jsObject), + returnValue: _FakeTraceJsImpl_3( + this, + Invocation.getter(#jsObject), + ), + returnValueForMissingStub: _FakeTraceJsImpl_3( + this, + Invocation.getter(#jsObject), + ), + ) as _i3.TraceJsImpl); + @override + String getAttribute(String? attr) => (super.noSuchMethod( + Invocation.method( + #getAttribute, + [attr], + ), + returnValue: '', + returnValueForMissingStub: '', + ) as String); + @override + Map getAttributes() => (super.noSuchMethod( + Invocation.method( + #getAttributes, + [], + ), + returnValue: {}, + returnValueForMissingStub: {}, + ) as Map); + @override + int getMetric(String? metricName) => (super.noSuchMethod( + Invocation.method( + #getMetric, + [metricName], + ), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + @override + void incrementMetric( + String? metricName, [ + int? num, + ]) => + super.noSuchMethod( + Invocation.method( + #incrementMetric, + [ + metricName, + num, + ], + ), + returnValueForMissingStub: null, + ); + @override + void putMetric( + String? metricName, + int? num, + ) => + super.noSuchMethod( + Invocation.method( + #putMetric, + [ + metricName, + num, + ], + ), + returnValueForMissingStub: null, + ); + @override + void putAttribute( + String? attr, + String? value, + ) => + super.noSuchMethod( + Invocation.method( + #putAttribute, + [ + attr, + value, + ], + ), + returnValueForMissingStub: null, + ); + @override + void removeAttribute(String? attr) => super.noSuchMethod( + Invocation.method( + #removeAttribute, + [attr], + ), + returnValueForMissingStub: null, + ); + @override + void start() => super.noSuchMethod( + Invocation.method( + #start, + [], + ), + returnValueForMissingStub: null, + ); + @override + void stop() => super.noSuchMethod( + Invocation.method( + #stop, + [], + ), + returnValueForMissingStub: null, + ); +} diff --git a/packages/firebase_remote_config/firebase_remote_config/example/pubspec.yaml b/packages/firebase_remote_config/firebase_remote_config/example/pubspec.yaml index 80e9f564420b..bf97627928c7 100644 --- a/packages/firebase_remote_config/firebase_remote_config/example/pubspec.yaml +++ b/packages/firebase_remote_config/firebase_remote_config/example/pubspec.yaml @@ -8,7 +8,6 @@ environment: dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.0 firebase_core: ^2.10.0 firebase_remote_config: ^4.0.2 flutter: diff --git a/packages/firebase_remote_config/firebase_remote_config_platform_interface/pubspec.yaml b/packages/firebase_remote_config/firebase_remote_config_platform_interface/pubspec.yaml index 96f0db627291..67083dc76166 100644 --- a/packages/firebase_remote_config/firebase_remote_config_platform_interface/pubspec.yaml +++ b/packages/firebase_remote_config/firebase_remote_config_platform_interface/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_remote_config/firebase_remote_config_web/pubspec.yaml b/packages/firebase_remote_config/firebase_remote_config_web/pubspec.yaml index 7f605cd0d3d3..01673552ae95 100644 --- a/packages/firebase_remote_config/firebase_remote_config_web/pubspec.yaml +++ b/packages/firebase_remote_config/firebase_remote_config_web/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: js: ^0.6.3 dev_dependencies: + build_runner: ^2.3.3 firebase_core_platform_interface: ^4.6.0 flutter_test: sdk: flutter diff --git a/packages/firebase_remote_config/firebase_remote_config_web/test/firebase_remote_config_web_test.dart b/packages/firebase_remote_config/firebase_remote_config_web/test/firebase_remote_config_web_test.dart index 3b7fe6df1858..ba0822a26718 100644 --- a/packages/firebase_remote_config/firebase_remote_config_web/test/firebase_remote_config_web_test.dart +++ b/packages/firebase_remote_config/firebase_remote_config_web/test/firebase_remote_config_web_test.dart @@ -6,17 +6,19 @@ import 'package:firebase_remote_config_platform_interface/firebase_remote_config_platform_interface.dart'; import 'package:firebase_remote_config_web/firebase_remote_config_web.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -class MockRemoteConfig extends Mock implements FirebaseRemoteConfigWeb {} +@GenerateNiceMocks([MockSpec()]) +import 'firebase_remote_config_web_test.mocks.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('$FirebaseRemoteConfigWeb', () { - late MockRemoteConfig remoteConfig; + late MockFirebaseRemoteConfigWeb remoteConfig; setUp(() { - remoteConfig = MockRemoteConfig(); + remoteConfig = MockFirebaseRemoteConfigWeb(); }); test('setInitialValues', () { diff --git a/packages/firebase_remote_config/firebase_remote_config_web/test/firebase_remote_config_web_test.mocks.dart b/packages/firebase_remote_config/firebase_remote_config_web/test/firebase_remote_config_web_test.mocks.dart new file mode 100644 index 000000000000..f4654bc554d4 --- /dev/null +++ b/packages/firebase_remote_config/firebase_remote_config_web/test/firebase_remote_config_web_test.mocks.dart @@ -0,0 +1,309 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Mocks generated by Mockito 5.4.0 from annotations +// in firebase_remote_config_web/test/firebase_remote_config_web_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i5; + +import 'package:firebase_core/firebase_core.dart' as _i3; +import 'package:firebase_remote_config_platform_interface/firebase_remote_config_platform_interface.dart' + as _i2; +import 'package:firebase_remote_config_web/firebase_remote_config_web.dart' + as _i4; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeDateTime_0 extends _i1.SmartFake implements DateTime { + _FakeDateTime_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeRemoteConfigSettings_1 extends _i1.SmartFake + implements _i2.RemoteConfigSettings { + _FakeRemoteConfigSettings_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFirebaseApp_2 extends _i1.SmartFake implements _i3.FirebaseApp { + _FakeFirebaseApp_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFirebaseRemoteConfigPlatform_3 extends _i1.SmartFake + implements _i2.FirebaseRemoteConfigPlatform { + _FakeFirebaseRemoteConfigPlatform_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeRemoteConfigValue_4 extends _i1.SmartFake + implements _i2.RemoteConfigValue { + _FakeRemoteConfigValue_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [FirebaseRemoteConfigWeb]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFirebaseRemoteConfigWeb extends _i1.Mock + implements _i4.FirebaseRemoteConfigWeb { + @override + DateTime get lastFetchTime => (super.noSuchMethod( + Invocation.getter(#lastFetchTime), + returnValue: _FakeDateTime_0( + this, + Invocation.getter(#lastFetchTime), + ), + returnValueForMissingStub: _FakeDateTime_0( + this, + Invocation.getter(#lastFetchTime), + ), + ) as DateTime); + @override + _i2.RemoteConfigFetchStatus get lastFetchStatus => (super.noSuchMethod( + Invocation.getter(#lastFetchStatus), + returnValue: _i2.RemoteConfigFetchStatus.noFetchYet, + returnValueForMissingStub: _i2.RemoteConfigFetchStatus.noFetchYet, + ) as _i2.RemoteConfigFetchStatus); + @override + _i2.RemoteConfigSettings get settings => (super.noSuchMethod( + Invocation.getter(#settings), + returnValue: _FakeRemoteConfigSettings_1( + this, + Invocation.getter(#settings), + ), + returnValueForMissingStub: _FakeRemoteConfigSettings_1( + this, + Invocation.getter(#settings), + ), + ) as _i2.RemoteConfigSettings); + @override + _i5.Stream<_i2.RemoteConfigUpdate> get onConfigUpdated => (super.noSuchMethod( + Invocation.getter(#onConfigUpdated), + returnValue: _i5.Stream<_i2.RemoteConfigUpdate>.empty(), + returnValueForMissingStub: _i5.Stream<_i2.RemoteConfigUpdate>.empty(), + ) as _i5.Stream<_i2.RemoteConfigUpdate>); + @override + _i3.FirebaseApp get app => (super.noSuchMethod( + Invocation.getter(#app), + returnValue: _FakeFirebaseApp_2( + this, + Invocation.getter(#app), + ), + returnValueForMissingStub: _FakeFirebaseApp_2( + this, + Invocation.getter(#app), + ), + ) as _i3.FirebaseApp); + @override + _i2.FirebaseRemoteConfigPlatform delegateFor({_i3.FirebaseApp? app}) => + (super.noSuchMethod( + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + returnValue: _FakeFirebaseRemoteConfigPlatform_3( + this, + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + ), + returnValueForMissingStub: _FakeFirebaseRemoteConfigPlatform_3( + this, + Invocation.method( + #delegateFor, + [], + {#app: app}, + ), + ), + ) as _i2.FirebaseRemoteConfigPlatform); + @override + _i2.FirebaseRemoteConfigPlatform setInitialValues( + {required Map? remoteConfigValues}) => + (super.noSuchMethod( + Invocation.method( + #setInitialValues, + [], + {#remoteConfigValues: remoteConfigValues}, + ), + returnValue: _FakeFirebaseRemoteConfigPlatform_3( + this, + Invocation.method( + #setInitialValues, + [], + {#remoteConfigValues: remoteConfigValues}, + ), + ), + returnValueForMissingStub: _FakeFirebaseRemoteConfigPlatform_3( + this, + Invocation.method( + #setInitialValues, + [], + {#remoteConfigValues: remoteConfigValues}, + ), + ), + ) as _i2.FirebaseRemoteConfigPlatform); + @override + _i5.Future activate() => (super.noSuchMethod( + Invocation.method( + #activate, + [], + ), + returnValue: _i5.Future.value(false), + returnValueForMissingStub: _i5.Future.value(false), + ) as _i5.Future); + @override + _i5.Future ensureInitialized() => (super.noSuchMethod( + Invocation.method( + #ensureInitialized, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future fetch() => (super.noSuchMethod( + Invocation.method( + #fetch, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future fetchAndActivate() => (super.noSuchMethod( + Invocation.method( + #fetchAndActivate, + [], + ), + returnValue: _i5.Future.value(false), + returnValueForMissingStub: _i5.Future.value(false), + ) as _i5.Future); + @override + Map getAll() => (super.noSuchMethod( + Invocation.method( + #getAll, + [], + ), + returnValue: {}, + returnValueForMissingStub: {}, + ) as Map); + @override + bool getBool(String? key) => (super.noSuchMethod( + Invocation.method( + #getBool, + [key], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + @override + int getInt(String? key) => (super.noSuchMethod( + Invocation.method( + #getInt, + [key], + ), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + @override + double getDouble(String? key) => (super.noSuchMethod( + Invocation.method( + #getDouble, + [key], + ), + returnValue: 0.0, + returnValueForMissingStub: 0.0, + ) as double); + @override + String getString(String? key) => (super.noSuchMethod( + Invocation.method( + #getString, + [key], + ), + returnValue: '', + returnValueForMissingStub: '', + ) as String); + @override + _i2.RemoteConfigValue getValue(String? key) => (super.noSuchMethod( + Invocation.method( + #getValue, + [key], + ), + returnValue: _FakeRemoteConfigValue_4( + this, + Invocation.method( + #getValue, + [key], + ), + ), + returnValueForMissingStub: _FakeRemoteConfigValue_4( + this, + Invocation.method( + #getValue, + [key], + ), + ), + ) as _i2.RemoteConfigValue); + @override + _i5.Future setConfigSettings( + _i2.RemoteConfigSettings? remoteConfigSettings) => + (super.noSuchMethod( + Invocation.method( + #setConfigSettings, + [remoteConfigSettings], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future setDefaults(Map? defaultParameters) => + (super.noSuchMethod( + Invocation.method( + #setDefaults, + [defaultParameters], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); +} diff --git a/packages/firebase_storage/firebase_storage_platform_interface/pubspec.yaml b/packages/firebase_storage/firebase_storage_platform_interface/pubspec.yaml index adb92c2cbeef..fda55b3876ce 100644 --- a/packages/firebase_storage/firebase_storage_platform_interface/pubspec.yaml +++ b/packages/firebase_storage/firebase_storage_platform_interface/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: firebase_core: ^2.10.0 flutter: sdk: flutter - meta: ^1.3.0 + meta: ^1.8.0 plugin_platform_interface: ^2.1.3 dev_dependencies: diff --git a/packages/firebase_storage/firebase_storage_platform_interface/test/mock.dart b/packages/firebase_storage/firebase_storage_platform_interface/test/mock.dart index 5d4b02b5a868..0e3785b2c710 100644 --- a/packages/firebase_storage/firebase_storage_platform_interface/test/mock.dart +++ b/packages/firebase_storage/firebase_storage_platform_interface/test/mock.dart @@ -21,7 +21,9 @@ void setupFirebaseStorageMocks([Callback? customHandlers]) { } void handleMethodCall(MethodCallCallback methodCallCallback) => - MethodChannelFirebaseStorage.channel.setMockMethodCallHandler((call) async { + TestDefaultBinaryMessengerBinding.instance?.defaultBinaryMessenger + .setMockMethodCallHandler(MethodChannelFirebaseStorage.channel, + (call) async { return await methodCallCallback(call); }); diff --git a/packages/firebase_storage/firebase_storage_web/pubspec.yaml b/packages/firebase_storage/firebase_storage_web/pubspec.yaml index 96e5ae8eca52..a08b20e2ae49 100644 --- a/packages/firebase_storage/firebase_storage_web/pubspec.yaml +++ b/packages/firebase_storage/firebase_storage_web/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: sdk: flutter http: ^0.13.0 js: ^0.6.3 - meta: ^1.3.0 + meta: ^1.8.0 dev_dependencies: firebase_core_platform_interface: ^4.6.0 diff --git a/packages/firebase_ui_auth/lib/src/screens/profile_screen.dart b/packages/firebase_ui_auth/lib/src/screens/profile_screen.dart index ec41097ab2d4..4c22778b42cb 100644 --- a/packages/firebase_ui_auth/lib/src/screens/profile_screen.dart +++ b/packages/firebase_ui_auth/lib/src/screens/profile_screen.dart @@ -11,19 +11,18 @@ import 'package:firebase_auth/firebase_auth.dart' PhoneAuthCredential, PhoneMultiFactorGenerator, User; -import 'package:firebase_ui_shared/firebase_ui_shared.dart'; -import 'package:flutter/cupertino.dart' hide Title; -import 'package:firebase_ui_localizations/firebase_ui_localizations.dart'; -import 'package:flutter/material.dart' hide Title; import 'package:firebase_ui_auth/firebase_ui_auth.dart'; +import 'package:firebase_ui_localizations/firebase_ui_localizations.dart'; import 'package:firebase_ui_oauth/firebase_ui_oauth.dart' hide OAuthProviderButtonBase; +import 'package:firebase_ui_shared/firebase_ui_shared.dart'; +import 'package:flutter/cupertino.dart' hide Title; +import 'package:flutter/material.dart' hide Title; import 'package:flutter/services.dart'; import '../widgets/internal/rebuild_scope.dart'; import '../widgets/internal/subtitle.dart'; import '../widgets/internal/universal_icon_button.dart'; - import 'internal/multi_provider_screen.dart'; class _AvailableProvidersRow extends StatefulWidget { diff --git a/packages/firebase_ui_firestore/test/table_builder_test.dart b/packages/firebase_ui_firestore/test/table_builder_test.dart index b84d9cd7febc..ef4e9fc63787 100644 --- a/packages/firebase_ui_firestore/test/table_builder_test.dart +++ b/packages/firebase_ui_firestore/test/table_builder_test.dart @@ -10,7 +10,6 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_ui_firestore/firebase_ui_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; - import 'package:mockito/mockito.dart'; typedef Snapshot = QuerySnapshot>; diff --git a/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart b/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart index 52fb6534a86d..871adcc918cc 100644 --- a/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart +++ b/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart @@ -37,16 +37,10 @@ void main() { group('authStateChanges()', () { StreamSubscription? subscription; - StreamSubscription? subscription2; tearDown(() async { await subscription?.cancel(); await ensureSignedOut(); - - if (subscription2 != null) { - await Future.delayed(const Duration(seconds: 5)); - await subscription2.cancel(); - } }); test('calls callback with the current user and when auth state changes', @@ -86,16 +80,10 @@ void main() { group('idTokenChanges()', () { StreamSubscription? subscription; - StreamSubscription? subscription2; tearDown(() async { await subscription?.cancel(); await ensureSignedOut(); - - if (subscription2 != null) { - await Future.delayed(const Duration(seconds: 5)); - await subscription2.cancel(); - } }); test('calls callback with the current user and when auth state changes', @@ -241,7 +229,8 @@ void main() { test('throws on invalid code', () async { try { await FirebaseAuth.instance.confirmPasswordReset( - code: '!!!!!!', newPassword: 'thingamajig', + code: '!!!!!!', + newPassword: 'thingamajig', ); fail('Should have thrown'); } on FirebaseException catch (e) { @@ -447,7 +436,8 @@ void main() { // Confirm the continue url was passed through to backend correctly. final url = Uri.parse(oobCode.oobLink!); expect( - url.queryParameters['continueUrl'], Uri.encodeFull(continueUrl), + url.queryParameters['continueUrl'], + Uri.encodeFull(continueUrl), ); }); }); @@ -570,7 +560,8 @@ void main() { test('throws if login password is incorrect', () async { var credential = EmailAuthProvider.credential( - email: testEmail, password: 'sowrong', + email: testEmail, + password: 'sowrong', ); try { await FirebaseAuth.instance.signInWithCredential(credential); @@ -748,7 +739,7 @@ void main() { phoneNumber: 'foo', verificationCompleted: (PhoneAuthCredential credential) { return completer.completeError( - Exception('Should not have been called'), + Exception('Should not have been called'), ); }, verificationFailed: (FirebaseAuthException e) { @@ -756,12 +747,12 @@ void main() { }, codeSent: (String verificationId, int? resetToken) { return completer.completeError( - Exception('Should not have been called'), + Exception('Should not have been called'), ); }, codeAutoRetrievalTimeout: (String foo) { return completer.completeError( - Exception('Should not have been called'), + Exception('Should not have been called'), ); }, ),