diff --git a/lib/src/impl/agora_rtc_engine_impl.dart b/lib/src/impl/agora_rtc_engine_impl.dart index 559389a43..09e4ed41d 100644 --- a/lib/src/impl/agora_rtc_engine_impl.dart +++ b/lib/src/impl/agora_rtc_engine_impl.dart @@ -35,7 +35,8 @@ import 'package:agora_rtc_engine/src/impl/audio_device_manager_impl.dart' as audio_device_manager_impl; import 'package:agora_rtc_engine/src/binding/impl_forward_export.dart'; import 'package:agora_rtc_engine/src/impl/native_iris_api_engine_binding_delegate.dart'; -import 'package:flutter/foundation.dart' show defaultTargetPlatform; +import 'package:flutter/foundation.dart' + show ChangeNotifier, defaultTargetPlatform; import 'package:flutter/services.dart' show MethodChannel; import 'package:flutter/widgets.dart' show @@ -168,6 +169,20 @@ class _Lifecycle with WidgetsBindingObserver { } } +@internal +class InitializationState extends ChangeNotifier { + bool _isInitialzed = false; + bool get isInitialzed => _isInitialzed; + set isInitialzed(bool value) { + if (_isInitialzed == value) { + return; + } + + _isInitialzed = value; + notifyListeners(); + } +} + class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl implements RtcEngineEx { RtcEngineImpl._(IrisMethodChannel irisMethodChannel) @@ -177,6 +192,10 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl static RtcEngineImpl? _instance; + final InitializationState _rtcEngineState = InitializationState(); + @internal + bool get isInitialzed => _rtcEngineState.isInitialzed; + final _rtcEngineImplScopedKey = const TypedScopedKey(RtcEngineImpl); late final GlobalVideoViewController _globalVideoViewController; @@ -214,6 +233,8 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl .attachVideoFrameBufferManager(irisMethodChannel.getNativeHandle()); irisMethodChannel.addHotRestartListener(_hotRestartListener); + + _rtcEngineState.isInitialzed = true; } void _hotRestartListener(Object? message) { @@ -262,6 +283,16 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl await _initializeInternal(context); } + @internal + void addInitializedCompletedListener(VoidCallback listener) { + _rtcEngineState.addListener(listener); + } + + @internal + void removeInitializedCompletedListener(VoidCallback listener) { + _rtcEngineState.removeListener(listener); + } + @override Future release({bool sync = false}) async { if (_instance == null) return; @@ -273,6 +304,8 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl _lifecycle = null; } + _rtcEngineState.dispose(); + await _objectPool.clear(); await _globalVideoViewController diff --git a/lib/src/impl/agora_video_view_impl.dart b/lib/src/impl/agora_video_view_impl.dart index 36783f3ba..44bf4e7f4 100644 --- a/lib/src/impl/agora_video_view_impl.dart +++ b/lib/src/impl/agora_video_view_impl.dart @@ -1,5 +1,6 @@ import 'package:agora_rtc_engine/src/agora_base.dart'; import 'package:agora_rtc_engine/src/agora_media_base.dart'; + import 'package:agora_rtc_engine/src/impl/video_view_controller_impl.dart'; import 'package:agora_rtc_engine/src/render/agora_video_view.dart'; import 'package:agora_rtc_engine/src/render/video_view_controller.dart'; @@ -11,9 +12,57 @@ import 'agora_rtc_renderer.dart'; // ignore_for_file: public_member_api_docs -class AgoraVideoViewState extends State with RtcRenderMixin { +class AgoraVideoViewState extends State { + AgoraVideoViewState() { + _listener = () { + bool isInitialzed = _controller(widget.controller).isInitialzed; + if (isInitialzed != _isInitialzed) { + setState(() { + _isInitialzed = isInitialzed; + }); + } + }; + } + + late VoidCallback _listener; + late bool _isInitialzed; + + VideoViewControllerBaseMixin _controller(VideoViewControllerBase controller) { + return controller as VideoViewControllerBaseMixin; + } + + @override + void initState() { + super.initState(); + + _isInitialzed = _controller(widget.controller).isInitialzed; + _controller(widget.controller).addInitializedCompletedListener(_listener); + } + + @override + void didUpdateWidget(covariant AgoraVideoView oldWidget) { + super.didUpdateWidget(oldWidget); + + _controller(oldWidget.controller) + .removeInitializedCompletedListener(_listener); + // Refresh the `_isInitialzed` to the current widget.controller `isInitialzed` + _isInitialzed = _controller(widget.controller).isInitialzed; + _controller(widget.controller).addInitializedCompletedListener(_listener); + } + + @override + void deactivate() { + super.deactivate(); + _controller(widget.controller) + .removeInitializedCompletedListener(_listener); + } + @override Widget build(BuildContext context) { + if (!_isInitialzed) { + return Container(); + } + if (defaultTargetPlatform == TargetPlatform.macOS || defaultTargetPlatform == TargetPlatform.windows) { return AgoraRtcRenderTexture( diff --git a/lib/src/impl/media_player_controller_impl.dart b/lib/src/impl/media_player_controller_impl.dart index b1be7759e..f0f0ecf32 100644 --- a/lib/src/impl/media_player_controller_impl.dart +++ b/lib/src/impl/media_player_controller_impl.dart @@ -9,6 +9,7 @@ import 'package:agora_rtc_engine/src/impl/agora_rtc_engine_impl.dart'; import 'package:agora_rtc_engine/src/impl/media_player_impl.dart'; import 'package:agora_rtc_engine/src/impl/video_view_controller_impl.dart'; import 'package:agora_rtc_engine/src/render/media_player_controller.dart'; +import 'package:flutter/foundation.dart'; class MediaPlayerControllerImpl with VideoViewControllerBaseMixin @@ -20,6 +21,10 @@ class MediaPlayerControllerImpl final RtcEngine _rtcEngine; + final InitializationState _initState = InitializationState(); + @override + bool get isInitialzed => _initState.isInitialzed; + @override RtcEngine get rtcEngine => _rtcEngine; @@ -329,6 +334,17 @@ class MediaPlayerControllerImpl @override Future initialize() async { _mediaPlayer = await rtcEngine.createMediaPlayer(); + _initState.isInitialzed = true; + } + + @override + void addInitializedCompletedListener(VoidCallback listener) { + _initState.addListener(listener); + } + + @override + void removeInitializedCompletedListener(VoidCallback listener) { + _initState.removeListener(listener); } @override @@ -348,6 +364,7 @@ class MediaPlayerControllerImpl @override Future dispose() async { + _initState.dispose(); await (_mediaPlayer as MediaPlayerImpl).destroy(); await super.dispose(); await rtcEngine.destroyMediaPlayer(this); diff --git a/lib/src/impl/video_view_controller_impl.dart b/lib/src/impl/video_view_controller_impl.dart index bc3cb1082..b25596b93 100644 --- a/lib/src/impl/video_view_controller_impl.dart +++ b/lib/src/impl/video_view_controller_impl.dart @@ -45,6 +45,21 @@ extension VideoViewControllerBaseExt on VideoViewControllerBase { mixin VideoViewControllerBaseMixin implements VideoViewControllerBase { int _textureId = kTextureNotInit; + @internal + bool get isInitialzed => (rtcEngine as RtcEngineImpl).isInitialzed; + + @internal + void addInitializedCompletedListener(VoidCallback listener) { + final engine = rtcEngine as RtcEngineImpl; + engine.addInitializedCompletedListener(listener); + } + + @internal + void removeInitializedCompletedListener(VoidCallback listener) { + final engine = rtcEngine as RtcEngineImpl; + engine.removeInitializedCompletedListener(listener); + } + @override int getTextureId() => _textureId; diff --git a/test_shard/integration_test_app/integration_test/testcases/agora_video_view_testcases.dart b/test_shard/integration_test_app/integration_test/testcases/agora_video_view_testcases.dart index 1cc8f09c2..1c1a34dc5 100644 --- a/test_shard/integration_test_app/integration_test/testcases/agora_video_view_testcases.dart +++ b/test_shard/integration_test_app/integration_test/testcases/agora_video_view_testcases.dart @@ -1,60 +1,81 @@ +import 'dart:io'; + import 'package:agora_rtc_engine/agora_rtc_engine.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; -import 'package:integration_test_app/main.dart' as app; class _RenderViewWidget extends StatefulWidget { const _RenderViewWidget({ Key? key, - required this.rtcEngine, required this.builder, }) : super(key: key); final Function(BuildContext context, RtcEngine engine) builder; - final RtcEngine rtcEngine; - @override State<_RenderViewWidget> createState() => _RenderViewWidgetState(); } class _RenderViewWidgetState extends State<_RenderViewWidget> { + late final RtcEngine _engine; + @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: widget.builder(context, widget.rtcEngine), - ), - ); + void initState() { + super.initState(); + _initEngine(); } -} -void testCases() { - testWidgets('Show Local AgoraVideoView pressure test', - (WidgetTester tester) async { - app.main(); - await tester.pumpAndSettle(); + @override + void dispose() { + super.dispose(); + _dispose(); + } + Future _dispose() async { + await _engine.leaveChannel(); + await _engine.release(); + } + + Future _initEngine() async { String engineAppId = const String.fromEnvironment('TEST_APP_ID', defaultValue: ''); - final rtcEngine = createAgoraRtcEngine(); - await rtcEngine.initialize(RtcEngineContext( + _engine = createAgoraRtcEngine(); + await _engine.initialize(RtcEngineContext( appId: engineAppId, areaCode: AreaCode.areaCodeGlob.value(), )); try { - await rtcEngine.enableVideo(); - await rtcEngine.startPreview(); + await _engine.enableVideo(); + await _engine.startPreview(); } catch (e) { debugPrint(e.toString()); } - for (int i = 0; i < 5; i++) { + await _engine.setClientRole(role: ClientRoleType.clientRoleBroadcaster); + await _engine.setAudioProfile( + profile: AudioProfileType.audioProfileDefault, + scenario: AudioScenarioType.audioScenarioGameStreaming, + ); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: widget.builder(context, _engine), + ), + ); + } +} + +void testCases() { + testWidgets( + 'Show local AgoraVideoView after RtcEngine.initialize', + (WidgetTester tester) async { await tester.pumpWidget(_RenderViewWidget( - rtcEngine: rtcEngine, builder: (context, engine) { return SizedBox( height: 100, @@ -71,12 +92,19 @@ void testCases() { await tester.pumpAndSettle(const Duration(milliseconds: 5000)); + if (defaultTargetPlatform == TargetPlatform.android) { + expect(find.byType(AndroidView), findsOneWidget); + } + + if (defaultTargetPlatform == TargetPlatform.iOS) { + expect(find.byType(UiKitView), findsOneWidget); + } + await tester.pumpWidget(Container()); await tester.pumpAndSettle(const Duration(milliseconds: 5000)); - } - - expect(find.byType(AgoraVideoView), findsNothing); - await rtcEngine.release(sync: true); - }); + expect(find.byType(AgoraVideoView), findsNothing); + }, + skip: !(Platform.isAndroid || Platform.isIOS), + ); } diff --git a/test_shard/rendering_test/integration_test/agora_video_view_render_test.dart b/test_shard/rendering_test/integration_test/agora_video_view_render_test.dart index bb1b65cf6..06e414cbe 100644 --- a/test_shard/rendering_test/integration_test/agora_video_view_render_test.dart +++ b/test_shard/rendering_test/integration_test/agora_video_view_render_test.dart @@ -29,6 +29,12 @@ class TestMediaPlayerController extends MediaPlayerControllerImpl { bool get shouldHandlerRenderMode => true; } +Future waitFrame(WidgetTester tester) async { + await tester.pumpAndSettle(const Duration(seconds: 10)); + // Need `pumpAndSettle` again since there's a `setState` logic inside the `AgoraVideoView` + await tester.pumpAndSettle(const Duration(seconds: 10)); +} + Future waitDisposed( WidgetTester tester, IntegrationTestWidgetsFlutterBinding binding, @@ -138,7 +144,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.convertFlutterSurfaceToImage(); await tester.pumpAndSettle(); @@ -176,7 +182,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await tester.pumpAndSettle(); @@ -208,7 +214,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.platformview.remote'); @@ -244,7 +250,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.local.donot_handle_rendermode'); @@ -274,7 +280,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.local.with_default_rendermode'); @@ -305,7 +311,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.local.with_rendermodehidden'); @@ -336,7 +342,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.local.with_rendermodefit'); @@ -367,7 +373,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.local.with_rendermodeadaptive'); @@ -398,7 +404,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.local.with_default_rendermode.with_videomirrormodedisabled'); @@ -430,7 +436,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.remote.donot_handle_rendermode'); @@ -460,7 +466,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.remote.with_default_rendermode'); @@ -490,7 +496,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.remote.with_rendermodehidden'); @@ -520,7 +526,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.remote.with_rendermodefit'); @@ -550,7 +556,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.remote.with_rendermodeadaptive'); @@ -580,7 +586,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await binding.takeScreenshot( 'ios.agora_video_view_render.texture.remote.with_default_rendermodede.with_videoMirrorModeEnabled'); @@ -623,7 +629,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.local.donot_handle_rendermode'); @@ -655,10 +661,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); - - await matchScreenShotDesktop(rtcEngine, - 'macos.agora_video_view_render.texture.local.with_default_rendermode'); + await waitFrame(tester); await waitDisposed(tester, binding); }, @@ -688,7 +691,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.local.with_rendermodehidden'); @@ -721,7 +724,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.local.with_rendermodefit'); @@ -754,7 +757,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.local.with_rendermodeadaptive'); @@ -787,7 +790,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.local.with_default_rendermode.with_videomirrormodedisabled'); @@ -820,7 +823,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.remote.donot_handle_rendermode'); @@ -851,7 +854,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.remote.with_default_rendermode'); @@ -883,7 +886,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.remote.with_rendermodehidden'); @@ -915,7 +918,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.remote.with_rendermodefit'); @@ -947,7 +950,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.remote.with_rendermodeadaptive'); @@ -979,7 +982,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'macos.agora_video_view_render.texture.remote.with_default_rendermodede.with_videoMirrorModeEnabled'); @@ -1020,7 +1023,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.local.donot_handle_rendermode'); @@ -1052,7 +1055,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.local.with_default_rendermode'); @@ -1085,7 +1088,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.local.with_rendermodehidden'); @@ -1118,7 +1121,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.local.with_rendermodefit'); @@ -1151,7 +1154,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.local.with_rendermodeadaptive'); @@ -1184,7 +1187,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.local.with_default_rendermode.with_videomirrormodedisabled'); @@ -1218,7 +1221,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.remote.donot_handle_rendermode'); @@ -1249,7 +1252,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.remote.with_default_rendermode'); @@ -1281,7 +1284,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.remote.with_rendermodehidden'); @@ -1313,7 +1316,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.remote.with_rendermodefit'); @@ -1345,7 +1348,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.remote.with_rendermodeadaptive'); @@ -1377,7 +1380,7 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 10)); await onFrameCompleter.future; - await tester.pumpAndSettle(const Duration(seconds: 10)); + await waitFrame(tester); await matchScreenShotDesktop(rtcEngine, 'windows.agora_video_view_render.texture.remote.with_default_rendermodede.with_videoMirrorModeEnabled'); diff --git a/test_shard/rendering_test/integration_test/local_video_view.dart b/test_shard/rendering_test/integration_test/local_video_view.dart index b23c8dc24..908f7fed3 100644 --- a/test_shard/rendering_test/integration_test/local_video_view.dart +++ b/test_shard/rendering_test/integration_test/local_video_view.dart @@ -33,7 +33,6 @@ class _LocalVideoViewState extends State { late final MediaPlayerController mediaPlayerController; late final MediaPlayerVideoFrameObserver observer; late final MediaPlayerSourceObserver mediaPlayerSourceObserver; - bool isInit = false; @override void initState() { @@ -48,19 +47,6 @@ class _LocalVideoViewState extends State { rtcEngine = createAgoraRtcEngineEx(); - await rtcEngine.initialize(RtcEngineContext( - appId: engineAppId, - areaCode: AreaCode.areaCodeGlob.value(), - )); - - await rtcEngine.setVideoEncoderConfiguration( - const VideoEncoderConfiguration( - dimensions: VideoDimensions(width: 640, height: 360), - frameRate: 15, - bitrate: 800, - ), - ); - if (widget.isRenderModeTest) { mediaPlayerController = TestMediaPlayerController( rtcEngine: rtcEngine, @@ -83,6 +69,19 @@ class _LocalVideoViewState extends State { ); } + await rtcEngine.initialize(RtcEngineContext( + appId: engineAppId, + areaCode: AreaCode.areaCodeGlob.value(), + )); + + await rtcEngine.setVideoEncoderConfiguration( + const VideoEncoderConfiguration( + dimensions: VideoDimensions(width: 640, height: 360), + frameRate: 15, + bitrate: 800, + ), + ); + await mediaPlayerController.initialize(); observer = MediaPlayerVideoFrameObserver( @@ -110,10 +109,6 @@ class _LocalVideoViewState extends State { await mediaPlayerController.open(url: widget.url, startPos: 0); await mediaPlayerControllerPlayed.future; - - setState(() { - isInit = true; - }); } @override @@ -130,9 +125,6 @@ class _LocalVideoViewState extends State { @override Widget build(BuildContext context) { - if (!isInit) { - return Container(); - } return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( diff --git a/test_shard/rendering_test/integration_test/remote_video_view.dart b/test_shard/rendering_test/integration_test/remote_video_view.dart index cb251d3d9..89a5b71c3 100644 --- a/test_shard/rendering_test/integration_test/remote_video_view.dart +++ b/test_shard/rendering_test/integration_test/remote_video_view.dart @@ -53,6 +53,26 @@ class _RemoteVideoViewState extends State { rtcEngine = createAgoraRtcEngineEx(); + if (widget.isRenderModeTest) { + mediaPlayerController = TestMediaPlayerController( + rtcEngine: rtcEngine, + canvas: VideoCanvas( + uid: 0, + renderMode: widget.renderModeType, + mirrorMode: widget.mirrorModeType, + ), + ); + } else { + mediaPlayerController = MediaPlayerController( + rtcEngine: rtcEngine, + canvas: VideoCanvas( + uid: 0, + renderMode: widget.renderModeType, + mirrorMode: widget.mirrorModeType, + ), + ); + } + await rtcEngine.initialize(RtcEngineContext( appId: engineAppId, areaCode: AreaCode.areaCodeGlob.value(), @@ -86,26 +106,6 @@ class _RemoteVideoViewState extends State { ), ); - if (widget.isRenderModeTest) { - mediaPlayerController = TestMediaPlayerController( - rtcEngine: rtcEngine, - canvas: VideoCanvas( - uid: 0, - renderMode: widget.renderModeType, - mirrorMode: widget.mirrorModeType, - ), - ); - } else { - mediaPlayerController = MediaPlayerController( - rtcEngine: rtcEngine, - canvas: VideoCanvas( - uid: 0, - renderMode: widget.renderModeType, - mirrorMode: widget.mirrorModeType, - ), - ); - } - await mediaPlayerController.initialize(); final mediaPlayerControllerPlayed = Completer(); diff --git a/test_shard/rendering_test/ios/Flutter/AppFrameworkInfo.plist b/test_shard/rendering_test/ios/Flutter/AppFrameworkInfo.plist index 8d4492f97..9625e105d 100644 --- a/test_shard/rendering_test/ios/Flutter/AppFrameworkInfo.plist +++ b/test_shard/rendering_test/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/test_shard/rendering_test/ios/Podfile b/test_shard/rendering_test/ios/Podfile index e5229ebb9..31a520b2b 100644 --- a/test_shard/rendering_test/ios/Podfile +++ b/test_shard/rendering_test/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/test_shard/rendering_test/ios/Runner.xcodeproj/project.pbxproj b/test_shard/rendering_test/ios/Runner.xcodeproj/project.pbxproj index 0fa960edf..e17bf0b36 100644 --- a/test_shard/rendering_test/ios/Runner.xcodeproj/project.pbxproj +++ b/test_shard/rendering_test/ios/Runner.xcodeproj/project.pbxproj @@ -340,7 +340,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -418,7 +418,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -467,7 +467,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos;