@@ -13,6 +13,9 @@ import 'package:flutter_test/flutter_test.dart';
1313import 'package:mocktail/mocktail.dart' ;
1414import 'package:oidc4vc/oidc4vc.dart' ;
1515
16+ import '../../../../../../../../golden_test_config.dart' ;
17+ import '../../../../../../../../test_objects.dart' ;
18+
1619class MockProfileCubit extends MockCubit <ProfileState >
1720 implements ProfileCubit {}
1821
@@ -83,7 +86,7 @@ class MockProfileState extends Fake implements ProfileState {
8386
8487void main () {
8588 // Enable mocking of named constructors
86- setUpAll (() {
89+ setUpAll (() async {
8790 registerFallbackValue (
8891 const CredentialManifestPickState (filteredCredentialList: []),
8992 );
@@ -105,10 +108,11 @@ void main() {
105108 PresentationDefinition (id: 'test' , inputDescriptors: []),
106109 );
107110 registerFallbackValue (MockQRCodeScanCubit ());
111+ await loadAppFonts ();
108112 });
109113
110114 group ('CredentialManifestOfferPickPage' , () {
111- late MockCredentialManifestPickCubit credentialManifestPickCubit;
115+ late CredentialManifestPickCubit credentialManifestPickCubit;
112116 late MockCredentialsCubit credentialsCubit;
113117 late MockProfileCubit profileCubit;
114118 late MockScanCubit scanCubit;
@@ -233,15 +237,18 @@ void main() {
233237 // Set up credential manifest pick cubit state
234238 when (() => credentialManifestPickCubit.state).thenReturn (
235239 CredentialManifestPickState (
236- filteredCredentialList: [testCredential ],
240+ filteredCredentialList: [TEST_CREDENTIAL ],
237241 selected: const [],
238242 presentationDefinition: presentationDefinition,
239- isButtonEnabled: false ,
243+ isButtonEnabled: true ,
240244 ),
241245 );
242246
243247 when (() => credentialsCubit.state).thenReturn (
244- const CredentialsState (status: CredentialsStatus .idle, credentials: []),
248+ CredentialsState (
249+ status: CredentialsStatus .idle,
250+ credentials: [TEST_CREDENTIAL ],
251+ ),
245252 );
246253
247254 when (
@@ -279,7 +286,7 @@ void main() {
279286 ),
280287 ],
281288 child: Material (
282- child: CredentialManifestOfferPickPage (
289+ child: CredentialManifestOfferPickView (
283290 uri: uri,
284291 credential: credential,
285292 issuer: issuer,
@@ -301,19 +308,64 @@ void main() {
301308 await tester.pump (const Duration (seconds: 1 ));
302309 });
303310
304- testWidgets ('displays purpose text from input descriptor' , (
305- WidgetTester tester,
306- ) async {
307- await tester.pumpWidget (buildSubject ());
308- await tester.pumpAndSettle ();
311+ for (final device in phoneScreenSizes) {
312+ testWidgets (
313+ 'Displays purpose text from input descriptor on ${device .name }' ,
314+ (WidgetTester tester) async {
315+ // Set the surface size for the test
316+ await tester.binding.setSurfaceSize (device.size);
317+ tester.view.devicePixelRatio = device.devicePixelRatio;
318+ addTearDown (() {
319+ tester.view.resetPhysicalSize ();
320+ tester.view.resetDevicePixelRatio ();
321+ });
322+ whenListen (
323+ credentialManifestPickCubit,
324+ Stream .fromIterable ([
325+ CredentialManifestPickState (
326+ filteredCredentialList: [TEST_CREDENTIAL ],
327+ selected: const [],
328+ presentationDefinition: presentationDefinition,
329+ isButtonEnabled: false ,
330+ ),
331+ CredentialManifestPickState (
332+ filteredCredentialList: [TEST_CREDENTIAL ],
333+ selected: const [],
334+ presentationDefinition: presentationDefinition,
335+ isButtonEnabled: true ,
336+ ),
337+ ]),
338+ );
339+ await tester.pumpWidget (
340+ MediaQuery (
341+ data: MediaQueryData (
342+ size: device.size,
343+ devicePixelRatio: device.devicePixelRatio,
344+ ),
345+ child: buildSubject (),
346+ ),
347+ );
348+ await tester.pumpAndSettle ();
309349
310- // Verify that the purpose text is shown somewhere in the widget tree
311- expect (
312- find.text (inputDescriptor.purpose ?? '' ),
313- findsOneWidget,
314- reason: 'Purpose text from input descriptor should be displayed' ,
350+ await expectLater (
351+ find.byType (CredentialManifestOfferPickView ),
352+ matchesGoldenFile (
353+ 'goldens/credential_manifest_offer_pick_page_${device .name }.png' ,
354+ ),
355+ );
356+
357+ // Verify that the purpose text is shown somewhere in the widget tree
358+ expect (
359+ find.text (inputDescriptor.purpose ?? '' ),
360+ findsOneWidget,
361+ reason: 'Purpose text from input descriptor should be displayed' ,
362+ );
363+
364+ // Reset the surface size
365+ await tester.binding.setSurfaceSize (null );
366+ },
315367 );
316- });
368+ }
317369
318370 testWidgets ('displays credential list item' , (WidgetTester tester) async {
319371 await tester.pumpWidget (buildSubject ());
0 commit comments