document_text_direction_test.dart 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import 'package:appflowy/workspace/application/appearance.dart';
  2. import 'package:appflowy_editor/appflowy_editor.dart';
  3. import 'package:flutter_test/flutter_test.dart';
  4. import 'package:integration_test/integration_test.dart';
  5. import '../util/util.dart';
  6. void main() {
  7. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  8. group('text direction', () {
  9. testWidgets(
  10. '''no text direction items will be displayed in the default/LTR mode,and three text direction items will be displayed in the RTL mode.''',
  11. (tester) async {
  12. // combine the two tests into one to avoid the time-consuming process of initializing the app
  13. await tester.initializeAppFlowy();
  14. await tester.tapGoButton();
  15. final selection = Selection.single(
  16. path: [0],
  17. startOffset: 0,
  18. endOffset: 1,
  19. );
  20. // click the first line of the readme
  21. await tester.editor.tapLineOfEditorAt(0);
  22. await tester.editor.updateSelection(selection);
  23. await tester.pumpAndSettle();
  24. // because this icons are defined in the appflowy_editor package, we can't fetch the icons by SVG data. [textDirectionItems]
  25. final textDirectionIconNames = [
  26. 'toolbar/text_direction_auto',
  27. 'toolbar/text_direction_left',
  28. 'toolbar/text_direction_right',
  29. ];
  30. // no text direction items in default/LTR mode
  31. var button = find.byWidgetPredicate(
  32. (widget) =>
  33. widget is SVGIconItemWidget &&
  34. textDirectionIconNames.contains(widget.iconName),
  35. );
  36. expect(button, findsNothing);
  37. // switch to the RTL mode
  38. await tester.switchLayoutDirectionMode(LayoutDirection.rtlLayout);
  39. await tester.editor.tapLineOfEditorAt(0);
  40. await tester.editor.updateSelection(selection);
  41. await tester.pumpAndSettle();
  42. button = find.byWidgetPredicate(
  43. (widget) =>
  44. widget is SVGIconItemWidget &&
  45. textDirectionIconNames.contains(widget.iconName),
  46. );
  47. expect(button, findsNWidgets(3));
  48. });
  49. });
  50. }