show images to detected URLs
This commit is contained in:
1 parent
98f6cf3745
commit
55529c3a61
10 files changed
+477
-68
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/helpers/message_image_helper.dart';
|
||||
|
||||
void main() {
|
||||
group('MessageImageHelper', () {
|
||||
test('parses short pyx ids', () {
|
||||
final attachment = MessageImageHelper.parse(
|
||||
'my picture: https://pyx.li/?i=RzmdkTsE text',
|
||||
);
|
||||
|
||||
expect(attachment, isNotNull);
|
||||
expect(attachment, 'https://pyx.li/i/RzmdkTsE.jpg');
|
||||
});
|
||||
|
||||
test('parses direct pyx image urls', () {
|
||||
final attachment = MessageImageHelper.parse('https://pyx.li/?i=Cd1KFiwu');
|
||||
|
||||
expect(attachment, isNotNull);
|
||||
expect(attachment, 'https://pyx.li/i/Cd1KFiwu.jpg');
|
||||
});
|
||||
|
||||
test('parses provider-hosted ipfs links', () {
|
||||
final attachment = MessageImageHelper.parse(
|
||||
'my picture: https://uneven-plum-tarantula.myfilebase.com/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text',
|
||||
);
|
||||
|
||||
expect(attachment, isNotNull);
|
||||
expect(
|
||||
attachment,
|
||||
'https://uneven-plum-tarantula.myfilebase.com/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly',
|
||||
);
|
||||
});
|
||||
|
||||
test('parses direct ipfs cid urls', () {
|
||||
final attachment = MessageImageHelper.parse(
|
||||
'my picture: ipfs://bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text',
|
||||
);
|
||||
|
||||
expect(attachment, isNotNull);
|
||||
expect(
|
||||
attachment,
|
||||
'https://ipfs.io/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly',
|
||||
);
|
||||
});
|
||||
|
||||
test('parses http image urls', () {
|
||||
final attachment = MessageImageHelper.parse(
|
||||
'see this image https://example.com/picture.png?size=large additional text',
|
||||
);
|
||||
|
||||
expect(attachment, isNotNull);
|
||||
expect(attachment, 'https://example.com/picture.png?size=large');
|
||||
});
|
||||
|
||||
test('returns null for plain text', () {
|
||||
expect(MessageImageHelper.parse('hello world'), isNull);
|
||||
});
|
||||
|
||||
test('returns null for non-image ipfs gateway url', () async {
|
||||
final attachment = await MessageImageHelper.parseVerified(
|
||||
'https://lime-famous-rat-748.mypinata.cloud/ipfs/bafybeih3jqv36rsxqx7yw3k3ixhganrevrk7xmcxgkr2zuzjegxdytb3nq',
|
||||
);
|
||||
|
||||
expect(attachment, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -643,7 +643,6 @@ void main() {
|
||||
expect(contacts.first.path, equals(Uint8List.fromList([0x11, 0x22])));
|
||||
},
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
group('AppSettingsService — gps interval fallback', () {
|
||||
|
||||
@@ -22,7 +22,8 @@ class _FakeStorageService extends StorageService {
|
||||
ContactPathHistory history,
|
||||
) async {}
|
||||
@override
|
||||
Future<ContactPathHistory?> loadPathHistory(String contactPubKeyHex) async => null;
|
||||
Future<ContactPathHistory?> loadPathHistory(String contactPubKeyHex) async =>
|
||||
null;
|
||||
@override
|
||||
Future<void> clearPathHistory(String contactPubKeyHex) async {}
|
||||
}
|
||||
@@ -71,13 +72,18 @@ Widget _buildTestApp({
|
||||
required MeshCoreConnector connector,
|
||||
required Widget child,
|
||||
}) {
|
||||
final appSettingsService = AppSettingsService();
|
||||
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<MeshCoreConnector>.value(value: connector),
|
||||
ChangeNotifierProvider<AppSettingsService>(
|
||||
create: (_) => AppSettingsService(),
|
||||
ChangeNotifierProvider<AppSettingsService>.value(
|
||||
value: appSettingsService,
|
||||
),
|
||||
ChangeNotifierProvider<MapTileCacheService>(
|
||||
create: (_) =>
|
||||
MapTileCacheService(appSettingsService: appSettingsService),
|
||||
),
|
||||
Provider<MapTileCacheService>(create: (_) => MapTileCacheService()),
|
||||
ChangeNotifierProvider<PathHistoryService>(
|
||||
create: (_) => PathHistoryService(_FakeStorageService()),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user