Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
flutter_markdown adjustments
  • Loading branch information
stuartmorgan-g committed Jun 30, 2023
commit 6608914cfbcb7e77ea2b96b19ba6964152c6da84
26 changes: 25 additions & 1 deletion packages/flutter_markdown/test/image_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:io' as io;

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
Expand Down Expand Up @@ -90,7 +91,7 @@ void defineTests() {
);

testWidgets(
'local files should be files',
'local files should be files on non-web',
(WidgetTester tester) async {
const String data = '![alt](http.png)';
await tester.pumpWidget(
Expand All @@ -105,6 +106,26 @@ void defineTests() {

expect(image.image is FileImage, isTrue);
},
skip: kIsWeb,
);

testWidgets(
'local files should be network on web',
(WidgetTester tester) async {
const String data = '![alt](http.png)';
await tester.pumpWidget(
boilerplate(
const Markdown(data: data),
),
);

final Iterable<Widget> widgets = tester.allWidgets;
final Image image =
widgets.firstWhere((Widget widget) => widget is Image) as Image;

expect(image.image is NetworkImage, isTrue);
},
skip: !kIsWeb,
);

testWidgets(
Expand Down Expand Up @@ -150,6 +171,7 @@ void defineTests() {
matchesGoldenFile(
'assets/images/golden/image_test/resource_asset_logo.png'));
},
skip: kIsWeb, // Goldens are platform-specific.
);

testWidgets(
Expand All @@ -168,6 +190,7 @@ void defineTests() {
expect(image.width, 50);
expect(image.height, 50);
},
skip: kIsWeb,
);

testWidgets(
Expand Down Expand Up @@ -360,6 +383,7 @@ void defineTests() {
matchesGoldenFile(
'assets/images/golden/image_test/custom_builder_asset_logo.png'));
},
skip: kIsWeb, // Goldens are platform-specific.
);
});
}
10 changes: 8 additions & 2 deletions packages/flutter_markdown/test/link_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
Expand Down Expand Up @@ -1147,8 +1148,13 @@ void defineTests() {
final Finder imageFinder = find.byType(Image);
expect(imageFinder, findsOneWidget);
final Image image = imageFinder.evaluate().first.widget as Image;
final FileImage fi = image.image as FileImage;
expect(fi.file.path, equals('uri3'));
if (kIsWeb) {
final NetworkImage fi = image.image as NetworkImage;
expect(fi.url.endsWith('uri3'), true);
} else {
final FileImage fi = image.image as FileImage;
expect(fi.file.path, equals('uri3'));
}
expect(linkTapResults, isNull);
},
);
Expand Down