@@ -62,6 +62,13 @@ void main() {
62
62
});
63
63
});
64
64
65
+ Future <void > tapText (WidgetTester tester, Finder textFinder) async {
66
+ final height = tester.getSize (textFinder).height;
67
+ final target = tester.getTopLeft (textFinder)
68
+ .translate (height/ 4 , height/ 2 ); // aim for middle of first letter
69
+ await tester.tapAt (target);
70
+ }
71
+
65
72
group ('LinkNode interactions' , () {
66
73
// The Flutter test font uses square glyphs, so width equals height:
67
74
// https://github.com/flutter/flutter/wiki/Flutter-Test-Fonts
@@ -85,7 +92,7 @@ void main() {
85
92
await prepareContent (tester,
86
93
'<p><a href="https://example/">hello</a></p>' );
87
94
88
- await tester. tap ( find.text ('hello' ));
95
+ await tapText (tester, find.text ('hello' ));
89
96
check (testBinding.takeLaunchUrlCalls ())
90
97
.single.equals ((url: Uri .parse ('https://example/' ), mode: LaunchMode .platformDefault));
91
98
}, variant: const TargetPlatformVariant ({TargetPlatform .android, TargetPlatform .iOS}));
@@ -111,7 +118,7 @@ void main() {
111
118
testWidgets ('link nested in other spans' , (tester) async {
112
119
await prepareContent (tester,
113
120
'<p><strong><em><a href="https://a/">word</a></em></strong></p>' );
114
- await tester. tap ( find.text ('word' ));
121
+ await tapText (tester, find.text ('word' ));
115
122
check (testBinding.takeLaunchUrlCalls ())
116
123
.single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault));
117
124
});
@@ -134,15 +141,15 @@ void main() {
134
141
testWidgets ('relative links are resolved' , (tester) async {
135
142
await prepareContent (tester,
136
143
'<p><a href="/a/b?c#d">word</a></p>' );
137
- await tester. tap ( find.text ('word' ));
144
+ await tapText (tester, find.text ('word' ));
138
145
check (testBinding.takeLaunchUrlCalls ())
139
146
.single.equals ((url: Uri .parse ('${eg .realmUrl }a/b?c#d' ), mode: LaunchMode .platformDefault));
140
147
});
141
148
142
149
testWidgets ('link inside HeadingNode' , (tester) async {
143
150
await prepareContent (tester,
144
151
'<h6><a href="https://a/">word</a></h6>' );
145
- await tester. tap ( find.text ('word' ));
152
+ await tapText (tester, find.text ('word' ));
146
153
check (testBinding.takeLaunchUrlCalls ())
147
154
.single.equals ((url: Uri .parse ('https://a/' ), mode: LaunchMode .platformDefault));
148
155
});
@@ -151,7 +158,7 @@ void main() {
151
158
await prepareContent (tester,
152
159
'<p><a href="file:///etc/bad">word</a></p>' );
153
160
testBinding.launchUrlResult = false ;
154
- await tester. tap ( find.text ('word' ));
161
+ await tapText (tester, find.text ('word' ));
155
162
await tester.pump ();
156
163
check (testBinding.takeLaunchUrlCalls ())
157
164
.single.equals ((url: Uri .parse ('file:///etc/bad' ), mode: LaunchMode .platformDefault));
@@ -187,7 +194,7 @@ void main() {
187
194
final pushedRoutes = await prepareContent (tester,
188
195
html: '<p><a href="/#narrow/stream/1-check">stream</a></p>' );
189
196
190
- await tester. tap ( find.text ('stream' ));
197
+ await tapText (tester, find.text ('stream' ));
191
198
check (testBinding.takeLaunchUrlCalls ()).isEmpty ();
192
199
check (pushedRoutes).single.isA <WidgetRoute >()
193
200
.page.isA <MessageListPage >().narrow.equals (const StreamNarrow (1 ));
@@ -198,7 +205,7 @@ void main() {
198
205
final pushedRoutes = await prepareContent (tester,
199
206
html: '<p><a href="/#narrow/stream/1-check/topic">invalid</a></p>' );
200
207
201
- await tester. tap ( find.text ('invalid' ));
208
+ await tapText (tester, find.text ('invalid' ));
202
209
final expectedUrl = eg.realmUrl.resolve ('/#narrow/stream/1-check/topic' );
203
210
check (testBinding.takeLaunchUrlCalls ())
204
211
.single.equals ((url: expectedUrl, mode: LaunchMode .platformDefault));
0 commit comments