Skip to content

Commit

Permalink
Add widget tests for status alert widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
sawel24 committed Oct 5, 2022
1 parent b06db4d commit b05b60a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
77 changes: 77 additions & 0 deletions example/test/widget_tests.dart
Original file line number Diff line number Diff line change
@@ -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),
);
},
),
),
);
}
}

0 comments on commit b05b60a

Please sign in to comment.