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/test/widget_tests.dart b/test/widget_tests.dart new file mode 100644 index 0000000..eae3dbf --- /dev/null +++ b/test/widget_tests.dart @@ -0,0 +1,122 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter/material.dart'; +import 'package:status_alert/src/widgets/status_alert_base_widget.dart'; +import 'package:status_alert/src/utils/status_allert_manager.dart'; +import 'package:status_alert/status_alert.dart'; + +void main() { + group('Status Alert Test', () { + final statusAlert = StatusAlertBaseWidget( + duration: Duration(minutes: 1), + title: 'Subscribed', + margin: const EdgeInsets.all(40.0), + padding: EdgeInsets.zero, + subtitle: 'test', + alignment: Alignment.center, + blurPower: 15, + maxWidth: 260, + titleOptions: StatusAlertTextConfiguration( + style: TextStyle( + color: Colors.red, + fontSize: 23, + fontWeight: FontWeight.w600, + ), + ), + subtitleOptions: StatusAlertTextConfiguration( + style: TextStyle( + color: Colors.orange, + fontSize: 16, + fontWeight: FontWeight.w400, + ), + ), + borderRadius: const BorderRadius.all(Radius.circular(10.0)), + onHide: StatusAlertManager.dismiss, + configuration: IconConfiguration( + icon: Icons.favorite_border, + color: Colors.blue, + ), + backgroundColor: Colors.green, + ); + + testWidgets('Widget should render correctly', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + + expect(find.byType(StatusAlertBaseWidget), findsOneWidget); + }); + }); + + testWidgets('Title content should match', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + + expect(find.text('Subscribed'), findsOneWidget); + }); + }); + + testWidgets('Title style should match', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + + final titleWidget = tester.widget(find.text('Subscribed')); + + expect(titleWidget.style?.color, Colors.red); + expect(titleWidget.style?.fontSize, 23); + expect(titleWidget.style?.fontWeight, FontWeight.w600); + }); + }); + + testWidgets('SubTitle content should match', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + + expect(find.text('test'), findsOneWidget); + }); + }); + + testWidgets('SubTitle style should match', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + + final titleWidget = tester.widget(find.text('test')); + + expect(titleWidget.style?.color, Colors.orange); + expect(titleWidget.style?.fontSize, 16); + expect(titleWidget.style?.fontWeight, FontWeight.w400); + }); + }); + + testWidgets('Widget color should match', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + + final statusAlertWidget = tester + .widget(find.byType(StatusAlertBaseWidget)); + + expect(statusAlertWidget.backgroundColor, Colors.green); + }); + }); + + testWidgets('Icon content should match', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + + expect(find.byIcon(Icons.favorite_border), findsOneWidget); + }); + }); + + testWidgets('Icon colour should match', (tester) async { + await tester.runAsync(() async { + await tester.pumpWidget(_wrapWithMaterialApp(statusAlert)); + final iconWidget = + tester.widget(find.byIcon(Icons.favorite_border)); + + expect(iconWidget.color, Colors.blue); + }); + }); + }); +} + +Widget _wrapWithMaterialApp(Widget testWidget) { + return MaterialApp(home: testWidget); +}