@@ -180,7 +180,7 @@ void main() {
180
180
testContentSmoke (ContentExample .spoilerRichHeaderAndContent);
181
181
182
182
group ('interactions: spoiler with tappable content (an image) in the header' , () {
183
- Future <List <Route <dynamic >>> prepareContent (WidgetTester tester, String html) async {
183
+ Future <List <Route <dynamic >>> prepare (WidgetTester tester, String html) async {
184
184
final pushedRoutes = < Route <dynamic >> [];
185
185
final testNavObserver = TestNavigatorObserver ()
186
186
..onPushed = (route, prevRoute) => pushedRoutes.add (route);
@@ -213,15 +213,15 @@ void main() {
213
213
const example = ContentExample .spoilerHeaderHasImage;
214
214
215
215
testWidgets ('tap image' , (tester) async {
216
- final pushedRoutes = await prepareContent (tester, example.html);
216
+ final pushedRoutes = await prepare (tester, example.html);
217
217
218
218
await tester.tap (find.byType (RealmContentNetworkImage ));
219
219
check (pushedRoutes).single.isA <AccountPageRouteBuilder >()
220
220
.fullscreenDialog.isTrue (); // recognize the lightbox
221
221
});
222
222
223
223
testWidgets ('tap header on expand/collapse icon' , (tester) async {
224
- final pushedRoutes = await prepareContent (tester, example.html);
224
+ final pushedRoutes = await prepare (tester, example.html);
225
225
checkIsExpanded (tester, false );
226
226
227
227
await tester.tap (find.byIcon (Icons .expand_more));
@@ -236,7 +236,7 @@ void main() {
236
236
});
237
237
238
238
testWidgets ('tap header away from expand/collapse icon (and image)' , (tester) async {
239
- final pushedRoutes = await prepareContent (tester, example.html);
239
+ final pushedRoutes = await prepare (tester, example.html);
240
240
checkIsExpanded (tester, false );
241
241
242
242
await tester.tapAt (
@@ -257,7 +257,7 @@ void main() {
257
257
testContentSmoke (ContentExample .quotation);
258
258
259
259
group ('MessageImage, MessageImageList' , () {
260
- Future <void > prepareContent (WidgetTester tester, String html) async {
260
+ Future <void > prepare (WidgetTester tester, String html) async {
261
261
await prepareContentBare (tester,
262
262
// Message is needed for an image's lightbox.
263
263
messageContent (html),
@@ -268,7 +268,7 @@ void main() {
268
268
269
269
testWidgets ('single image' , (tester) async {
270
270
const example = ContentExample .imageSingle;
271
- await prepareContent (tester, example.html);
271
+ await prepare (tester, example.html);
272
272
final expectedImages = (example.expectedNodes[0 ] as ImageNodeList ).images;
273
273
final images = tester.widgetList <RealmContentNetworkImage >(
274
274
find.byType (RealmContentNetworkImage ));
@@ -278,7 +278,7 @@ void main() {
278
278
279
279
testWidgets ('image with invalid src URL' , (tester) async {
280
280
const example = ContentExample .imageInvalidUrl;
281
- await prepareContent (tester, example.html);
281
+ await prepare (tester, example.html);
282
282
// The image indeed has an invalid URL.
283
283
final expectedImages = (example.expectedNodes[0 ] as ImageNodeList ).images;
284
284
check (() => Uri .parse (expectedImages.single.srcUrl)).throws ();
@@ -290,7 +290,7 @@ void main() {
290
290
291
291
testWidgets ('multiple images' , (tester) async {
292
292
const example = ContentExample .imageCluster;
293
- await prepareContent (tester, example.html);
293
+ await prepare (tester, example.html);
294
294
final expectedImages = (example.expectedNodes[1 ] as ImageNodeList ).images;
295
295
final images = tester.widgetList <RealmContentNetworkImage >(
296
296
find.byType (RealmContentNetworkImage ));
@@ -300,7 +300,7 @@ void main() {
300
300
301
301
testWidgets ('content after image cluster' , (tester) async {
302
302
const example = ContentExample .imageClusterThenContent;
303
- await prepareContent (tester, example.html);
303
+ await prepare (tester, example.html);
304
304
final expectedImages = (example.expectedNodes[1 ] as ImageNodeList ).images;
305
305
final images = tester.widgetList <RealmContentNetworkImage >(
306
306
find.byType (RealmContentNetworkImage ));
@@ -310,7 +310,7 @@ void main() {
310
310
311
311
testWidgets ('multiple clusters of images' , (tester) async {
312
312
const example = ContentExample .imageMultipleClusters;
313
- await prepareContent (tester, example.html);
313
+ await prepare (tester, example.html);
314
314
final expectedImages = (example.expectedNodes[1 ] as ImageNodeList ).images
315
315
+ (example.expectedNodes[4 ] as ImageNodeList ).images;
316
316
final images = tester.widgetList <RealmContentNetworkImage >(
@@ -321,7 +321,7 @@ void main() {
321
321
322
322
testWidgets ('image as immediate child in implicit paragraph' , (tester) async {
323
323
const example = ContentExample .imageInImplicitParagraph;
324
- await prepareContent (tester, example.html);
324
+ await prepare (tester, example.html);
325
325
final expectedImages = ((example.expectedNodes[0 ] as ListNode )
326
326
.items[0 ][0 ] as ImageNodeList ).images;
327
327
final images = tester.widgetList <RealmContentNetworkImage >(
@@ -332,7 +332,7 @@ void main() {
332
332
333
333
testWidgets ('image cluster in implicit paragraph' , (tester) async {
334
334
const example = ContentExample .imageClusterInImplicitParagraph;
335
- await prepareContent (tester, example.html);
335
+ await prepare (tester, example.html);
336
336
final expectedImages = ((example.expectedNodes[0 ] as ListNode )
337
337
.items[0 ][1 ] as ImageNodeList ).images;
338
338
final images = tester.widgetList <RealmContentNetworkImage >(
@@ -343,7 +343,7 @@ void main() {
343
343
});
344
344
345
345
group ("MessageInlineVideo" , () {
346
- Future <List <Route <dynamic >>> prepareContent (WidgetTester tester, String html) async {
346
+ Future <List <Route <dynamic >>> prepare (WidgetTester tester, String html) async {
347
347
final pushedRoutes = < Route <dynamic >> [];
348
348
final testNavObserver = TestNavigatorObserver ()
349
349
..onPushed = (route, prevRoute) => pushedRoutes.add (route);
@@ -366,7 +366,7 @@ void main() {
366
366
367
367
testWidgets ('tapping on preview opens lightbox' , (tester) async {
368
368
const example = ContentExample .videoInline;
369
- final pushedRoutes = await prepareContent (tester, example.html);
369
+ final pushedRoutes = await prepare (tester, example.html);
370
370
371
371
await tester.tap (find.byIcon (Icons .play_arrow_rounded));
372
372
check (pushedRoutes).single.isA <AccountPageRouteBuilder >()
@@ -375,7 +375,7 @@ void main() {
375
375
});
376
376
377
377
group ("MessageEmbedVideo" , () {
378
- Future <void > prepareContent (WidgetTester tester, String html) async {
378
+ Future <void > prepare (WidgetTester tester, String html) async {
379
379
await prepareContentBare (tester,
380
380
// Message is needed for a video's lightbox.
381
381
messageContent (html),
@@ -384,7 +384,7 @@ void main() {
384
384
}
385
385
386
386
Future <void > checkEmbedVideo (WidgetTester tester, ContentExample example) async {
387
- await prepareContent (tester, example.html);
387
+ await prepare (tester, example.html);
388
388
389
389
final expectedTitle = (((example.expectedNodes[0 ] as ParagraphNode )
390
390
.nodes.single as LinkNode ).nodes.single as TextNode ).text;
@@ -519,14 +519,14 @@ void main() {
519
519
// https://github.com/flutter/flutter/wiki/Flutter-Test-Fonts
520
520
// We use this to simulate taps on specific glyphs.
521
521
522
- Future <void > prepareContent (WidgetTester tester, String html) async {
522
+ Future <void > prepare (WidgetTester tester, String html) async {
523
523
await prepareContentBare (tester, plainContent (html),
524
524
// We try to resolve relative links on the self-account's realm.
525
525
wrapWithPerAccountStoreWidget: true );
526
526
}
527
527
528
528
testWidgets ('can tap a link to open URL' , (tester) async {
529
- await prepareContent (tester,
529
+ await prepare (tester,
530
530
'<p><a href="https://example/">hello</a></p>' );
531
531
532
532
await tapText (tester, find.text ('hello' ));
@@ -540,7 +540,7 @@ void main() {
540
540
testWidgets ('multiple links in paragraph' , (tester) async {
541
541
final fontSize = Paragraph .textStyle.fontSize! ;
542
542
543
- await prepareContent (tester,
543
+ await prepare (tester,
544
544
'<p><a href="https://a/">foo</a> bar <a href="https://b/">baz</a></p>' );
545
545
final base = tester.getTopLeft (find.text ('foo bar baz' ))
546
546
.translate (fontSize/ 2 , fontSize/ 2 ); // middle of first letter
@@ -558,7 +558,7 @@ void main() {
558
558
});
559
559
560
560
testWidgets ('link nested in other spans' , (tester) async {
561
- await prepareContent (tester,
561
+ await prepare (tester,
562
562
'<p><strong><em><a href="https://a/">word</a></em></strong></p>' );
563
563
await tapText (tester, find.text ('word' ));
564
564
check (testBinding.takeLaunchUrlCalls ())
@@ -568,7 +568,7 @@ void main() {
568
568
testWidgets ('link containing other spans' , (tester) async {
569
569
final fontSize = Paragraph .textStyle.fontSize! ;
570
570
571
- await prepareContent (tester,
571
+ await prepare (tester,
572
572
'<p><a href="https://a/">two <strong><em><code>words</code></em></strong></a></p>' );
573
573
final base = tester.getTopLeft (find.text ('two words' ))
574
574
.translate (fontSize/ 2 , fontSize/ 2 ); // middle of first letter
@@ -583,23 +583,23 @@ void main() {
583
583
});
584
584
585
585
testWidgets ('relative links are resolved' , (tester) async {
586
- await prepareContent (tester,
586
+ await prepare (tester,
587
587
'<p><a href="/a/b?c#d">word</a></p>' );
588
588
await tapText (tester, find.text ('word' ));
589
589
check (testBinding.takeLaunchUrlCalls ())
590
590
.single.equals ((url: Uri .parse ('${eg .realmUrl }a/b?c#d' ), mode: LaunchMode .platformDefault));
591
591
});
592
592
593
593
testWidgets ('link inside HeadingNode' , (tester) async {
594
- await prepareContent (tester,
594
+ await prepare (tester,
595
595
'<h6><a href="https://a/">word</a></h6>' );
596
596
await tapText (tester, find.text ('word' ));
597
597
check (testBinding.takeLaunchUrlCalls ())
598
598
.single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault));
599
599
});
600
600
601
601
testWidgets ('error dialog if invalid link' , (tester) async {
602
- await prepareContent (tester,
602
+ await prepare (tester,
603
603
'<p><a href="file:///etc/bad">word</a></p>' );
604
604
testBinding.launchUrlResult = false ;
605
605
await tapText (tester, find.text ('word' ));
@@ -611,7 +611,7 @@ void main() {
611
611
});
612
612
613
613
group ('LinkNode on internal links' , () {
614
- Future <List <Route <dynamic >>> prepareContent (WidgetTester tester, String html) async {
614
+ Future <List <Route <dynamic >>> prepare (WidgetTester tester, String html) async {
615
615
final pushedRoutes = < Route <dynamic >> [];
616
616
final testNavObserver = TestNavigatorObserver ()
617
617
..onPushed = (route, prevRoute) => pushedRoutes.add (route);
@@ -632,7 +632,7 @@ void main() {
632
632
}
633
633
634
634
testWidgets ('valid internal links are navigated to within app' , (tester) async {
635
- final pushedRoutes = await prepareContent (tester,
635
+ final pushedRoutes = await prepare (tester,
636
636
'<p><a href="/#narrow/stream/1-check">stream</a></p>' );
637
637
638
638
await tapText (tester, find.text ('stream' ));
@@ -643,7 +643,7 @@ void main() {
643
643
644
644
testWidgets ('invalid internal links are opened in browser' , (tester) async {
645
645
// Link is invalid due to `topic` operator missing an operand.
646
- final pushedRoutes = await prepareContent (tester,
646
+ final pushedRoutes = await prepare (tester,
647
647
'<p><a href="/#narrow/stream/1-check/topic">invalid</a></p>' );
648
648
649
649
await tapText (tester, find.text ('invalid' ));
@@ -748,28 +748,28 @@ void main() {
748
748
});
749
749
750
750
group ('MessageImageEmoji' , () {
751
- Future <void > prepareContent (WidgetTester tester, String html) async {
751
+ Future <void > prepare (WidgetTester tester, String html) async {
752
752
await prepareContentBare (tester, plainContent (html),
753
753
// We try to resolve image-emoji URLs on the self-account's realm.
754
754
// For URLs on the self-account's realm, we include the auth credential.
755
755
wrapWithPerAccountStoreWidget: true );
756
756
}
757
757
758
758
testWidgets ('smoke: custom emoji' , (tester) async {
759
- await prepareContent (tester, ContentExample .emojiCustom.html);
759
+ await prepare (tester, ContentExample .emojiCustom.html);
760
760
tester.widget (find.byType (MessageImageEmoji ));
761
761
debugNetworkImageHttpClientProvider = null ;
762
762
});
763
763
764
764
testWidgets ('smoke: custom emoji with invalid URL' , (tester) async {
765
- await prepareContent (tester, ContentExample .emojiCustomInvalidUrl.html);
765
+ await prepare (tester, ContentExample .emojiCustomInvalidUrl.html);
766
766
final url = tester.widget <MessageImageEmoji >(find.byType (MessageImageEmoji )).node.src;
767
767
check (() => Uri .parse (url)).throws ();
768
768
debugNetworkImageHttpClientProvider = null ;
769
769
});
770
770
771
771
testWidgets ('smoke: Zulip extra emoji' , (tester) async {
772
- await prepareContent (tester, ContentExample .emojiZulipExtra.html);
772
+ await prepare (tester, ContentExample .emojiZulipExtra.html);
773
773
tester.widget (find.byType (MessageImageEmoji ));
774
774
debugNetworkImageHttpClientProvider = null ;
775
775
});
0 commit comments