From 01a28960b88469f2b39731d9372b901f1d2920cf Mon Sep 17 00:00:00 2001 From: erluxman Date: Thu, 23 Jul 2020 09:50:23 +0545 Subject: [PATCH 1/4] Yet another attempt --- coverage/lcov.info | 365 +++++++++++++++++++ lib/features/splash/splash_screen.dart | 25 +- test/features/splash/splash_screen_test.dart | 6 +- 3 files changed, 385 insertions(+), 11 deletions(-) create mode 100644 coverage/lcov.info diff --git a/coverage/lcov.info b/coverage/lcov.info new file mode 100644 index 0000000..9959c24 --- /dev/null +++ b/coverage/lcov.info @@ -0,0 +1,365 @@ +SF:lib/utils/animation/scale_on_press_widget.dart +DA:7,3 +DA:14,3 +DA:22,4 +DA:23,4 +DA:29,0 +DA:31,2 +DA:33,1 +DA:34,2 +DA:35,1 +DA:39,4 +DA:41,4 +DA:43,2 +DA:44,0 +DA:45,2 +DA:46,0 +DA:47,4 +DA:48,4 +DA:49,4 +DA:50,8 +DA:51,4 +DA:52,8 +DA:53,4 +DA:54,8 +DA:55,6 +DA:57,4 +DA:58,8 +DA:60,8 +DA:61,4 +DA:62,4 +DA:63,4 +DA:65,4 +DA:66,4 +DA:67,4 +DA:70,4 +DA:72,8 +LF:35 +LH:32 +end_of_record +SF:lib/utils/animation/animated_scale.dart +DA:5,4 +DA:13,8 +DA:14,4 +DA:22,4 +DA:23,4 +DA:30,4 +DA:32,20 +DA:33,8 +DA:37,4 +DA:39,16 +DA:42,4 +DA:43,4 +DA:44,4 +DA:45,8 +DA:46,8 +LF:15 +LH:15 +end_of_record +SF:lib/common/resources/r.dart +DA:2,9 +DA:3,9 +DA:4,6 +DA:5,9 +DA:6,3 +DA:7,6 +LF:6 +LH:6 +end_of_record +SF:lib/features/home/widgets/home_app_bar.dart +DA:9,0 +DA:11,1 +DA:13,1 +DA:15,1 +DA:16,1 +DA:23,1 +DA:24,2 +DA:25,1 +DA:27,3 +DA:34,0 +DA:39,1 +DA:41,1 +DA:42,1 +DA:43,2 +DA:44,0 +DA:45,1 +DA:46,2 +DA:47,1 +DA:48,1 +DA:49,1 +LF:20 +LH:17 +end_of_record +SF:lib/features/home/widgets/home_bottom_nav_bar.dart +DA:7,0 +DA:9,1 +DA:10,1 +DA:17,0 +DA:18,0 +DA:19,0 +DA:23,0 +DA:24,0 +DA:25,0 +DA:29,0 +DA:31,0 +DA:33,0 +DA:35,0 +DA:37,0 +DA:39,1 +DA:41,1 +DA:49,1 +DA:54,1 +DA:62,1 +DA:64,1 +DA:65,1 +DA:66,1 +DA:67,1 +DA:68,1 +DA:69,1 +DA:70,1 +DA:72,2 +DA:73,1 +DA:76,1 +DA:77,1 +DA:78,1 +DA:79,1 +DA:80,1 +DA:81,1 +DA:83,2 +DA:84,1 +LF:36 +LH:24 +end_of_record +SF:lib/features/home/widgets/home_fab.dart +DA:8,0 +DA:10,1 +DA:12,1 +DA:15,0 +DA:16,0 +DA:18,2 +DA:20,1 +DA:22,1 +DA:23,2 +DA:25,1 +DA:28,1 +LF:11 +LH:8 +end_of_record +SF:lib/features/home/widgets/home_screen.dart +DA:10,0 +DA:12,1 +DA:14,1 +DA:16,1 +LF:4 +LH:3 +end_of_record +SF:lib/features/home/widgets/animated_circle_progress.dart +DA:9,0 +DA:14,0 +DA:15,0 +DA:21,1 +DA:23,1 +DA:32,1 +DA:34,1 +DA:35,5 +DA:36,2 +DA:38,2 +DA:39,3 +DA:40,2 +DA:41,4 +DA:42,2 +DA:43,2 +DA:45,2 +DA:48,1 +DA:50,1 +DA:52,5 +DA:53,5 +DA:57,1 +DA:59,2 +DA:60,2 +DA:61,1 +DA:66,1 +DA:67,9 +DA:77,1 +DA:79,2 +DA:80,1 +DA:81,1 +DA:82,1 +DA:83,2 +DA:85,1 +DA:86,1 +DA:87,2 +DA:88,1 +DA:89,1 +DA:90,5 +DA:91,1 +DA:92,1 +DA:94,1 +DA:95,1 +DA:96,5 +DA:97,1 +DA:98,1 +DA:99,1 +DA:100,1 +DA:102,1 +DA:105,0 +LF:49 +LH:45 +end_of_record +SF:lib/utils/extensions/gradient_extensions.dart +DA:4,3 +DA:5,6 +DA:8,1 +DA:9,2 +DA:12,4 +DA:13,4 +DA:15,4 +DA:16,4 +DA:22,2 +DA:25,2 +DA:26,2 +DA:27,2 +DA:35,12 +DA:36,6 +DA:38,4 +DA:39,4 +LF:16 +LH:16 +end_of_record +SF:lib/features/home/widgets/animated_nav_button.dart +DA:7,1 +DA:14,1 +DA:21,1 +DA:23,1 +DA:25,1 +DA:26,1 +DA:27,1 +DA:28,0 +DA:29,0 +DA:30,0 +DA:31,1 +DA:37,1 +DA:42,1 +DA:48,1 +DA:50,1 +DA:52,1 +DA:54,3 +DA:55,1 +DA:56,1 +DA:58,4 +DA:64,1 +DA:65,2 +DA:66,1 +DA:67,1 +DA:70,1 +DA:71,2 +DA:72,0 +DA:73,2 +DA:74,2 +DA:75,2 +DA:80,0 +DA:85,0 +DA:90,0 +DA:91,0 +DA:95,0 +DA:96,0 +DA:97,0 +LF:37 +LH:26 +end_of_record +SF:lib/features/home/widgets/home_body.dart +DA:5,0 +DA:7,1 +DA:9,1 +DA:10,3 +LF:4 +LH:3 +end_of_record +SF:lib/features/splash/splash_screen.dart +DA:12,2 +DA:14,2 +DA:15,2 +DA:21,2 +DA:23,2 +DA:24,10 +DA:31,2 +DA:38,2 +DA:40,2 +DA:41,4 +DA:46,2 +DA:48,2 +DA:50,2 +DA:53,2 +DA:55,6 +DA:57,2 +DA:58,4 +DA:59,2 +DA:60,2 +DA:70,1 +DA:72,1 +DA:74,2 +DA:76,2 +DA:78,0 +DA:79,0 +DA:84,2 +DA:86,2 +DA:87,6 +DA:89,2 +DA:90,4 +DA:91,2 +LF:31 +LH:29 +end_of_record +SF:lib/utils/extensions/navigation_extension.dart +DA:5,1 +DA:10,2 +DA:11,1 +DA:14,0 +DA:16,2 +DA:20,1 +DA:21,1 +DA:22,1 +DA:23,1 +DA:29,3 +DA:31,2 +LF:11 +LH:10 +end_of_record +SF:lib/main.dart +DA:5,2 +DA:8,2 +DA:11,1 +DA:13,1 +DA:14,1 +DA:17,1 +LF:6 +LH:6 +end_of_record +SF:lib/playground/test_main.dart +DA:7,1 +DA:9,2 +DA:14,1 +DA:16,1 +DA:17,1 +DA:18,1 +DA:19,1 +DA:20,1 +DA:22,1 +DA:23,2 +DA:27,1 +DA:29,1 +DA:30,2 +DA:42,1 +DA:44,1 +DA:45,1 +DA:46,1 +DA:47,1 +DA:48,1 +DA:50,1 +DA:51,2 +DA:57,1 +DA:59,1 +DA:60,2 +LF:24 +LH:24 +end_of_record diff --git a/lib/features/splash/splash_screen.dart b/lib/features/splash/splash_screen.dart index fb17f96..175b8fc 100644 --- a/lib/features/splash/splash_screen.dart +++ b/lib/features/splash/splash_screen.dart @@ -59,21 +59,28 @@ class SplashScreenBody extends StatelessWidget { style: TextStyle(fontWeight: FontWeight.w700, fontSize: 64), ).withBlueGradientFg(), const Spacer(flex: 5), - ScaleOnPressWidget( - key: const Key("login"), - onTap: () { - context.navigateTo(const HomeScreen(), replace: true); - }, - outerPadding: const EdgeInsets.symmetric(horizontal: 48.0), - innerPadding: - const EdgeInsets.only(top: 12, bottom: 8, left: 12, right: 12), - child: const SignInWithGoogleButton()), + GoogleSignInButton(), const Spacer(flex: 2) ], ); } } +class GoogleSignInButton extends StatelessWidget { + @override + Widget build(BuildContext context) { + return ScaleOnPressWidget( + key: const Key("login"), + onTap: () { + context.navigateTo(const HomeScreen(), replace: true); + }, + outerPadding: const EdgeInsets.symmetric(horizontal: 48.0), + innerPadding: + const EdgeInsets.only(top: 12, bottom: 8, left: 12, right: 12), + child: const SignInWithGoogleButton()); + } +} + class SignInWithGoogleButton extends StatelessWidget { const SignInWithGoogleButton({Key key}) : super(key: key); diff --git a/test/features/splash/splash_screen_test.dart b/test/features/splash/splash_screen_test.dart index ef9fa43..63e2646 100644 --- a/test/features/splash/splash_screen_test.dart +++ b/test/features/splash/splash_screen_test.dart @@ -39,14 +39,16 @@ void main() { testWidgets( "There is a Google Sign in Button", (WidgetTester tester) async { - await tester.pumpWidget(const SplashScreen().asScaffold); + // ignore: prefer_const_constructors + await tester.pumpWidget(SplashScreenBody().asScaffold); expect(find.byType(AnimatedScale), findsOneWidget); expect(find.text(R.string.loginWithGoogle), findsOneWidget); }, ); testWidgets("Can navigate to HomeScreen", (WidgetTester tester) async { - await tester.pumpWidget(const SplashScreen().asScaffold); + // ignore: prefer_const_constructors + await tester.pumpWidget( SplashScreenBody().insideMaterialApp); final loginButton = find.byKey(const Key("login")); expect(loginButton, findsOneWidget); await tester.tap(loginButton); From 648184fc96dc68124f3f4fbb358c0d096626367e Mon Sep 17 00:00:00 2001 From: erluxman Date: Thu, 23 Jul 2020 11:35:55 +0545 Subject: [PATCH 2/4] Ok hook or crook --- lib/features/splash/splash_screen.dart | 31 +++++++++----------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/features/splash/splash_screen.dart b/lib/features/splash/splash_screen.dart index 175b8fc..04d51e4 100644 --- a/lib/features/splash/splash_screen.dart +++ b/lib/features/splash/splash_screen.dart @@ -77,25 +77,16 @@ class GoogleSignInButton extends StatelessWidget { outerPadding: const EdgeInsets.symmetric(horizontal: 48.0), innerPadding: const EdgeInsets.only(top: 12, bottom: 8, left: 12, right: 12), - child: const SignInWithGoogleButton()); - } -} - -class SignInWithGoogleButton extends StatelessWidget { - const SignInWithGoogleButton({Key key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset(R.svg.googleIcon), - const SizedBox(width: 16), - Text( - R.string.loginWithGoogle, - style: TextStyle(fontSize: 17, fontWeight: FontWeight.w700), - ), - ], - ); + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset(R.svg.googleIcon), + const SizedBox(width: 16), + Text( + R.string.loginWithGoogle, + style: TextStyle(fontSize: 17, fontWeight: FontWeight.w700), + ), + ], + )); } } From 232cb2227b2ea67536ffe1b27e2f97ac4081f9ed Mon Sep 17 00:00:00 2001 From: erluxman Date: Fri, 24 Jul 2020 09:02:01 +0545 Subject: [PATCH 3/4] Added more tests --- .../home/animated_motivation_meter_test.dart | 4 ---- .../home/home_screen_components_test.dart | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) delete mode 100644 test/features/home/animated_motivation_meter_test.dart create mode 100644 test/features/home/home_screen_components_test.dart diff --git a/test/features/home/animated_motivation_meter_test.dart b/test/features/home/animated_motivation_meter_test.dart deleted file mode 100644 index 6814464..0000000 --- a/test/features/home/animated_motivation_meter_test.dart +++ /dev/null @@ -1,4 +0,0 @@ -void main(){ - - -} \ No newline at end of file diff --git a/test/features/home/home_screen_components_test.dart b/test/features/home/home_screen_components_test.dart new file mode 100644 index 0000000..3a1c8ce --- /dev/null +++ b/test/features/home/home_screen_components_test.dart @@ -0,0 +1,23 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:productive/common/resources/r.dart'; +import 'package:productive/features/home/widgets/animated_circle_progress.dart'; + +void main() { + group("All required widgets are on the Splash screen", () { + setUpAll(() { + R.buildMode.isTesting = true; + }); + + tearDownAll(() { + R.buildMode.isTesting = false; + }); + + testWidgets("test animated progressbar", (WidgetTester tester) async { + await tester.pumpWidget( + // ignore: prefer_const_constructors + AnimatedMotivationMeter(height: 200, width: 200, motivation: 0.5)); + expect(find.byType(CustomPaint), findsNWidgets(1)); + }); + }); +} From 49707e05d2502333c3efee6b56faeedfa65aee66 Mon Sep 17 00:00:00 2001 From: erluxman Date: Fri, 24 Jul 2020 10:30:05 +0545 Subject: [PATCH 4/4] Removed unnnecessary callback --- lib/utils/animation/scale_on_press_widget.dart | 1 - test/features/home/home_screen_components_test.dart | 4 +++- test/utils/animation/scale_on_press_widget_test.dart | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/utils/animation/scale_on_press_widget.dart b/lib/utils/animation/scale_on_press_widget.dart index 9aa29be..c3cf946 100644 --- a/lib/utils/animation/scale_on_press_widget.dart +++ b/lib/utils/animation/scale_on_press_widget.dart @@ -41,7 +41,6 @@ class _ScaleOnPressWidgetState extends State { return GestureDetector( behavior: HitTestBehavior.opaque, onLongPressStart: (_) => _press, - onLongPressEnd: (_) => _unPress, onTapDown: (_) => _press, onTapUp: (_) => _unPress, onLongPress: _press, diff --git a/test/features/home/home_screen_components_test.dart b/test/features/home/home_screen_components_test.dart index 3a1c8ce..0b56f30 100644 --- a/test/features/home/home_screen_components_test.dart +++ b/test/features/home/home_screen_components_test.dart @@ -4,7 +4,7 @@ import 'package:productive/common/resources/r.dart'; import 'package:productive/features/home/widgets/animated_circle_progress.dart'; void main() { - group("All required widgets are on the Splash screen", () { + group("Test Animated Motivation Meter", () { setUpAll(() { R.buildMode.isTesting = true; }); @@ -20,4 +20,6 @@ void main() { expect(find.byType(CustomPaint), findsNWidgets(1)); }); }); + + } diff --git a/test/utils/animation/scale_on_press_widget_test.dart b/test/utils/animation/scale_on_press_widget_test.dart index 7e96bba..e133007 100644 --- a/test/utils/animation/scale_on_press_widget_test.dart +++ b/test/utils/animation/scale_on_press_widget_test.dart @@ -12,7 +12,9 @@ void main() { await tester.pumpWidget(scaledIcon); expect(find.byType(GestureDetector), findsOneWidget); await tester.press(find.byType(GestureDetector)); + await tester.pumpAndSettle(); await tester.longPress(find.byType(GestureDetector)); + await tester.pumpAndSettle(); }); }); }