93 lines
3.6 KiB
Dart
93 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:ikar/backend/modules/messages.dart';
|
|
import 'package:ikar/frontend/widgets/message_bubble.dart';
|
|
import 'package:ikar/l10n/app_localizations.dart';
|
|
import 'package:ikar/models/attachment.dart';
|
|
import 'package:ikar/models/animoji.dart';
|
|
|
|
void main() {
|
|
for (final attachment in <MessageAttachment>[
|
|
const AudioAttachment(duration: 11000),
|
|
const VideoAttachment(width: 720, height: 1280),
|
|
const VideoAttachment(videoType: 1),
|
|
const PhotoAttachment(width: 0, height: 0),
|
|
const ForwardedMessageAttachment(
|
|
originalSenderId: 4,
|
|
originalAttachments: [AudioAttachment(duration: 11000)],
|
|
),
|
|
const ForwardedMessageAttachment(
|
|
originalSenderId: 4,
|
|
originalAttachments: [VideoAttachment(width: 720, height: 1280)],
|
|
),
|
|
]) {
|
|
for (final count
|
|
in attachment is PhotoAttachment ||
|
|
(attachment is VideoAttachment && !attachment.isNote)
|
|
? [1, 2, 3, 4]
|
|
: [1]) {
|
|
for (final reacted in [false, true]) {
|
|
testWidgets(
|
|
'media remain finite, count=$count reactions=$reacted type=${attachment.runtimeType} note=${attachment is VideoAttachment ? attachment.videoType : null}',
|
|
(tester) async {
|
|
final controller = ScrollController();
|
|
addTearDown(controller.dispose);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: Scaffold(
|
|
body: ListView.builder(
|
|
controller: controller,
|
|
reverse: true,
|
|
scrollCacheExtent: const ScrollCacheExtent.pixels(5000),
|
|
itemCount: 30,
|
|
itemBuilder: (_, index) => MessageBubble(
|
|
message: CachedMessage(
|
|
id: '$index',
|
|
accountId: 1,
|
|
chatId: 2,
|
|
senderId: 3,
|
|
time: 1000,
|
|
status: 'sent',
|
|
attachments: List.filled(count, attachment),
|
|
payload: reacted
|
|
? {
|
|
'reactionInfo': {
|
|
'totalCount': 1,
|
|
'counters': [
|
|
{'reaction': '🔥', 'count': 1},
|
|
],
|
|
},
|
|
}
|
|
: null,
|
|
),
|
|
isMe: false,
|
|
myId: 1,
|
|
chatType: 'DIALOG',
|
|
reactionAnimojiResolver: (emoji) => Animoji(
|
|
id: 1,
|
|
emoji: emoji,
|
|
iconUrl: 'https://example.com/a.png',
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
expect(tester.takeException(), isNull);
|
|
expect(controller.position.maxScrollExtent.isFinite, isTrue);
|
|
await tester.drag(find.byType(ListView), const Offset(0, 1200));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
expect(controller.position.pixels.isFinite, isTrue);
|
|
expect(find.byType(MessageBubble), findsWidgets);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|