Skip to content

Commit

Permalink
added THEOlive integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dallos committed Oct 18, 2024
1 parent 14932f8 commit d20b58d
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ void main() {
testWidgets('Test basic playback with SURFACE_TEXTURE', (WidgetTester tester) async {
await runBasicPlaybackTest(tester, AndroidViewComposition.SURFACE_TEXTURE);
});

//disabled for now, we need to figure out the license
if (false && kIsWeb) {
testWidgets('Test basic THEOlive playback with HYBRID_COMPOSITION', (WidgetTester tester) async {
await runBasicTHEOlivePlaybackTest(tester, AndroidViewComposition.HYBRID_COMPOSITION);
});

// the only difference is is on Android
testWidgets('Test basic THEOlive playback with SURFACE_TEXTURE', (WidgetTester tester) async {
await runBasicTHEOlivePlaybackTest(tester, AndroidViewComposition.SURFACE_TEXTURE);
});
}
}

Future<void> runBasicPlaybackTest(WidgetTester tester, AndroidViewComposition androidViewComposition) async {
Expand Down Expand Up @@ -60,3 +72,41 @@ Future<void> runBasicPlaybackTest(WidgetTester tester, AndroidViewComposition an
print("Testing playback currentTime(): ${player.getCurrentTime()}");
expect(player.getCurrentTime() >= 5, isTrue);
}

Future<void> runBasicTHEOlivePlaybackTest(WidgetTester tester, AndroidViewComposition androidViewComposition) async {
TestApp app = TestApp(androidViewComposition: androidViewComposition,);
await tester.pumpWidget(app);

final chromlessPlayerView = find.byKey(const Key('testChromelessPlayer'));
await tester.ensureVisible(chromlessPlayerView);
final player = (tester.firstElement(chromlessPlayerView).widget as ChromelessPlayerView).player;
await tester.pumpAndSettle();
await app.waitForPlayerReady();
await tester.pumpAndSettle();

print("Testing isInitialized()");
expect(player.isInitialized(), isTrue);

print("Testing isPaused()");
expect(player.isPaused(), isTrue);

player.setMuted(true);
player.setAutoplay(true);

print("Setting source");

player.setSource(SourceDescription(sources: [
TheoLiveSource(src: "38yyniscxeglzr8n0lbku57b0"),
]));

await tester.pumpAndSettle(const Duration(seconds: 10));

print("Testing channel state : ${player.theoLive!.publicationState}");
expect(player.theoLive?.publicationState == PublicationState.loaded, isTrue);

print("Testing playback duration(): ${player.getDuration()}");
expect(player.getDuration() == double.infinity, isTrue);

print("Testing playback currentTime(): ${player.getCurrentTime()}");
expect(player.getCurrentTime() >= 0, isTrue);
}

0 comments on commit d20b58d

Please sign in to comment.