diff --git a/analysis_options.yaml b/analysis_options.yaml index ef627c7f8..8bb726c09 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -22,4 +22,5 @@ analyzer: dart_code_linter: rules: - - avoid-dynamic \ No newline at end of file + - avoid-dynamic + - avoid-redundant-async \ No newline at end of file diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 3a0139365..cb5db3cc3 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -17,171 +17,157 @@ import 'users.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group( - 'Integration Test', - () { - setUpAll( - () async { - // this random dialog popping up is super hard to cover in tests - SharedPreferences.setMockInitialValues({ - 'chat.fluffy.show_no_google': false, - }); - }, - ); - - testWidgets( - 'Start app, login and logout', - (WidgetTester tester) async { - app.main(); - await tester.ensureAppStartedHomescreen(); - await tester.ensureLoggedOut(); - }, - ); - - testWidgets( - 'Login again', - (WidgetTester tester) async { - app.main(); - await tester.ensureAppStartedHomescreen(); - }, - ); - - testWidgets( - 'Start chat and send message', - (WidgetTester tester) async { - app.main(); - await tester.ensureAppStartedHomescreen(); - await tester.waitFor(find.byType(TextField)); - await tester.enterText(find.byType(TextField), Users.user2.name); - await tester.pumpAndSettle(); - - await tester.scrollUntilVisible( - find.text('Chats').first, - 500, - scrollable: find - .descendant( - of: find.byType(ChatListViewBody), - matching: find.byType(Scrollable), - ) - .first, - ); - await tester.pumpAndSettle(); - await tester.tap(find.text('Chats')); - await tester.pumpAndSettle(); - await tester.waitFor(find.byType(SearchTitle)); - await tester.pumpAndSettle(); - - await tester.scrollUntilVisible( - find.text(Users.user2.name).first, - 500, - scrollable: find - .descendant( - of: find.byType(ChatListViewBody), - matching: find.byType(Scrollable), - ) - .first, - ); - await tester.pumpAndSettle(); - await tester.tap(find.text(Users.user2.name).first); - - try { - await tester.waitFor( - find.byType(ChatView), - timeout: const Duration(seconds: 5), - ); - } catch (_) { - // in case the homeserver sends the username as search result - if (find.byIcon(Icons.send_outlined).evaluate().isNotEmpty) { - await tester.tap(find.byIcon(Icons.send_outlined)); - await tester.pumpAndSettle(); - } - } - - await tester.waitFor(find.byType(ChatView)); - await tester.enterText(find.byType(TextField).last, 'Test'); - await tester.pumpAndSettle(); - try { - await tester.waitFor(find.byIcon(Icons.send_outlined)); - await tester.tap(find.byIcon(Icons.send_outlined)); - } catch (_) { - await tester.testTextInput.receiveAction(TextInputAction.done); - } - await tester.pumpAndSettle(); - await tester.waitFor(find.text('Test')); - await tester.pumpAndSettle(); - }, - ); - - testWidgets('Spaces', (tester) async { - app.main(); - await tester.ensureAppStartedHomescreen(); - - await tester.waitFor(find.byTooltip('Show menu')); - await tester.tap(find.byTooltip('Show menu')); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byIcon(Icons.workspaces_outlined)); - await tester.tap(find.byIcon(Icons.workspaces_outlined)); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byType(TextField)); - await tester.enterText(find.byType(TextField).last, 'Test Space'); - await tester.pumpAndSettle(); - - await tester.testTextInput.receiveAction(TextInputAction.done); - await tester.pumpAndSettle(); - - await tester.waitFor(find.text('Invite contact')); - - await tester.tap(find.text('Invite contact')); - await tester.pumpAndSettle(); - - await tester.waitFor( - find.descendant( - of: find.byType(InvitationSelectionView), - matching: find.byType(TextField), - ), - ); - await tester.enterText( - find.descendant( - of: find.byType(InvitationSelectionView), - matching: find.byType(TextField), - ), - Users.user2.name, - ); - - await Future.delayed(const Duration(milliseconds: 250)); - await tester.testTextInput.receiveAction(TextInputAction.done); - - await Future.delayed(const Duration(milliseconds: 1000)); - await tester.pumpAndSettle(); - - await tester.tap( - find - .descendant( - of: find.descendant( - of: find.byType(InvitationSelectionView), - matching: find.byType(ListTile), - ), - matching: find.text(Users.user2.name), - ) - .last, - ); - await tester.pumpAndSettle(); - - await tester.waitFor(find.maybeUppercaseText('Yes')); - await tester.tap(find.maybeUppercaseText('Yes')); - await tester.pumpAndSettle(); - - await tester.tap(find.byTooltip('Back')); - await tester.pumpAndSettle(); - - await tester.waitFor(find.text('Load 2 more participants')); - await tester.tap(find.text('Load 2 more participants')); - await tester.pumpAndSettle(); - - expect(find.text(Users.user2.name), findsOneWidget); + group('Integration Test', () { + setUpAll(() { + // this random dialog popping up is super hard to cover in tests + SharedPreferences.setMockInitialValues({ + 'chat.fluffy.show_no_google': false, }); - }, - ); + }); + + testWidgets('Start app, login and logout', (WidgetTester tester) async { + app.main(); + await tester.ensureAppStartedHomescreen(); + await tester.ensureLoggedOut(); + }); + + testWidgets('Login again', (WidgetTester tester) async { + app.main(); + await tester.ensureAppStartedHomescreen(); + }); + + testWidgets('Start chat and send message', (WidgetTester tester) async { + app.main(); + await tester.ensureAppStartedHomescreen(); + await tester.waitFor(find.byType(TextField)); + await tester.enterText(find.byType(TextField), Users.user2.name); + await tester.pumpAndSettle(); + + await tester.scrollUntilVisible( + find.text('Chats').first, + 500, + scrollable: find + .descendant( + of: find.byType(ChatListViewBody), + matching: find.byType(Scrollable), + ) + .first, + ); + await tester.pumpAndSettle(); + await tester.tap(find.text('Chats')); + await tester.pumpAndSettle(); + await tester.waitFor(find.byType(SearchTitle)); + await tester.pumpAndSettle(); + + await tester.scrollUntilVisible( + find.text(Users.user2.name).first, + 500, + scrollable: find + .descendant( + of: find.byType(ChatListViewBody), + matching: find.byType(Scrollable), + ) + .first, + ); + await tester.pumpAndSettle(); + await tester.tap(find.text(Users.user2.name).first); + + try { + await tester.waitFor( + find.byType(ChatView), + timeout: const Duration(seconds: 5), + ); + } catch (_) { + // in case the homeserver sends the username as search result + if (find.byIcon(Icons.send_outlined).evaluate().isNotEmpty) { + await tester.tap(find.byIcon(Icons.send_outlined)); + await tester.pumpAndSettle(); + } + } + + await tester.waitFor(find.byType(ChatView)); + await tester.enterText(find.byType(TextField).last, 'Test'); + await tester.pumpAndSettle(); + try { + await tester.waitFor(find.byIcon(Icons.send_outlined)); + await tester.tap(find.byIcon(Icons.send_outlined)); + } catch (_) { + await tester.testTextInput.receiveAction(TextInputAction.done); + } + await tester.pumpAndSettle(); + await tester.waitFor(find.text('Test')); + await tester.pumpAndSettle(); + }); + + testWidgets('Spaces', (tester) async { + app.main(); + await tester.ensureAppStartedHomescreen(); + + await tester.waitFor(find.byTooltip('Show menu')); + await tester.tap(find.byTooltip('Show menu')); + await tester.pumpAndSettle(); + + await tester.waitFor(find.byIcon(Icons.workspaces_outlined)); + await tester.tap(find.byIcon(Icons.workspaces_outlined)); + await tester.pumpAndSettle(); + + await tester.waitFor(find.byType(TextField)); + await tester.enterText(find.byType(TextField).last, 'Test Space'); + await tester.pumpAndSettle(); + + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pumpAndSettle(); + + await tester.waitFor(find.text('Invite contact')); + + await tester.tap(find.text('Invite contact')); + await tester.pumpAndSettle(); + + await tester.waitFor( + find.descendant( + of: find.byType(InvitationSelectionView), + matching: find.byType(TextField), + ), + ); + await tester.enterText( + find.descendant( + of: find.byType(InvitationSelectionView), + matching: find.byType(TextField), + ), + Users.user2.name, + ); + + await Future.delayed(const Duration(milliseconds: 250)); + await tester.testTextInput.receiveAction(TextInputAction.done); + + await Future.delayed(const Duration(milliseconds: 1000)); + await tester.pumpAndSettle(); + + await tester.tap( + find + .descendant( + of: find.descendant( + of: find.byType(InvitationSelectionView), + matching: find.byType(ListTile), + ), + matching: find.text(Users.user2.name), + ) + .last, + ); + await tester.pumpAndSettle(); + + await tester.waitFor(find.maybeUppercaseText('Yes')); + await tester.tap(find.maybeUppercaseText('Yes')); + await tester.pumpAndSettle(); + + await tester.tap(find.byTooltip('Back')); + await tester.pumpAndSettle(); + + await tester.waitFor(find.text('Load 2 more participants')); + await tester.tap(find.text('Load 2 more participants')); + await tester.pumpAndSettle(); + + expect(find.text(Users.user2.name), findsOneWidget); + }); + }); } diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index 9d2b5fabf..592bb3e85 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -90,7 +90,7 @@ class BootstrapDialogState extends State { context.canPop() ? context.pop(success) : context.go('/rooms'); } - void _decryptLastEvents() async { + void _decryptLastEvents() { for (final room in client.rooms) { final event = room.lastEvent; if (event != null && diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index f4c2a34d1..15b36b982 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -257,7 +257,7 @@ class ChatController extends State } } - void _loadDraft() async { + void _loadDraft() { final prefs = Matrix.of(context).store; final draft = prefs.getString('draft_$roomId'); if (draft != null && draft.isNotEmpty) { diff --git a/lib/pages/chat/events/poll.dart b/lib/pages/chat/events/poll.dart index e6baeb7ce..7cc57dc78 100644 --- a/lib/pages/chat/events/poll.dart +++ b/lib/pages/chat/events/poll.dart @@ -27,11 +27,7 @@ class PollWidget extends StatelessWidget { void _endPoll(BuildContext context) => showFutureLoadingDialog(context: context, future: () => event.endPoll()); - void _toggleVote( - BuildContext context, - String answerId, - int maxSelection, - ) async { + void _toggleVote(BuildContext context, String answerId, int maxSelection) { final userId = event.room.client.userID!; final answerIds = event.getPollResponses(timeline)[userId] ?? {}; if (!answerIds.remove(answerId)) { diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 45e638518..aae3a10cc 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -372,7 +372,7 @@ class ChatListController extends State scrollController.addListener(_onScroll); _waitForFirstSync(); _hackyWebRTCFixForWeb(); - WidgetsBinding.instance.addPostFrameCallback((_) async { + WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { searchServer = Matrix.of( context, diff --git a/lib/pages/dialer/dialer.dart b/lib/pages/dialer/dialer.dart index d3cca97c1..85c10f7d9 100644 --- a/lib/pages/dialer/dialer.dart +++ b/lib/pages/dialer/dialer.dart @@ -189,7 +189,7 @@ class MyCallingPage extends State { _playCallSound(); } - void initialize() async { + void initialize() { final call = this.call; call.onCallStateChanged.stream.listen(_handleCallState); call.onCallEventChanged.stream.listen((event) { @@ -282,7 +282,7 @@ class MyCallingPage extends State { }); } - void _screenSharing() async { + void _screenSharing() { if (PlatformInfos.isAndroid) { if (!call.screensharingEnabled) { FlutterForegroundTask.init( diff --git a/lib/pages/invitation_selection/invitation_selection.dart b/lib/pages/invitation_selection/invitation_selection.dart index 1701a1a0f..50fcd2667 100644 --- a/lib/pages/invitation_selection/invitation_selection.dart +++ b/lib/pages/invitation_selection/invitation_selection.dart @@ -66,7 +66,7 @@ class InvitationSelectionController extends State { } } - void searchUserWithCoolDown(String text) async { + void searchUserWithCoolDown(String text) { coolDown?.cancel(); coolDown = Timer( const Duration(milliseconds: 500), diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index c1620f913..cb2a45d6d 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -94,7 +94,7 @@ class LoginController extends State { Timer? _coolDown; - void checkWellKnownWithCoolDown(String userId) async { + void checkWellKnownWithCoolDown(String userId) { _coolDown?.cancel(); _coolDown = Timer( const Duration(seconds: 1), diff --git a/lib/pages/settings_style/settings_style.dart b/lib/pages/settings_style/settings_style.dart index b22e98fbb..c30492cfe 100644 --- a/lib/pages/settings_style/settings_style.dart +++ b/lib/pages/settings_style/settings_style.dart @@ -19,7 +19,7 @@ class SettingsStyle extends StatefulWidget { } class SettingsStyleController extends State { - void setChatColor(Color? color) async { + void setChatColor(Color? color) { AppSettings.colorSchemeSeedInt.setItem( color?.toARGB32() ?? AppSettings.colorSchemeSeedInt.defaultValue, ); diff --git a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/sqlcipher_stub.dart b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/sqlcipher_stub.dart index b0f8b43dc..c5ec4feba 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/sqlcipher_stub.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/sqlcipher_stub.dart @@ -1 +1,2 @@ -Future applyWorkaroundToOpenSqlCipherOnOldAndroidVersions() async {} +Future applyWorkaroundToOpenSqlCipherOnOldAndroidVersions() => + Future.value(); diff --git a/lib/widgets/qr_code_viewer.dart b/lib/widgets/qr_code_viewer.dart index f8653a68c..32024f11a 100644 --- a/lib/widgets/qr_code_viewer.dart +++ b/lib/widgets/qr_code_viewer.dart @@ -27,7 +27,7 @@ class QrCodeViewer extends StatelessWidget { void _save(BuildContext context) async { final imageResult = await showFutureLoadingDialog( context: context, - future: () async { + future: () { final inviteLink = 'https://matrix.to/#/$content'; final image = QRImage(inviteLink, size: 256, radius: 1).generate(); return compute(encodePng, image); diff --git a/test/archive_test.dart b/test/archive_test.dart index 25bb090e7..33ff38ab1 100644 --- a/test/archive_test.dart +++ b/test/archive_test.dart @@ -6,5 +6,6 @@ void main() { testWidget: Archive(), testClient: await testClient(loggedIn: true), ));*/ + return; }); } diff --git a/test/homeserver_picker_test.dart b/test/homeserver_picker_test.dart index 054f49cab..3200fdd2f 100644 --- a/test/homeserver_picker_test.dart +++ b/test/homeserver_picker_test.dart @@ -13,5 +13,6 @@ void main() { testWidget: HomeserverPicker(), ), );*/ + return; }); } diff --git a/test/widget_test.dart b/test/widget_test.dart index 7d1d98eb6..beb6cd2a1 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -16,5 +16,6 @@ void main() { /* await tester.pumpWidget(FluffyChatApp( client: await prepareTestClient(), ));*/ + return; }); }