Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import 'package:google_sign_in_web/src/flexible_size_html_element_view.dart';
import 'package:integration_test/integration_test.dart';
import 'package:web/web.dart' as web;

// TODO(stuartmorgan): Re-enable this test, by renaming it not to end with
// _disabled. It is currently extremely flaky on WASM, see
// https://github.com/flutter/flutter/issues/176299

/// Used to keep track of the number of HtmlElementView factories the test has registered.
int widgetFactoryNumber = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,83 +38,80 @@ void main() {
});

group('Link Widget', () {
testWidgets(
'creates anchor with correct attributes',
(WidgetTester tester) async {
final Uri uri = Uri.parse('http://foobar/example?q=1');
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebLinkDelegate(
TestLinkInfo(
uri: uri,
target: LinkTarget.blank,
builder: (BuildContext context, FollowLink? followLink) {
return const SizedBox(width: 100, height: 100);
},
),
testWidgets('creates anchor with correct attributes', (
WidgetTester tester,
) async {
final Uri uri = Uri.parse('http://foobar/example?q=1');
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebLinkDelegate(
TestLinkInfo(
uri: uri,
target: LinkTarget.blank,
builder: (BuildContext context, FollowLink? followLink) {
return const SizedBox(width: 100, height: 100);
},
),
),
);
// Platform view creation happens asynchronously.
await tester.pumpAndSettle();
await tester.pump();

final html.Element anchor = _findSingleAnchor();
expect(anchor.getAttribute('href'), uri.toString());
expect(anchor.getAttribute('target'), '_blank');

final Uri uri2 = Uri.parse('http://foobar2/example?q=2');
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebLinkDelegate(
TestLinkInfo(
uri: uri2,
target: LinkTarget.self,
builder: (BuildContext context, FollowLink? followLink) {
return const SizedBox(width: 100, height: 100);
},
),
),
);
// Platform view creation happens asynchronously.
await tester.pumpAndSettle();
await tester.pump();

final html.Element anchor = _findSingleAnchor();
expect(anchor.getAttribute('href'), uri.toString());
expect(anchor.getAttribute('target'), '_blank');

final Uri uri2 = Uri.parse('http://foobar2/example?q=2');
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebLinkDelegate(
TestLinkInfo(
uri: uri2,
target: LinkTarget.self,
builder: (BuildContext context, FollowLink? followLink) {
return const SizedBox(width: 100, height: 100);
},
),
),
);
await tester.pumpAndSettle();
await tester.pump();

// Check that the same anchor has been updated.
expect(anchor.getAttribute('href'), uri2.toString());
expect(anchor.getAttribute('target'), '_self');

final Uri uri3 = Uri.parse('/foobar');
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebLinkDelegate(
TestLinkInfo(
uri: uri3,
target: LinkTarget.self,
builder: (BuildContext context, FollowLink? followLink) {
return const SizedBox(width: 100, height: 100);
},
),
),
);
await tester.pumpAndSettle();
await tester.pump();

// Check that the same anchor has been updated.
expect(anchor.getAttribute('href'), uri2.toString());
expect(anchor.getAttribute('target'), '_self');

final Uri uri3 = Uri.parse('/foobar');
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebLinkDelegate(
TestLinkInfo(
uri: uri3,
target: LinkTarget.self,
builder: (BuildContext context, FollowLink? followLink) {
return const SizedBox(width: 100, height: 100);
},
),
),
);
await tester.pumpAndSettle();
await tester.pump();

// Check that internal route properly prepares using the default
// [UrlStrategy]
expect(
anchor.getAttribute('href'),
ui_web.urlStrategy?.prepareExternalUrl(uri3.toString()),
);
expect(anchor.getAttribute('target'), '_self');
},
// Flaky under WASM: https://github.com/flutter/flutter/issues/182844
skip: true,
);
),
);
await tester.pumpAndSettle();
await tester.pump();

// Check that internal route properly prepares using the default
// [UrlStrategy]
expect(
anchor.getAttribute('href'),
ui_web.urlStrategy?.prepareExternalUrl(uri3.toString()),
);
expect(anchor.getAttribute('target'), '_self');
});

testWidgets('sizes itself correctly', (WidgetTester tester) async {
final Key containerKey = GlobalKey();
Expand Down
Loading