From b05b60a8ad8916d31b694a34409111f1e2d93f37 Mon Sep 17 00:00:00 2001 From: sawel24 Date: Wed, 5 Oct 2022 16:06:47 +0300 Subject: [PATCH] Add widget tests for status alert widgets --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 6 +- example/ios/Runner/Info.plist | 2 + example/test/widget_tests.dart | 77 ++++++++++++++++++++ 4 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 example/test/widget_tests.dart diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index f2872cf..4f8d4d2 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index eba300f..2627b71 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -281,7 +281,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -364,7 +364,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -413,7 +413,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index a060db6..1579fb3 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -41,5 +41,7 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/example/test/widget_tests.dart b/example/test/widget_tests.dart new file mode 100644 index 0000000..02f8ef3 --- /dev/null +++ b/example/test/widget_tests.dart @@ -0,0 +1,77 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:status_alert/status_alert.dart'; + +void main() { + testWidgets('Test Alert Widget', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(TestApp()); + + final listTileFinder = find.text('Ones and Zeros'); + final iconButtonFinder = find.byIcon(Icons.favorite_border); + final alertFinder = find.text('Loved'); + + await tester.tap(iconButtonFinder); + + await tester.pumpAndSettle(const Duration(seconds:1)); + + await tester.ensureVisible(alertFinder); + + expect(alertFinder, findsOneWidget); + expect(listTileFinder, findsOneWidget); + expect(iconButtonFinder, findsWidgets); + }); + }); +} + +class TestApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.deepPurple, + brightness: Brightness.light, + ), + darkTheme: ThemeData( + brightness: Brightness.dark, + ), + home: StatusAlertScreen(), + ); + } +} + +class StatusAlertScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('Status Alert')), + body: ListTile( + leading: ClipRRect( + borderRadius: BorderRadius.circular(8), + child: Container( + width: 40, + height: 40, + color: Colors.black, + ), + ), + title: Text('Ones and Zeros'), + subtitle: Text('Young Guns'), + trailing: IconButton( + icon: Icon(Icons.favorite_border), + onPressed: () { + StatusAlert.show( + + context, + duration: Duration(seconds: 3), + title: 'Loved', + subtitle: 'We\'ll recommend more like this For You.', + configuration: IconConfiguration(icon: Icons.favorite_border), + ); + }, + ), + ), + ); + } +}