From 6188a4c545e6e6794eba943431ec20108553b98f Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Wed, 31 Jul 2024 11:30:22 -0400 Subject: Add support for CI screenshot testing Rework the high-level App & AppView widgets a bit to allow conditionally displaying a simple fixed pattern if the HOMESCREEN_DEMO_CI environment variable is set to anything other than "0". The pattern displayed matches what the Qt homescreen shows for this to allow the CI test to be common. Bug-AGL: SPEC-5203 Change-Id: I36ed77c91304e3b6cdbce6a7350831d52d20d378 Signed-off-by: Scott Murray (cherry picked from commit 25b6a079d5fe9c1365d776298ae5230a4de1ba16) --- lib/data/data_providers/app.dart | 27 +++++++++++++++++---------- lib/export.dart | 1 + lib/presentation/screens/home/home_ci.dart | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 lib/presentation/screens/home/home_ci.dart (limited to 'lib') diff --git a/lib/data/data_providers/app.dart b/lib/data/data_providers/app.dart index acfaa01..3368a83 100644 --- a/lib/data/data_providers/app.dart +++ b/lib/data/data_providers/app.dart @@ -1,25 +1,32 @@ import '../../export.dart'; +final homeScreenProvider = Provider((ref) { + final Map envVars = Platform.environment; + final ciFlagStr = envVars['HOMESCREEN_DEMO_CI']; + final bool ciFlag = ciFlagStr != null && ciFlagStr != "0"; + return ciFlag ? const HomeScreenCI() : const HomeScreen(); +}); + class App extends StatelessWidget { const App({super.key}); - @override - Widget build(BuildContext context) { - return const AppView(); - } -} - -class AppView extends StatelessWidget { - const AppView({super.key}); - @override Widget build(BuildContext context) { return ProviderScope( child: MaterialApp( debugShowCheckedModeBanner: false, theme: theme, - home: const HomeScreen(), + home: const AppView(), ), ); } } + +class AppView extends ConsumerWidget { + const AppView({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return ref.watch(homeScreenProvider); + } +} diff --git a/lib/export.dart b/lib/export.dart index ef029c7..90ed196 100644 --- a/lib/export.dart +++ b/lib/export.dart @@ -16,6 +16,7 @@ export 'data/models/hybrid.dart'; //Screens export 'presentation/screens/home/home.dart'; +export 'presentation/screens/home/home_ci.dart'; export 'presentation/screens/home/widgets/custom_tile.dart'; export 'presentation/screens/dashboard/dashboard.dart'; export 'presentation/screens/dashboard/widgets/hybrid/hybrid.dart'; diff --git a/lib/presentation/screens/home/home_ci.dart b/lib/presentation/screens/home/home_ci.dart new file mode 100644 index 0000000..8584420 --- /dev/null +++ b/lib/presentation/screens/home/home_ci.dart @@ -0,0 +1,20 @@ +import 'package:flutter_ics_homescreen/export.dart'; + +// Simple fixed pattern homescreen for AGL CI screenshot testing + +class HomeScreenCI extends StatelessWidget { + const HomeScreenCI({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + // Note that the colors are specified with hex in order to match + // Qt's red/blue/green constants, which are different than Flutter's. + Container(width: 1080, height: 216, color: Color(0xFF0000FF)), + Container(width: 1080, height: 1488, color: Color(0xFFFF0000)), + Container(width: 1080, height: 216, color: Color(0xFF008000)) + ], + ); + } +} -- cgit 1.2.3-korg