tane/apps/app_seeds/test/ui/photo_crop_test.dart
vjrj f6967e8cbb feat(profile): Material default avatar + square photo crop
Drop the DiceBear generated avatar (and dicebear_core/dicebear_styles/
flutter_svg): the default is again a Material coloured-initial disc from
the pubkey. Picking a photo now goes through a square crop step
(crop_your_image — pure Flutter, all platforms incl. desktop, Apache-2.0,
only pulls the image package we already had) before the 24 KB thumbnail.
2026-07-12 23:39:56 +02:00

48 lines
1.4 KiB
Dart

import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:image/image.dart' as img;
import 'package:tane/ui/photo_crop.dart';
void main() {
// A small but real PNG the cropper can decode.
final bytes = Uint8List.fromList(
img.encodePng(img.Image(width: 32, height: 32)),
);
testWidgets('cropToSquare shows a cancel/confirm UI and cancel returns null', (
tester,
) async {
Uint8List? result;
var returned = false;
await tester.pumpWidget(MaterialApp(
home: Builder(
builder: (context) => Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () async {
result = await cropToSquare(context, bytes);
returned = true;
},
child: const Text('open'),
),
),
),
),
));
await tester.tap(find.text('open'));
await tester.pump(); // push the crop route
await tester.pump(const Duration(milliseconds: 100));
expect(find.byKey(const Key('crop.confirm')), findsOneWidget);
expect(find.byKey(const Key('crop.cancel')), findsOneWidget);
await tester.tap(find.byKey(const Key('crop.cancel')));
await tester.pump(); // pop the crop route
expect(returned, isTrue);
expect(result, isNull); // cancelling yields no image
});
}