slivers_padding_test.dart 17.2 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1 2 3 4 5 6
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
7
import 'package:flutter/widgets.dart';
Ian Hickson's avatar
Ian Hickson committed
8

9
Future<void> test(WidgetTester tester, double offset, EdgeInsetsGeometry padding, AxisDirection axisDirection, TextDirection textDirection) {
10
  return tester.pumpWidget(
11
    Directionality(
12
      textDirection: textDirection,
13 14
      child: Viewport(
        offset: ViewportOffset.fixed(offset),
15 16
        axisDirection: axisDirection,
        slivers: <Widget>[
17
          const SliverToBoxAdapter(child: SizedBox(width: 400.0, height: 400.0, child: Text('before'))),
18
          SliverPadding(
19
            padding: padding,
20
            sliver: const SliverToBoxAdapter(child: SizedBox(width: 400.0, height: 400.0, child: Text('padded'))),
21
          ),
22
          const SliverToBoxAdapter(child: SizedBox(width: 400.0, height: 400.0, child: Text('after'))),
23
        ],
Ian Hickson's avatar
Ian Hickson committed
24
      ),
25
    ),
26
  );
Ian Hickson's avatar
Ian Hickson committed
27 28 29
}

void verify(WidgetTester tester, List<Rect> answerKey) {
30
  final List<Rect> testAnswers = tester.renderObjectList<RenderBox>(find.byType(SizedBox, skipOffstage: false)).map<Rect>(
Ian Hickson's avatar
Ian Hickson committed
31
    (RenderBox target) {
32 33
      final Offset topLeft = target.localToGlobal(Offset.zero);
      final Offset bottomRight = target.localToGlobal(target.size.bottomRight(Offset.zero));
34
      return Rect.fromPoints(topLeft, bottomRight);
Ian Hickson's avatar
Ian Hickson committed
35 36 37 38 39 40
    }
  ).toList();
  expect(testAnswers, equals(answerKey));
}

void main() {
41
  testWidgets('Viewport+SliverPadding basic test (VISUAL)', (WidgetTester tester) async {
42
    const EdgeInsets padding = EdgeInsets.fromLTRB(25.0, 20.0, 15.0, 35.0);
43
    await test(tester, 0.0, padding, AxisDirection.down, TextDirection.ltr);
Adam Barth's avatar
Adam Barth committed
44
    expect(tester.renderObject<RenderBox>(find.byType(Viewport)).size, equals(const Size(800.0, 600.0)));
Ian Hickson's avatar
Ian Hickson committed
45
    verify(tester, <Rect>[
46 47 48
      Rect.fromLTWH(0.0, 0.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, 420.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 855.0, 800.0, 400.0),
Ian Hickson's avatar
Ian Hickson committed
49 50
    ]);

51
    await test(tester, 200.0, padding, AxisDirection.down, TextDirection.ltr);
Ian Hickson's avatar
Ian Hickson committed
52
    verify(tester, <Rect>[
53 54 55
      Rect.fromLTWH(0.0, -200.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, 220.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 655.0, 800.0, 400.0),
Ian Hickson's avatar
Ian Hickson committed
56 57
    ]);

58
    await test(tester, 390.0, padding, AxisDirection.down, TextDirection.ltr);
Ian Hickson's avatar
Ian Hickson committed
59
    verify(tester, <Rect>[
60 61 62
      Rect.fromLTWH(0.0, -390.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, 30.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 465.0, 800.0, 400.0),
Ian Hickson's avatar
Ian Hickson committed
63 64
    ]);

65
    await test(tester, 490.0, padding, AxisDirection.down, TextDirection.ltr);
Ian Hickson's avatar
Ian Hickson committed
66
    verify(tester, <Rect>[
67 68 69
      Rect.fromLTWH(0.0, -490.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, -70.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 365.0, 800.0, 400.0),
Ian Hickson's avatar
Ian Hickson committed
70 71
    ]);

72
    await test(tester, 10000.0, padding, AxisDirection.down, TextDirection.ltr);
Ian Hickson's avatar
Ian Hickson committed
73
    verify(tester, <Rect>[
74 75 76
      Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, -9580.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0),
Ian Hickson's avatar
Ian Hickson committed
77 78 79
    ]);
  });

80
  testWidgets('Viewport+SliverPadding basic test (LTR)', (WidgetTester tester) async {
81
    const EdgeInsetsDirectional padding = EdgeInsetsDirectional.fromSTEB(25.0, 20.0, 15.0, 35.0);
82
    await test(tester, 0.0, padding, AxisDirection.down, TextDirection.ltr);
83 84
    expect(tester.renderObject<RenderBox>(find.byType(Viewport)).size, equals(const Size(800.0, 600.0)));
    verify(tester, <Rect>[
85 86 87
      Rect.fromLTWH(0.0, 0.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, 420.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 855.0, 800.0, 400.0),
88 89
    ]);

90
    await test(tester, 200.0, padding, AxisDirection.down, TextDirection.ltr);
91
    verify(tester, <Rect>[
92 93 94
      Rect.fromLTWH(0.0, -200.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, 220.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 655.0, 800.0, 400.0),
95 96
    ]);

97
    await test(tester, 390.0, padding, AxisDirection.down, TextDirection.ltr);
98
    verify(tester, <Rect>[
99 100 101
      Rect.fromLTWH(0.0, -390.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, 30.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 465.0, 800.0, 400.0),
102 103
    ]);

104
    await test(tester, 490.0, padding, AxisDirection.down, TextDirection.ltr);
105
    verify(tester, <Rect>[
106 107 108
      Rect.fromLTWH(0.0, -490.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, -70.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 365.0, 800.0, 400.0),
109 110
    ]);

111
    await test(tester, 10000.0, padding, AxisDirection.down, TextDirection.ltr);
112
    verify(tester, <Rect>[
113 114 115
      Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0),
      Rect.fromLTWH(25.0, -9580.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0),
116 117 118 119
    ]);
  });

  testWidgets('Viewport+SliverPadding basic test (RTL)', (WidgetTester tester) async {
120
    const EdgeInsetsDirectional padding = EdgeInsetsDirectional.fromSTEB(25.0, 20.0, 15.0, 35.0);
121
    await test(tester, 0.0, padding, AxisDirection.down, TextDirection.rtl);
122 123
    expect(tester.renderObject<RenderBox>(find.byType(Viewport)).size, equals(const Size(800.0, 600.0)));
    verify(tester, <Rect>[
124 125 126
      Rect.fromLTWH(0.0, 0.0, 800.0, 400.0),
      Rect.fromLTWH(15.0, 420.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 855.0, 800.0, 400.0),
127 128
    ]);

129
    await test(tester, 200.0, padding, AxisDirection.down, TextDirection.rtl);
130
    verify(tester, <Rect>[
131 132 133
      Rect.fromLTWH(0.0, -200.0, 800.0, 400.0),
      Rect.fromLTWH(15.0, 220.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 655.0, 800.0, 400.0),
134 135
    ]);

136
    await test(tester, 390.0, padding, AxisDirection.down, TextDirection.rtl);
137
    verify(tester, <Rect>[
138 139 140
      Rect.fromLTWH(0.0, -390.0, 800.0, 400.0),
      Rect.fromLTWH(15.0, 30.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 465.0, 800.0, 400.0),
141 142
    ]);

143
    await test(tester, 490.0, padding, AxisDirection.down, TextDirection.rtl);
144
    verify(tester, <Rect>[
145 146 147
      Rect.fromLTWH(0.0, -490.0, 800.0, 400.0),
      Rect.fromLTWH(15.0, -70.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, 365.0, 800.0, 400.0),
148 149
    ]);

150
    await test(tester, 10000.0, padding, AxisDirection.down, TextDirection.rtl);
151
    verify(tester, <Rect>[
152 153 154
      Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0),
      Rect.fromLTWH(15.0, -9580.0, 760.0, 400.0),
      Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0),
155 156 157
    ]);
  });

Adam Barth's avatar
Adam Barth committed
158
  testWidgets('Viewport+SliverPadding hit testing', (WidgetTester tester) async {
159
    const EdgeInsets padding = EdgeInsets.all(30.0);
160
    await test(tester, 350.0, padding, AxisDirection.down, TextDirection.ltr);
Adam Barth's avatar
Adam Barth committed
161
    expect(tester.renderObject<RenderBox>(find.byType(Viewport)).size, equals(const Size(800.0, 600.0)));
Ian Hickson's avatar
Ian Hickson committed
162
    verify(tester, <Rect>[
163 164 165
      Rect.fromLTWH(0.0, -350.0, 800.0, 400.0),
      Rect.fromLTWH(30.0, 80.0, 740.0, 400.0),
      Rect.fromLTWH(0.0, 510.0, 800.0, 400.0),
Ian Hickson's avatar
Ian Hickson committed
166 167
    ]);
    HitTestResult result;
168
    result = tester.hitTestOnBinding(const Offset(10.0, 10.0));
Ian Hickson's avatar
Ian Hickson committed
169
    expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
170
    result = tester.hitTestOnBinding(const Offset(10.0, 60.0));
171
    expect(result.path.first.target, isInstanceOf<RenderView>());
172
    result = tester.hitTestOnBinding(const Offset(100.0, 100.0));
Ian Hickson's avatar
Ian Hickson committed
173
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
174
    result = tester.hitTestOnBinding(const Offset(100.0, 490.0));
175
    expect(result.path.first.target, isInstanceOf<RenderView>());
176
    result = tester.hitTestOnBinding(const Offset(10.0, 520.0));
Ian Hickson's avatar
Ian Hickson committed
177 178 179
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
  });

Adam Barth's avatar
Adam Barth committed
180
  testWidgets('Viewport+SliverPadding hit testing up', (WidgetTester tester) async {
181
    const EdgeInsets padding = EdgeInsets.all(30.0);
182
    await test(tester, 350.0, padding, AxisDirection.up, TextDirection.ltr);
Adam Barth's avatar
Adam Barth committed
183
    expect(tester.renderObject<RenderBox>(find.byType(Viewport)).size, equals(const Size(800.0, 600.0)));
Ian Hickson's avatar
Ian Hickson committed
184
    verify(tester, <Rect>[
185 186 187
      Rect.fromLTWH(0.0, 600.0+350.0-400.0, 800.0, 400.0),
      Rect.fromLTWH(30.0, 600.0-80.0-400.0, 740.0, 400.0),
      Rect.fromLTWH(0.0, 600.0-510.0-400.0, 800.0, 400.0),
Ian Hickson's avatar
Ian Hickson committed
188 189
    ]);
    HitTestResult result;
190
    result = tester.hitTestOnBinding(const Offset(10.0, 600.0-10.0));
Ian Hickson's avatar
Ian Hickson committed
191
    expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
192
    result = tester.hitTestOnBinding(const Offset(10.0, 600.0-60.0));
193
    expect(result.path.first.target, isInstanceOf<RenderView>());
194
    result = tester.hitTestOnBinding(const Offset(100.0, 600.0-100.0));
Ian Hickson's avatar
Ian Hickson committed
195
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
196
    result = tester.hitTestOnBinding(const Offset(100.0, 600.0-490.0));
197
    expect(result.path.first.target, isInstanceOf<RenderView>());
198
    result = tester.hitTestOnBinding(const Offset(10.0, 600.0-520.0));
Ian Hickson's avatar
Ian Hickson committed
199 200 201
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
  });

Adam Barth's avatar
Adam Barth committed
202
  testWidgets('Viewport+SliverPadding hit testing left', (WidgetTester tester) async {
203
    const EdgeInsets padding = EdgeInsets.all(30.0);
204
    await test(tester, 350.0, padding, AxisDirection.left, TextDirection.ltr);
Adam Barth's avatar
Adam Barth committed
205
    expect(tester.renderObject<RenderBox>(find.byType(Viewport)).size, equals(const Size(800.0, 600.0)));
Ian Hickson's avatar
Ian Hickson committed
206
    verify(tester, <Rect>[
207 208 209
      Rect.fromLTWH(800.0+350.0-400.0, 0.0, 400.0, 600.0),
      Rect.fromLTWH(800.0-80.0-400.0, 30.0, 400.0, 540.0),
      Rect.fromLTWH(800.0-510.0-400.0, 0.0, 400.0, 600.0),
Ian Hickson's avatar
Ian Hickson committed
210 211
    ]);
    HitTestResult result;
212
    result = tester.hitTestOnBinding(const Offset(800.0-10.0, 10.0));
Ian Hickson's avatar
Ian Hickson committed
213
    expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
214
    result = tester.hitTestOnBinding(const Offset(800.0-60.0, 10.0));
215
    expect(result.path.first.target, isInstanceOf<RenderView>());
216
    result = tester.hitTestOnBinding(const Offset(800.0-100.0, 100.0));
Ian Hickson's avatar
Ian Hickson committed
217
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
218
    result = tester.hitTestOnBinding(const Offset(800.0-490.0, 100.0));
219
    expect(result.path.first.target, isInstanceOf<RenderView>());
220
    result = tester.hitTestOnBinding(const Offset(800.0-520.0, 10.0));
Ian Hickson's avatar
Ian Hickson committed
221 222 223
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
  });

Adam Barth's avatar
Adam Barth committed
224
  testWidgets('Viewport+SliverPadding hit testing right', (WidgetTester tester) async {
225
    const EdgeInsets padding = EdgeInsets.all(30.0);
226
    await test(tester, 350.0, padding, AxisDirection.right, TextDirection.ltr);
Adam Barth's avatar
Adam Barth committed
227
    expect(tester.renderObject<RenderBox>(find.byType(Viewport)).size, equals(const Size(800.0, 600.0)));
Ian Hickson's avatar
Ian Hickson committed
228
    verify(tester, <Rect>[
229 230 231
      Rect.fromLTWH(-350.0, 0.0, 400.0, 600.0),
      Rect.fromLTWH(80.0, 30.0, 400.0, 540.0),
      Rect.fromLTWH(510.0, 0.0, 400.0, 600.0),
Ian Hickson's avatar
Ian Hickson committed
232 233
    ]);
    HitTestResult result;
234
    result = tester.hitTestOnBinding(const Offset(10.0, 10.0));
Ian Hickson's avatar
Ian Hickson committed
235
    expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
236
    result = tester.hitTestOnBinding(const Offset(60.0, 10.0));
237
    expect(result.path.first.target, isInstanceOf<RenderView>());
238
    result = tester.hitTestOnBinding(const Offset(100.0, 100.0));
Ian Hickson's avatar
Ian Hickson committed
239
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
240
    result = tester.hitTestOnBinding(const Offset(490.0, 100.0));
241
    expect(result.path.first.target, isInstanceOf<RenderView>());
242
    result = tester.hitTestOnBinding(const Offset(520.0, 10.0));
Ian Hickson's avatar
Ian Hickson committed
243 244 245
    expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
  });

Adam Barth's avatar
Adam Barth committed
246
  testWidgets('Viewport+SliverPadding no child', (WidgetTester tester) async {
247
    await tester.pumpWidget(
248
      Directionality(
249
        textDirection: TextDirection.ltr,
250 251
        child: Viewport(
          offset: ViewportOffset.fixed(0.0),
252
          slivers: const <Widget>[
253 254
            SliverPadding(padding: EdgeInsets.all(100.0)),
            SliverToBoxAdapter(child: SizedBox(width: 400.0, height: 400.0, child: Text('x'))),
255 256 257 258
          ],
        ),
      ),
    );
259
    expect(tester.renderObject<RenderBox>(find.text('x')).localToGlobal(Offset.zero), const Offset(0.0, 200.0));
Ian Hickson's avatar
Ian Hickson committed
260 261
  });

Adam Barth's avatar
Adam Barth committed
262
  testWidgets('Viewport+SliverPadding changing padding', (WidgetTester tester) async {
263
    await tester.pumpWidget(
264
      Directionality(
265
        textDirection: TextDirection.ltr,
266
        child: Viewport(
267
          axisDirection: AxisDirection.left,
268
          offset: ViewportOffset.fixed(0.0),
269
          slivers: const <Widget>[
270 271
            SliverPadding(padding: EdgeInsets.fromLTRB(90.0, 1.0, 110.0, 2.0)),
            SliverToBoxAdapter(child: SizedBox(width: 201.0, child: Text('x'))),
272 273 274 275
          ],
        ),
      ),
    );
276
    expect(tester.renderObject<RenderBox>(find.text('x')).localToGlobal(Offset.zero), const Offset(399.0, 0.0));
277
    await tester.pumpWidget(
278
      Directionality(
279
        textDirection: TextDirection.ltr,
280
        child: Viewport(
281
          axisDirection: AxisDirection.left,
282
          offset: ViewportOffset.fixed(0.0),
283
          slivers: const <Widget>[
284 285
            SliverPadding(padding: EdgeInsets.fromLTRB(110.0, 1.0, 80.0, 2.0)),
            SliverToBoxAdapter(child: SizedBox(width: 201.0, child: Text('x'))),
286 287 288 289
          ],
        ),
      ),
    );
290
    expect(tester.renderObject<RenderBox>(find.text('x')).localToGlobal(Offset.zero), const Offset(409.0, 0.0));
Ian Hickson's avatar
Ian Hickson committed
291 292
  });

Adam Barth's avatar
Adam Barth committed
293
  testWidgets('Viewport+SliverPadding changing direction', (WidgetTester tester) async {
294
    await tester.pumpWidget(
295
      Directionality(
296
        textDirection: TextDirection.ltr,
297
        child: Viewport(
298
          axisDirection: AxisDirection.up,
299
          offset: ViewportOffset.fixed(0.0),
300
          slivers: const <Widget>[
301
            SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)),
302 303 304 305
          ],
        ),
      ),
    );
306
    expect(tester.renderObject<RenderSliverPadding>(find.byType(SliverPadding)).afterPadding, 2.0);
307
    await tester.pumpWidget(
308
      Directionality(
309
        textDirection: TextDirection.ltr,
310
        child: Viewport(
311
          axisDirection: AxisDirection.down,
312
          offset: ViewportOffset.fixed(0.0),
313
          slivers: const <Widget>[
314
            SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)),
315 316 317 318
          ],
        ),
      ),
    );
319
    expect(tester.renderObject<RenderSliverPadding>(find.byType(SliverPadding)).afterPadding, 8.0);
320
    await tester.pumpWidget(
321
      Directionality(
322
        textDirection: TextDirection.ltr,
323
        child: Viewport(
324
          axisDirection: AxisDirection.right,
325
          offset: ViewportOffset.fixed(0.0),
326
          slivers: const <Widget>[
327
            SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)),
328 329 330 331
          ],
        ),
      ),
    );
332
    expect(tester.renderObject<RenderSliverPadding>(find.byType(SliverPadding)).afterPadding, 4.0);
333
    await tester.pumpWidget(
334
      Directionality(
335
        textDirection: TextDirection.ltr,
336
        child: Viewport(
337
          axisDirection: AxisDirection.left,
338
          offset: ViewportOffset.fixed(0.0),
339
          slivers: const <Widget>[
340
            SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)),
341 342 343 344
          ],
        ),
      ),
    );
345
    expect(tester.renderObject<RenderSliverPadding>(find.byType(SliverPadding)).afterPadding, 1.0);
346
    await tester.pumpWidget(
347
      Directionality(
348
        textDirection: TextDirection.ltr,
349
        child: Viewport(
350
          axisDirection: AxisDirection.left,
351
          offset: ViewportOffset.fixed(99999.9),
352
          slivers: const <Widget>[
353
            SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)),
354 355 356 357
          ],
        ),
      ),
    );
358
    expect(tester.renderObject<RenderSliverPadding>(find.byType(SliverPadding)).afterPadding, 1.0);
Ian Hickson's avatar
Ian Hickson committed
359
  });
360 361 362

  testWidgets('SliverPadding propagates geometry offset corrections', (WidgetTester tester) async {
    Widget listBuilder(IndexedWidgetBuilder sliverChildBuilder) {
363
      return Directionality(
364
        textDirection: TextDirection.ltr,
365
        child: CustomScrollView(
366
          cacheExtent: 0.0,
367
          slivers: <Widget>[
368
            SliverPadding(
369
              padding: EdgeInsets.zero,
370 371
              sliver: SliverList(
                delegate: SliverChildBuilderDelegate(
372 373 374 375 376 377 378 379 380 381 382 383 384
                  sliverChildBuilder,
                  childCount: 10,
                ),
              ),
            ),
          ],
        ),
      );
    }

    await tester.pumpWidget(
      listBuilder(
        (BuildContext context, int index) {
385
          return Container(
386
            height: 200.0,
387 388
            child: Center(
              child: Text(index.toString()),
389 390 391 392 393 394 395 396 397 398 399
            ),
          );
        },
      ),
    );

    await tester.drag(find.text('2'), const Offset(0.0, -300.0));
    await tester.pump();

    expect(
      tester.getRect(find.widgetWithText(Container, '2')),
400
      Rect.fromLTRB(0.0, 100.0, 800.0, 300.0),
401 402 403 404 405 406
    );

    // Now item 0 is 400.0px and going back will underflow.
    await tester.pumpWidget(
      listBuilder(
        (BuildContext context, int index) {
407
          return Container(
408
            height: index == 0 ? 400.0 : 200.0,
409 410
            child: Center(
              child: Text(index.toString()),
411 412 413 414 415 416 417 418 419 420 421 422
            ),
          );
        },
      ),
    );

    await tester.drag(find.text('2'), const Offset(0.0, 300.0));
    // On this one frame, the scroll correction must properly propagate.
    await tester.pump();

    expect(
      tester.getRect(find.widgetWithText(Container, '0')),
423
      Rect.fromLTRB(0.0, -200.0, 800.0, 200.0),
424 425
    );
  });
Ian Hickson's avatar
Ian Hickson committed
426
}