1
1
import 'dart:io' ;
2
2
3
3
import 'package:checks/checks.dart' ;
4
- import 'package:flutter/foundation.dart' ;
5
4
import 'package:flutter/material.dart' ;
6
5
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart' ;
7
6
import 'package:flutter_test/flutter_test.dart' ;
@@ -64,8 +63,6 @@ void main() {
64
63
});
65
64
66
65
group ('LinkNode interactions' , () {
67
- const expectedModeAndroid = LaunchMode .externalApplication;
68
-
69
66
// The Flutter test font uses square glyphs, so width equals height:
70
67
// https://github.com/flutter/flutter/wiki/Flutter-Test-Fonts
71
68
const fontSize = 48.0 ;
@@ -89,10 +86,8 @@ void main() {
89
86
'<p><a href="https://example/">hello</a></p>' );
90
87
91
88
await tester.tap (find.text ('hello' ));
92
- final expectedMode = defaultTargetPlatform == TargetPlatform .android ?
93
- LaunchMode .externalApplication : LaunchMode .platformDefault;
94
89
check (testBinding.takeLaunchUrlCalls ())
95
- .single.equals ((url: Uri .parse ('https://example/' ), mode: expectedMode ));
90
+ .single.equals ((url: Uri .parse ('https://example/' ), mode: LaunchMode .platformDefault ));
96
91
}, variant: const TargetPlatformVariant ({TargetPlatform .android, TargetPlatform .iOS}));
97
92
98
93
testWidgets ('multiple links in paragraph' , (tester) async {
@@ -106,19 +101,19 @@ void main() {
106
101
107
102
await tester.tapAt (base .translate (1 * fontSize, 0 )); // "fXo bar baz"
108
103
check (testBinding.takeLaunchUrlCalls ())
109
- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
104
+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
110
105
111
106
await tester.tapAt (base .translate (9 * fontSize, 0 )); // "foo bar bXz"
112
107
check (testBinding.takeLaunchUrlCalls ())
113
- .single.equals ((url: Uri .parse ('https://b/' ), mode: expectedModeAndroid ));
108
+ .single.equals ((url: Uri .parse ('https://b/' ), mode: LaunchMode .platformDefault ));
114
109
});
115
110
116
111
testWidgets ('link nested in other spans' , (tester) async {
117
112
await prepareContent (tester,
118
113
'<p><strong><em><a href="https://a/">word</a></em></strong></p>' );
119
114
await tester.tap (find.text ('word' ));
120
115
check (testBinding.takeLaunchUrlCalls ())
121
- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
116
+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
122
117
});
123
118
124
119
testWidgets ('link containing other spans' , (tester) async {
@@ -129,27 +124,27 @@ void main() {
129
124
130
125
await tester.tapAt (base .translate (1 * fontSize, 0 )); // "tXo words"
131
126
check (testBinding.takeLaunchUrlCalls ())
132
- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
127
+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
133
128
134
129
await tester.tapAt (base .translate (6 * fontSize, 0 )); // "two woXds"
135
130
check (testBinding.takeLaunchUrlCalls ())
136
- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
131
+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
137
132
});
138
133
139
134
testWidgets ('relative links are resolved' , (tester) async {
140
135
await prepareContent (tester,
141
136
'<p><a href="/a/b?c#d">word</a></p>' );
142
137
await tester.tap (find.text ('word' ));
143
138
check (testBinding.takeLaunchUrlCalls ())
144
- .single.equals ((url: Uri .parse ('${eg .realmUrl }a/b?c#d' ), mode: expectedModeAndroid ));
139
+ .single.equals ((url: Uri .parse ('${eg .realmUrl }a/b?c#d' ), mode: LaunchMode .platformDefault ));
145
140
});
146
141
147
142
testWidgets ('link inside HeadingNode' , (tester) async {
148
143
await prepareContent (tester,
149
144
'<h6><a href="https://a/">word</a></h6>' );
150
145
await tester.tap (find.text ('word' ));
151
146
check (testBinding.takeLaunchUrlCalls ())
152
- .single.equals ((url: Uri .parse ('https://a/' ), mode: expectedModeAndroid ));
147
+ .single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault ));
153
148
});
154
149
155
150
testWidgets ('error dialog if invalid link' , (tester) async {
@@ -159,7 +154,7 @@ void main() {
159
154
await tester.tap (find.text ('word' ));
160
155
await tester.pump ();
161
156
check (testBinding.takeLaunchUrlCalls ())
162
- .single.equals ((url: Uri .parse ('file:///etc/bad' ), mode: expectedModeAndroid ));
157
+ .single.equals ((url: Uri .parse ('file:///etc/bad' ), mode: LaunchMode .platformDefault ));
163
158
checkErrorDialog (tester, expectedTitle: 'Unable to open link' );
164
159
});
165
160
});
@@ -206,7 +201,7 @@ void main() {
206
201
await tester.tap (find.text ('invalid' ));
207
202
final expectedUrl = eg.realmUrl.resolve ('/#narrow/stream/1-check/topic' );
208
203
check (testBinding.takeLaunchUrlCalls ())
209
- .single.equals ((url: expectedUrl, mode: LaunchMode .externalApplication ));
204
+ .single.equals ((url: expectedUrl, mode: LaunchMode .platformDefault ));
210
205
check (pushedRoutes).isEmpty ();
211
206
});
212
207
});
0 commit comments