@@ -328,6 +328,54 @@ void main() {
328
328
});
329
329
});
330
330
331
+ group ("MessageEmbedVideo" , () {
332
+ Future <void > prepareContent (WidgetTester tester, String html) async {
333
+ addTearDown (testBinding.reset);
334
+ await testBinding.globalStore.add (eg.selfAccount, eg.initialSnapshot ());
335
+ prepareBoringImageHttpClient ();
336
+
337
+ await tester.pumpWidget (GlobalStoreWidget (child: MaterialApp (
338
+ home: PerAccountStoreWidget (accountId: eg.selfAccount.id,
339
+ child: MessageContent (
340
+ message: eg.streamMessage (content: html),
341
+ content: parseContent (html))))));
342
+ await tester.pump (); // global store
343
+ await tester.pump (); // per-account store
344
+ debugNetworkImageHttpClientProvider = null ;
345
+ }
346
+
347
+ Future <void > checkEmbedVideo (WidgetTester tester, ContentExample example) async {
348
+ await prepareContent (tester, example.html);
349
+
350
+ final expectedTitle = (((example.expectedNodes[0 ] as ParagraphNode )
351
+ .nodes.single as LinkNode ).nodes.single as TextNode ).text;
352
+ await tester.ensureVisible (find.text (expectedTitle));
353
+
354
+ final expectedVideo = example.expectedNodes[1 ] as EmbedVideoNode ;
355
+ final expectedResolvedUrl = eg.store ()
356
+ .tryResolveUrl (expectedVideo.previewImageSrcUrl)! ;
357
+ final image = tester.widget <RealmContentNetworkImage >(
358
+ find.byType (RealmContentNetworkImage ));
359
+ check (image.src).equals (expectedResolvedUrl);
360
+
361
+ final expectedLaunchUrl = expectedVideo.hrefUrl;
362
+ await tester.tap (find.byIcon (Icons .play_arrow_rounded));
363
+ check (testBinding.takeLaunchUrlCalls ())
364
+ .single.equals ((url: Uri .parse (expectedLaunchUrl), mode: LaunchMode .platformDefault));
365
+ }
366
+
367
+ testWidgets ('video preview for youtube embed' , (tester) async {
368
+ const example = ContentExample .videoEmbedYoutube;
369
+ await checkEmbedVideo (tester, example);
370
+ });
371
+
372
+ testWidgets ('video preview for vimeo embed' , (tester) async {
373
+ const example = ContentExample .videoEmbedVimeo;
374
+ await checkEmbedVideo (tester, example);
375
+ });
376
+ });
377
+
378
+
331
379
group ("CodeBlock" , () {
332
380
testContentSmoke (ContentExample .codeBlockPlain);
333
381
testContentSmoke (ContentExample .codeBlockHighlightedShort);
0 commit comments