From 687837c4633ff5567618a9042a06ccc77d5e178f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 18 May 2026 23:02:38 +0300 Subject: Add named routes and widget smoke tests to player-android Adds HomeScreen ('/') and NowPlayingScreen ('/now-playing') as the first two named routes in PlayerAndroidApp, replacing the anonymous home widget. Widget smoke tests verify that the app starts on the library screen, navigates to the now-playing screen on button tap, and back-navigates correctly. Co-Authored-By: Claude Sonnet 4.6 --- player-android/test/widget_smoke_test.dart | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 player-android/test/widget_smoke_test.dart (limited to 'player-android/test/widget_smoke_test.dart') diff --git a/player-android/test/widget_smoke_test.dart b/player-android/test/widget_smoke_test.dart new file mode 100644 index 0000000..fba21d4 --- /dev/null +++ b/player-android/test/widget_smoke_test.dart @@ -0,0 +1,48 @@ +// Widget smoke tests for PlayerAndroidApp. +// +// These tests verify that the two named routes defined in main.dart render +// without errors and contain the expected key widgets. Navigation between +// HomeScreen and NowPlayingScreen is exercised end-to-end. +// +// Run with: flutter test test/widget_smoke_test.dart + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:player_android/main.dart'; + +void main() { + group('PlayerAndroidApp', () { + testWidgets('starts on HomeScreen showing Library title', (tester) async { + await tester.pumpWidget(const PlayerAndroidApp()); + + expect(find.text('Library'), findsOneWidget); + expect(find.text('Now Playing'), findsOneWidget); + }); + + testWidgets('navigates to NowPlayingScreen on button tap', (tester) async { + await tester.pumpWidget(const PlayerAndroidApp()); + + await tester.tap(find.widgetWithText(ElevatedButton, 'Now Playing')); + await tester.pumpAndSettle(); + + expect(find.text('Now Playing'), findsWidgets); + expect(find.text('No media selected'), findsOneWidget); + }); + + testWidgets('NowPlayingScreen back-navigates to HomeScreen', (tester) async { + await tester.pumpWidget(const PlayerAndroidApp()); + + // Navigate to NowPlayingScreen. + await tester.tap(find.widgetWithText(ElevatedButton, 'Now Playing')); + await tester.pumpAndSettle(); + expect(find.text('No media selected'), findsOneWidget); + + // Press the back button provided by Scaffold/AppBar. + final NavigatorState nav = tester.state(find.byType(Navigator)); + nav.pop(); + await tester.pumpAndSettle(); + + expect(find.text('Library'), findsOneWidget); + }); + }); +} -- cgit v1.2.3