flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.68k stars 27.14k forks source link

AudioPlayer while writing Golden tests #152667

Closed CpedniyNikon closed 2 weeks ago

CpedniyNikon commented 1 month ago

Steps to reproduce

1.

group('AudioPlayer Test', (){

    TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
        .setMockMethodCallHandler(
        const MethodChannel('plugins.flutter.io/path_provider'),
            (MethodCall methodCall) async {
          return '.';
        });

    TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
        .setMockMethodCallHandler(
        const MethodChannel('xyz.luan/audioplayers'),
            (MethodCall methodCall) async {
          return '.';
        });

    testGoldens('admin collection page', (tester) async {
      final builder = DeviceBuilder()
        ..addScenario(
            widget: const MaterialApp(
                debugShowCheckedModeBanner: false, home: AdminCollectionPage()));
      await tester.pumpDeviceBuilder(builder);
      await screenMatchesGolden(tester, 'admin_collection_page');
    });
  });
  1. This page uses
    late AudioPlayer audioPlayer;

    and

    rootPath = Platform.isAndroid
        ? await getExternalStorageDirectory()
        : await getApplicationSupportDirectory(); 
  2. flutter test --update-goldens --tags=golden

Expected results

test passed

Actual results

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following MissingPluginException was thrown while activating platform stream on channel
xyz.luan/audioplayers/events/039d2269-6791-4970-975b-5d6320cb003b:
MissingPluginException(No implementation found for method listen on channel
xyz.luan/audioplayers/events/039d2269-6791-4970-975b-5d6320cb003b)

When the exception was thrown, this was the stack:
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7)
<asynchronous suspension>
#1      EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:676:9)
<asynchronous suspension>

Code sample

Code sample ```dart [Paste your code here] ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

```console ══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════ The following MissingPluginException was thrown while activating platform stream on channel xyz.luan/audioplayers/events/039d2269-6791-4970-975b-5d6320cb003b: MissingPluginException(No implementation found for method listen on channel xyz.luan/audioplayers/events/039d2269-6791-4970-975b-5d6320cb003b) When the exception was thrown, this was the stack: #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7) #1 EventChannel.receiveBroadcastStream. (package:flutter/src/services/platform_channel.dart:676:9) ```

Flutter Doctor output

Doctor output ```console [√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [Version 10.0.22000.2899], locale ru-RU) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2023.2) [√] IntelliJ IDEA Ultimate Edition (version 2023.3) [√] VS Code (version 1.91.1) [√] Connected device (3 available) [√] Network resources ```
huycozy commented 1 month ago

MissingPluginException(No implementation found for method listen on channel xyz.luan/audioplayers/events/039d2269-6791-4970-975b-5d6320cb003b)

This error is thrown before testGoldens call and it looks like you put the test file into the wrong test directory. Please see https://docs.flutter.dev/testing/plugins-in-tests and https://docs.flutter.dev/testing/testing-plugins for the documentation. If you are running integration test on integration_test directory and still see the error, please provide a complete and minimal sample code. Thanks!

github-actions[bot] commented 2 weeks ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

github-actions[bot] commented 4 days ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.