auth_operation.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import 'package:appflowy/user/presentation/sign_in_screen.dart';
  2. import 'package:appflowy/workspace/presentation/settings/widgets/sync_setting_view.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_test/flutter_test.dart';
  5. import 'base.dart';
  6. extension AppFlowyAuthTest on WidgetTester {
  7. Future<void> tapGoogleLoginInButton() async {
  8. await tapButton(find.byType(GoogleSignUpButton));
  9. }
  10. Future<void> tapSignInAsGuest() async {
  11. await tapButton(find.byType(SignInAsGuestButton));
  12. }
  13. void expectToSeeGoogleLoginButton() {
  14. expect(find.byType(GoogleSignUpButton), findsOneWidget);
  15. }
  16. void assertSwitchValue(Finder finder, bool value) {
  17. final Switch switchWidget = widget(finder);
  18. final isSwitched = switchWidget.value;
  19. assert(isSwitched == value);
  20. }
  21. void assertEnableEncryptSwitchValue(bool value) {
  22. assertSwitchValue(
  23. find.descendant(
  24. of: find.byType(EnableEncrypt),
  25. matching: find.byWidgetPredicate((widget) => widget is Switch),
  26. ),
  27. value,
  28. );
  29. }
  30. void assertEnableSyncSwitchValue(bool value) {
  31. assertSwitchValue(
  32. find.descendant(
  33. of: find.byType(EnableSync),
  34. matching: find.byWidgetPredicate((widget) => widget is Switch),
  35. ),
  36. value,
  37. );
  38. }
  39. Future<void> toggleEnableEncrypt() async {
  40. final finder = find.descendant(
  41. of: find.byType(EnableEncrypt),
  42. matching: find.byWidgetPredicate((widget) => widget is Switch),
  43. );
  44. await tapButton(finder);
  45. }
  46. Future<void> toggleEnableSync() async {
  47. final finder = find.descendant(
  48. of: find.byType(EnableSync),
  49. matching: find.byWidgetPredicate((widget) => widget is Switch),
  50. );
  51. await tapButton(finder);
  52. }
  53. }