Open MJablonskiCodespot opened 1 year ago
I created widget that uses BetterPlayer like:
class PlayerView extends StatelessWidget { final ControllerProvider controllerProvider; final PlayerPlaybackInfo _playerData; final Function(int playbackPosition)? onPlaybackPositionUpdated; PlayerView( this._playerData, { this.onPlaybackPositionUpdated, super.key, this.controllerProvider = const ControllerProvider(), }); final Lazy<PlayerRepository> _playerRepository = Di.lazy(); @override Widget build(BuildContext context) => _playerData.isContentSecured() ? BlocBuilderWrapped<DrmHeadersBloc, GetDrmHeadersState>( bloc: () => DrmHeadersBloc(_playerRepository.value())..add(GetDrmHeadersEvent(_playerData)), builder: _buildDrmState, ) : _buildPlayer( controllerProvider.getNonDrmController(_playerData, onPlaybackPositionUpdated: onPlaybackPositionUpdated), ); Widget _buildDrmState(BuildContext context, GetDrmHeadersState state) { if (state is GetDrmHeadersStateSuccess) { final BetterPlayerController controller = controllerProvider.getDrmController( _playerData, state.authHeaders, onPlaybackPositionUpdated: onPlaybackPositionUpdated, ); return _buildPlayer(controller); } else if (state is GetDrmHeadersStateError) { return RetryErrorView(RStrings.commonApiErrorString, () => _onRetryDrmHeaders(context)); } else { return const Center(child: DataLoader()); } } void _onRetryDrmHeaders(BuildContext context) { if (context.mounted) { BlocProvider.of<DrmHeadersBloc>(context).add(GetDrmHeadersEvent(_playerData)); } } Widget _buildPlayer(BetterPlayerController controller) => AspectRatio( aspectRatio: controller.getAspectRatio() ?? 16 / 9, child: BetterPlayer(controller: controller), ); }
but when I want to create test for this widget, it fails everytime while i'm trying to build controller, even with some provider class and mocked controllers with mockito.
I'd like to have controller designated to tests.
I created widget that uses BetterPlayer like:
but when I want to create test for this widget, it fails everytime while i'm trying to build controller, even with some provider class and mocked controllers with mockito.
I'd like to have controller designated to tests.