Skip to content

Commit

Permalink
Merge pull request #1501 from spydon/fix-3.16.0-tests
Browse files Browse the repository at this point in the history
deps: Update to Flutter 3.16.0 and fix tests
  • Loading branch information
spydon authored Nov 23, 2023
2 parents 80a5ea5 + 8053345 commit 70a788c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
flutter 3.13.9-stable
flutter 3.16.0-stable
Binary file not shown.
28 changes: 22 additions & 6 deletions packages/app_center/test/snap_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,15 @@ void main() {
await tester.tap(find.byIcon(Icons.thumb_down_outlined));
verify(ratingsModel.castVote(VoteStatus.down)).called(1);

await tester.tap(find.byIcon(YaruIcons.view_more_horizontal));
final viewMoreButton = find.byIcon(YaruIcons.view_more_horizontal);
expect(viewMoreButton, findsOneWidget);
await tester.tap(viewMoreButton);
await tester.pump();

await tester.tap(find.text(tester.l10n.snapActionRemoveLabel));
final removeButton = find.text(tester.l10n.snapActionRemoveLabel);
expect(removeButton, findsOneWidget);
await tester.tap(removeButton);
await tester.pump();
verify(snapModel.remove()).called(1);

expect(find.text(tester.l10n.snapActionUpdateLabel), findsNothing);
Expand Down Expand Up @@ -181,13 +186,18 @@ void main() {
await tester.tap(find.byIcon(Icons.thumb_down_outlined));
verify(ratingsModel.castVote(VoteStatus.down)).called(1);

await tester.tap(find.byIcon(YaruIcons.view_more_horizontal));
final viewMoreButton = find.byIcon(YaruIcons.view_more_horizontal);
expect(viewMoreButton, findsOneWidget);
await tester.tap(viewMoreButton);
await tester.pump();

final updateButton = find.text(tester.l10n.snapActionUpdateLabel);
expect(updateButton, findsOneWidget);

await tester.tap(find.text(tester.l10n.snapActionRemoveLabel));
await tester.pump();
verify(snapModel.remove()).called(1);

expect(find.text(tester.l10n.snapActionUpdateLabel), findsOneWidget);
final l10n = tester.l10n;
expect(find.text(tester.l10n.snapRatingsVotes(snapRating.totalVotes)),
findsOneWidget);
Expand Down Expand Up @@ -258,11 +268,17 @@ void main() {

await tester.tap(find.text(tester.l10n.snapActionOpenLabel));
verify(snapLauncher.open()).called(1);
await tester.pump();

await tester.tap(find.byIcon(YaruIcons.view_more_horizontal));
final findMoreButton = find.byIcon(YaruIcons.view_more_horizontal);
expect(findMoreButton, findsOneWidget);
await tester.tap(findMoreButton);
await tester.pump();

await tester.tap(find.text(tester.l10n.snapActionRemoveLabel));
final removeButton = find.text(tester.l10n.snapActionRemoveLabel);
expect(removeButton, findsOneWidget);
await tester.tap(removeButton);
await tester.pump();
verify(snapModel.remove()).called(1);

expect(find.text(tester.l10n.snapActionUpdateLabel), findsNothing);
Expand Down
24 changes: 19 additions & 5 deletions packages/app_center/test/test_utils.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';

import 'package:app_center/appstream.dart';
import 'package:app_center/l10n.dart';
Expand All @@ -11,6 +12,7 @@ import 'package:app_center_ratings_client/ratings_client.dart';
import 'package:appstream/appstream.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gtk/gtk.dart';
Expand All @@ -24,11 +26,23 @@ import 'test_utils.mocks.dart';
extension WidgetTesterX on WidgetTester {
BuildContext get context => element(find.byType(Scaffold).first);
AppLocalizations get l10n => AppLocalizations.of(context);
Future<void> pumpApp(WidgetBuilder builder) {
return pumpWidget(MaterialApp(
localizationsDelegates: localizationsDelegates,
home: Scaffold(body: Builder(builder: builder)),
));
Future<void> pumpApp(WidgetBuilder builder) async {
// The intended minimum size of the window.
view.physicalSize =
(Size(800, 600) + Offset(54, 54)) * view.devicePixelRatio;
final ubuntuRegular = File('test/fonts/Ubuntu-Regular.ttf');
final content = ByteData.view(
Uint8List.fromList(ubuntuRegular.readAsBytesSync()).buffer);
final fontLoader = FontLoader('UbuntuRegular')
..addFont(Future.value(content));
await fontLoader.load();
return pumpWidget(
MaterialApp(
theme: ThemeData(fontFamily: 'UbuntuRegular'),
localizationsDelegates: localizationsDelegates,
home: Scaffold(body: Builder(builder: builder)),
),
);
}
}

Expand Down

0 comments on commit 70a788c

Please sign in to comment.