test: improved driver test + shaders

This commit is contained in:
Thibault Deckers 2021-06-07 14:37:11 +09:00
parent d0fe4ee1c3
commit 0982726e4a
8 changed files with 25 additions and 7 deletions

View file

@ -38,8 +38,9 @@ class CollectionGrid extends StatefulWidget {
final String? settingsRouteKey; final String? settingsRouteKey;
const CollectionGrid({ const CollectionGrid({
Key? key,
this.settingsRouteKey, this.settingsRouteKey,
}); }) : super(key: key);
@override @override
_CollectionGridState createState() => _CollectionGridState(); _CollectionGridState createState() => _CollectionGridState();

View file

@ -46,7 +46,9 @@ class _CollectionPageState extends State<CollectionPage> {
bottom: false, bottom: false,
child: ChangeNotifierProvider<CollectionLens>.value( child: ChangeNotifierProvider<CollectionLens>.value(
value: collection, value: collection,
child: CollectionGrid(), child: CollectionGrid(
key: Key('collection-grid'),
),
), ),
), ),
), ),

View file

@ -284,7 +284,6 @@ class GridPainter extends CustomPainter {
], ],
); );
// final topLeft = center.translate(-extent / 2, -extent / 2);
final delta = extent + spacing; final delta = extent + spacing;
for (var i = -2; i <= 2; i++) { for (var i = -2; i <= 2; i++) {
final dx = delta * i; final dx = delta * i;

View file

@ -53,7 +53,7 @@ class FilterNavigationPage<T extends CollectionFilter> extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isMainMode = context.select<ValueNotifier<AppMode>, bool>((vn) => vn.value == AppMode.main); final isMainMode = context.select<ValueNotifier<AppMode>, bool>((vn) => vn.value == AppMode.main);
return FilterGridPage<T>( return FilterGridPage<T>(
key: ValueKey('filter-grid-page'), key: Key('filter-grid-page'),
appBar: SliverAppBar( appBar: SliverAppBar(
title: InteractiveAppBarTitle( title: InteractiveAppBarTitle(
onTap: () => _goToSearch(context), onTap: () => _goToSearch(context),

File diff suppressed because one or more lines are too long

View file

@ -16,7 +16,9 @@ void main() {
// scan files copied from test assets // scan files copied from test assets
// we do it via the app instead of broadcasting via ADB // we do it via the app instead of broadcasting via ADB
// because `MEDIA_SCANNER_SCAN_FILE` intent got deprecated in API 29 // because `MEDIA_SCANNER_SCAN_FILE` intent got deprecated in API 29
PlatformStorageService().scanFile(p.join(targetPicturesDir, 'ipse.jpg'), 'image/jpeg'); final storageService = PlatformStorageService();
storageService.scanFile(p.join(targetPicturesDir, 'aves_logo.svg'), 'image/svg+xml');
storageService.scanFile(p.join(targetPicturesDir, 'ipse.jpg'), 'image/jpeg');
configureAndLaunch(); configureAndLaunch();
} }

View file

@ -37,6 +37,7 @@ void main() {
selectFirstAlbum(); selectFirstAlbum();
searchAlbum(); searchAlbum();
showViewer(); showViewer();
goToNextImage();
toggleOverlay(); toggleOverlay();
zoom(); zoom();
showInfoMetadata(); showInfoMetadata();
@ -154,12 +155,24 @@ void searchAlbum() {
void showViewer() { void showViewer() {
test('[collection] show viewer', () async { test('[collection] show viewer', () async {
await driver.tap(find.byType('DecoratedThumbnail')); await driver.tap(find.descendant(
of: find.byValueKey('collection-grid'),
matching: find.byType('DecoratedThumbnail'),
firstMatchOnly: true,
));
await driver.waitUntilNoTransientCallbacks(); await driver.waitUntilNoTransientCallbacks();
await Future.delayed(Duration(seconds: 2)); await Future.delayed(Duration(seconds: 2));
}); });
} }
void goToNextImage() {
test('[viewer] show next image', () async {
final horizontalPageView = find.byValueKey('horizontal-pageview');
await driver.scroll(horizontalPageView, -600, 0, Duration(milliseconds: 400));
await Future.delayed(Duration(seconds: 2));
});
}
void toggleOverlay() { void toggleOverlay() {
test('[viewer] toggle overlay', () async { test('[viewer] toggle overlay', () async {
final imageView = find.byValueKey('imageview'); final imageView = find.byValueKey('imageview');

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="265.554" height="244.35"><path d="M0 10.84L166.56 177.4l43.778-43.775L87.553 10.84z" fill="#3f51b5"/><path d="M99.61 132.726V244.35l55.812-55.812z" fill="#4caf50"/><path d="M210.337 111.624V0l-55.812 55.812z" fill="#ffc107"/><path d="M265.554 39.465L226.089 0v39.465z" fill="#ff5722"/></svg>

After

Width:  |  Height:  |  Size: 338 B