You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Dart
		
	
		
		
			
		
	
	
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Dart
		
	
| 
								 
											3 years ago
										 
									 | 
							
								import 'package:flutter_test/flutter_test.dart';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/// Workaround for https://github.com/flutter/flutter/issues/88765
							 | 
						||
| 
								 | 
							
								extension WaitForExtension on WidgetTester {
							 | 
						||
| 
								 | 
							
								  Future<void> waitFor(
							 | 
						||
| 
								 | 
							
								    Finder finder, {
							 | 
						||
| 
								 | 
							
								    Duration timeout = const Duration(seconds: 20),
							 | 
						||
| 
								 | 
							
								    bool skipPumpAndSettle = false,
							 | 
						||
| 
								 | 
							
								  }) async {
							 | 
						||
| 
								 | 
							
								    final end = DateTime.now().add(timeout);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    do {
							 | 
						||
| 
								 | 
							
								      if (DateTime.now().isAfter(end)) {
							 | 
						||
| 
								 | 
							
								        throw Exception('Timed out waiting for $finder');
							 | 
						||
| 
								 | 
							
								      }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      if (!skipPumpAndSettle) {
							 | 
						||
| 
								 | 
							
								        await pumpAndSettle();
							 | 
						||
| 
								 | 
							
								      }
							 | 
						||
| 
								 | 
							
								      await Future.delayed(const Duration(milliseconds: 100));
							 | 
						||
| 
								 | 
							
								    } while (finder.evaluate().isEmpty);
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								extension MaybeUppercaseFinder on CommonFinders {
							 | 
						||
| 
								 | 
							
								  /// On Android some button labels are in uppercase while on iOS they
							 | 
						||
| 
								 | 
							
								  /// are not. This method tries both.
							 | 
						||
| 
								 | 
							
								  Finder maybeUppercaseText(
							 | 
						||
| 
								 | 
							
								    String text, {
							 | 
						||
| 
								 | 
							
								    bool findRichText = false,
							 | 
						||
| 
								 | 
							
								    bool skipOffstage = true,
							 | 
						||
| 
								 | 
							
								  }) {
							 | 
						||
| 
								 | 
							
								    try {
							 | 
						||
| 
								 | 
							
								      final finder = find.text(
							 | 
						||
| 
								 | 
							
								        text.toUpperCase(),
							 | 
						||
| 
								 | 
							
								        findRichText: findRichText,
							 | 
						||
| 
								 | 
							
								        skipOffstage: skipOffstage,
							 | 
						||
| 
								 | 
							
								      );
							 | 
						||
| 
								 | 
							
								      expect(finder, findsOneWidget);
							 | 
						||
| 
								 | 
							
								      return finder;
							 | 
						||
| 
								 | 
							
								    } catch (_) {
							 | 
						||
| 
								 | 
							
								      return find.text(
							 | 
						||
| 
								 | 
							
								        text,
							 | 
						||
| 
								 | 
							
								        findRichText: findRichText,
							 | 
						||
| 
								 | 
							
								        skipOffstage: skipOffstage,
							 | 
						||
| 
								 | 
							
								      );
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 |