11import 'dart:io' ;
22
33import 'package:checks/checks.dart' ;
4- import 'package:flutter/foundation.dart' ;
54import 'package:flutter/material.dart' ;
65import 'package:flutter_test/flutter_test.dart' ;
76import 'package:url_launcher/url_launcher.dart' ;
@@ -57,8 +56,6 @@ void main() {
5756 });
5857
5958 group ('LinkNode interactions' , () {
60- const expectedModeAndroid = LaunchMode .externalApplication;
61-
6259 // The Flutter test font uses square glyphs, so width equals height:
6360 // https://github.com/flutter/flutter/wiki/Flutter-Test-Fonts
6461 const fontSize = 48.0 ;
@@ -80,10 +77,8 @@ void main() {
8077 '<p><a href="https://example/">hello</a></p>' );
8178
8279 await tester.tap (find.text ('hello' ));
83- final expectedMode = defaultTargetPlatform == TargetPlatform .android ?
84- LaunchMode .externalApplication : LaunchMode .platformDefault;
8580 check (testBinding.takeLaunchUrlCalls ())
86- .single.equals ((url: Uri .parse ('https://example/' ), mode: expectedMode ));
81+ .single.equals ((url: Uri .parse ('https://example/' ), mode: LaunchMode .platformDefault ));
8782 }, variant: const TargetPlatformVariant ({TargetPlatform .android, TargetPlatform .iOS}));
8883
8984 testWidgets ('multiple links in paragraph' , (tester) async {
@@ -97,19 +92,19 @@ void main() {
9792
9893 await tester.tapAt (base .translate (1 * fontSize, 0 )); // "fXo bar baz"
9994 check (testBinding.takeLaunchUrlCalls ())
100- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
95+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
10196
10297 await tester.tapAt (base .translate (9 * fontSize, 0 )); // "foo bar bXz"
10398 check (testBinding.takeLaunchUrlCalls ())
104- .single.equals ((url: Uri .parse ('https://b/' ), mode: expectedModeAndroid ));
99+ .single.equals ((url: Uri .parse ('https://b/' ), mode: LaunchMode .platformDefault ));
105100 });
106101
107102 testWidgets ('link nested in other spans' , (tester) async {
108103 await prepareContent (tester,
109104 '<p><strong><em><a href="https://a/">word</a></em></strong></p>' );
110105 await tester.tap (find.text ('word' ));
111106 check (testBinding.takeLaunchUrlCalls ())
112- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
107+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
113108 });
114109
115110 testWidgets ('link containing other spans' , (tester) async {
@@ -120,27 +115,27 @@ void main() {
120115
121116 await tester.tapAt (base .translate (1 * fontSize, 0 )); // "tXo words"
122117 check (testBinding.takeLaunchUrlCalls ())
123- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
118+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
124119
125120 await tester.tapAt (base .translate (6 * fontSize, 0 )); // "two woXds"
126121 check (testBinding.takeLaunchUrlCalls ())
127- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
122+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
128123 });
129124
130125 testWidgets ('relative links are resolved' , (tester) async {
131126 await prepareContent (tester,
132127 '<p><a href="/a/b?c#d">word</a></p>' );
133128 await tester.tap (find.text ('word' ));
134129 check (testBinding.takeLaunchUrlCalls ())
135- .single.equals ((url: Uri .parse ('${eg .realmUrl }a/b?c#d' ), mode: expectedModeAndroid ));
130+ .single.equals ((url: Uri .parse ('${eg .realmUrl }a/b?c#d' ), mode: LaunchMode .platformDefault ));
136131 });
137132
138133 testWidgets ('link inside HeadingNode' , (tester) async {
139134 await prepareContent (tester,
140135 '<h6><a href="https://a/">word</a></h6>' );
141136 await tester.tap (find.text ('word' ));
142137 check (testBinding.takeLaunchUrlCalls ())
143- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
138+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
144139 });
145140
146141 testWidgets ('error dialog if invalid link' , (tester) async {
@@ -150,7 +145,7 @@ void main() {
150145 await tester.tap (find.text ('word' ));
151146 await tester.pump ();
152147 check (testBinding.takeLaunchUrlCalls ())
153- .single.equals ((url: Uri .parse ('file:///etc/bad' ), mode: expectedModeAndroid ));
148+ .single.equals ((url: Uri .parse ('file:///etc/bad' ), mode: LaunchMode .platformDefault ));
154149 checkErrorDialog (tester, expectedTitle: 'Unable to open link' );
155150 });
156151 });
0 commit comments