|
6 | 6 |
|
7 | 7 | import 'package:flutter/material.dart';
|
8 | 8 | import 'package:flutter_test/flutter_test.dart';
|
| 9 | +import 'package:intro_views_flutter/intro_views_flutter.dart'; |
9 | 10 |
|
10 | 11 | // ignore: avoid_relative_lib_imports
|
11 | 12 | import '../example/lib/main.dart';
|
@@ -133,4 +134,46 @@ void main() {
|
133 | 134 |
|
134 | 135 | expect(find.byKey(const Key('Portrait Page')), findsWidgets);
|
135 | 136 | });
|
| 137 | + |
| 138 | + testWidgets('should throw an assert if pages list is empty', ( |
| 139 | + WidgetTester tester, |
| 140 | + ) async { |
| 141 | + final pages = <PageViewModel>[]; |
| 142 | + |
| 143 | + await expectLater( |
| 144 | + () async => await tester.pumpWidget( |
| 145 | + IntroViewsFlutter(pages), |
| 146 | + ), |
| 147 | + throwsA( |
| 148 | + isAssertionError.having( |
| 149 | + (AssertionError error) => error.message, |
| 150 | + 'message', |
| 151 | + contains("At least one 'PageViewModel' item"), |
| 152 | + ), |
| 153 | + ), |
| 154 | + ); |
| 155 | + }); |
| 156 | + |
| 157 | + testWidgets('should not overflow if many bubbles', ( |
| 158 | + WidgetTester tester, |
| 159 | + ) async { |
| 160 | + final pages = List.generate( |
| 161 | + 15, |
| 162 | + (index) => PageViewModel( |
| 163 | + pageColor: const Color(0xFF03A9F4), |
| 164 | + title: Text('$index'), |
| 165 | + ), |
| 166 | + ); |
| 167 | + |
| 168 | + tester.binding.window.physicalSizeTestValue = const Size(500, 800); |
| 169 | + await tester.pumpWidget( |
| 170 | + MaterialApp( |
| 171 | + home: Builder( |
| 172 | + builder: (_) => IntroViewsFlutter(pages), |
| 173 | + ), |
| 174 | + ), |
| 175 | + ); |
| 176 | + |
| 177 | + expect(tester.takeException(), isNull); |
| 178 | + }); |
136 | 179 | }
|
0 commit comments