Skip to content

Commit 27699de

Browse files
committed
msglist test: Use default screen size
This size is in *physical* pixels, not logical -- so with the tests' default device pixel ratio of 3, it corresponds to 200w267h in logical pixels, which is a very small screen. (It's a bit over 2 inches (53mm) diagonal when converted at 160px/in, which is the nominal value for a logical pixel.) Better to use the default size, which is somewhat more realistic. In particular, we have a known issue (#282) that the recipient headers suffer overflow if a stream name is long. This tiny screen causes that issue to appear even when a name is not very long at all; and when we add dates to the recipient headers (#172), it would start happening in the tests as they stand. A handful of tests need adjustments to keep working with the new size, mostly just to fill the message list with more messages.
1 parent 412233c commit 27699de

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

lib/widgets/message_list.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ class StreamTopicRecipientHeader extends StatelessWidget {
427427
child: ColoredBox(
428428
color: _kStreamMessageBorderColor,
429429
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
430-
// TODO: Long stream name will break layout; find a fix.
430+
// TODO(#282): Long stream name will break layout; find a fix.
431431
GestureDetector(
432432
onTap: () => Navigator.push(context,
433433
MessageListPage.buildRoute(context: context,

test/widgets/message_list_test.dart

+10-13
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ void main() {
3333
List<Message>? messages,
3434
}) async {
3535
addTearDown(testBinding.reset);
36-
addTearDown(tester.view.resetPhysicalSize);
37-
38-
tester.view.physicalSize = const Size(600, 800);
39-
4036
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
4137
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
4238
connection = store.connection as FakeApiConnection;
@@ -72,8 +68,8 @@ void main() {
7268

7369
testWidgets('basic', (tester) async {
7470
await setupMessageListPage(tester, foundOldest: false,
75-
messages: List.generate(30, (i) => eg.streamMessage(id: 950 + i, sender: eg.selfUser)));
76-
check(itemCount(tester)).equals(30);
71+
messages: List.generate(100, (i) => eg.streamMessage(id: 950 + i, sender: eg.selfUser)));
72+
check(itemCount(tester)).equals(100);
7773

7874
// Fling-scroll upward...
7975
await tester.fling(find.byType(MessageListPage), const Offset(0, 300), 8000);
@@ -86,13 +82,13 @@ void main() {
8682
await tester.pump(Duration.zero); // Allow a frame for the response to arrive.
8783

8884
// Now we have more messages.
89-
check(itemCount(tester)).equals(130);
85+
check(itemCount(tester)).equals(200);
9086
});
9187

9288
testWidgets('observe double-fetch glitch', (tester) async {
9389
await setupMessageListPage(tester, foundOldest: false,
94-
messages: List.generate(30, (i) => eg.streamMessage(id: 950 + i, sender: eg.selfUser)));
95-
check(itemCount(tester)).equals(30);
90+
messages: List.generate(100, (i) => eg.streamMessage(id: 950 + i, sender: eg.selfUser)));
91+
check(itemCount(tester)).equals(100);
9692

9793
// Fling-scroll upward...
9894
await tester.fling(find.byType(MessageListPage), const Offset(0, 300), 8000);
@@ -101,17 +97,17 @@ void main() {
10197
// ... and we fetch more messages as we go.
10298
connection.prepare(json: olderResult(anchor: 950, foundOldest: false,
10399
messages: List.generate(100, (i) => eg.streamMessage(id: 850 + i, sender: eg.selfUser))).toJson());
104-
await tester.pump(const Duration(seconds: 2));
100+
await tester.pump(const Duration(milliseconds: 500));
105101
await tester.pump(Duration.zero);
106-
check(itemCount(tester)).equals(130);
102+
check(itemCount(tester)).equals(200);
107103

108104
// But on the next frame, we promptly fetch *another* batch.
109105
// This is a glitch and it'd be nicer if we didn't.
110106
connection.prepare(json: olderResult(anchor: 850, foundOldest: false,
111107
messages: List.generate(100, (i) => eg.streamMessage(id: 750 + i, sender: eg.selfUser))).toJson());
112108
await tester.pump(const Duration(milliseconds: 1));
113109
await tester.pump(Duration.zero);
114-
check(itemCount(tester)).equals(230);
110+
check(itemCount(tester)).equals(300);
115111
});
116112
});
117113

@@ -140,7 +136,7 @@ void main() {
140136
});
141137

142138
testWidgets('dimension updates changes visibility', (WidgetTester tester) async {
143-
await setupMessageListPage(tester, messageCount: 10);
139+
await setupMessageListPage(tester, messageCount: 100);
144140

145141
final scrollController = findMessageListScrollController(tester)!;
146142

@@ -151,6 +147,7 @@ void main() {
151147
await tester.pump();
152148
check(isButtonVisible(tester)).equals(true);
153149

150+
addTearDown(tester.view.resetPhysicalSize);
154151
tester.view.physicalSize = const Size(2000, 40000);
155152
await tester.pump();
156153
// Dimension changes use NotificationListener<ScrollMetricsNotification

0 commit comments

Comments
 (0)