Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

widget_test.dart 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // This is a basic Flutter widget test.
  2. // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter
  3. // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to
  4. // find child widgets in the widget tree, read text, and verify that the values of widget properties
  5. // are correct.
  6. //import 'package:flutter/material.dart';
  7. import 'package:flutter/material.dart';
  8. import 'package:flutter_test/flutter_test.dart';
  9. //import 'package:touch_demonstrator/main.dart';
  10. import 'package:touch_demonstrator/pages/PageTouchPoints.dart';
  11. //import 'package:touch_demonstrator/ui/home/uiComponents.dart';
  12. import 'package:touch_demonstrator/ui/pageTouchPoints/Logo.dart';
  13. import 'package:touch_demonstrator/ui/pageTouchPoints/ButtonOrAnimation.dart';
  14. import 'package:touch_demonstrator/src/blocs/appBloc.dart';
  15. import 'package:touch_demonstrator/src/blocs/BlocProvider.dart';
  16. import 'package:touch_demonstrator/ui/pageTouchPoints/AppBarPageTouchPoints.dart';
  17. import 'package:touch_demonstrator/src/blocs/bluetoothBloc.dart';
  18. void main() {
  19. testWidgets('debugBloc test', (WidgetTester tester) async {
  20. // Create the Widget and tell the tester to build it
  21. final AppBloc bloc = AppBloc();
  22. var expectBool = true;
  23. bloc.debugBlocGetter.debugEnabledStatus$.listen(expectAsync1((status){
  24. print('status: $status // expectBool= $expectBool');
  25. expectLater(status, emitsInOrder([true, false]));
  26. }));
  27. for (var i = 0; i < 10; i++) {
  28. print('i: $i');
  29. bloc.debugBlocGetter.debugCounterIncrement.add(null);
  30. if((i%3)==0){
  31. // expect(bloc.debugBlocGetter.debugEnabledStatus$, emits(expectBool));
  32. expectBool = !expectBool;
  33. };
  34. }
  35. // expect(bugIconFinder, findsOneWidget);
  36. // var value = await Future.value(LogoState.debugEnableCounter);
  37. // expect(value, 5);
  38. });
  39. testWidgets('Text above logo ', (WidgetTester tester) async {
  40. await tester.pumpWidget(TextAboveLogo());
  41. final textFinder = find.text('Touchpad Demonstrator by');
  42. expect(textFinder, findsOneWidget);
  43. });
  44. testWidgets('Logo', (WidgetTester tester) async {
  45. // Create the Widget and tell the tester to build it
  46. var heightLogo = 200.0;
  47. final AppBloc bloc = AppBloc();
  48. await tester.pumpWidget(BlocProvider(
  49. bloc: bloc,
  50. child: MaterialApp(home: Scaffold(/*appBar: buildAppBarPageTouchPoints(context),*/body: Logo(heightLogo)),)));
  51. // final myAppBar = buildAppBarPageTouchPoints();
  52. final logoFinder = find.byType(Logo);
  53. final bugIconFinder = find.byIcon(Icons.bug_report);
  54. // Create finders to find elements in our widget we are looking for.
  55. expect(logoFinder, findsOneWidget);
  56. expect(bugIconFinder, findsNothing);
  57. // bloc.debugBlocGetter.debugEnabledStatus$.listen(expectAsync1((test)=>print('test')));
  58. await tester.pump();
  59. for (var i = 0; i < 7; i++) {
  60. await tester.tap(find.byType(Container));
  61. await tester.pump();
  62. print('tap');
  63. }
  64. // expect(bugIconFinder, findsOneWidget);
  65. // var value = await Future.value(LogoState.debugEnableCounter);
  66. // expect(value, 5);
  67. });
  68. testWidgets('BluetoothBloc', (WidgetTester tester) async {
  69. // Create the Widget and tell the tester to build it
  70. final AppBloc bloc = AppBloc();
  71. await tester.pumpWidget(BlocProvider(
  72. bloc: bloc,
  73. child: Directionality(
  74. textDirection: TextDirection.ltr, child: ConnectButtonWithAnimations())));
  75. // Create finders to find elements in our widget we are looking for.
  76. final textFinderConnect = find.text('Connect');
  77. expect(textFinderConnect, findsOneWidget);
  78. final textFinderDisconnect = find.text('Disconnect');
  79. expect(textFinderDisconnect, findsNothing);
  80. });
  81. /* testWidgets('Test Text Above', (WidgetTester tester) async {
  82. await tester.pumpWidget(TextAboveLogo());
  83. });*/
  84. // test('page touch points test', () {
  85. //final pageTouchPoints = PageTouchPoints();
  86. // });
  87. }
  88. /*
  89. void main() {
  90. testWidgets('page touch points smoke test', (WidgetTester tester) async {
  91. // Build our app and trigger a frame.
  92. // await tester.pumpWidget(new TouchDemonstrator());
  93. // Verify that our counter starts at 0.
  94. expect(find.text('0'), findsOneWidget);
  95. expect(find.text('1'), findsNothing);
  96. // Tap the '+' icon and trigger a frame.
  97. await tester.tap(find.byIcon(Icons.add));
  98. await tester.pump();
  99. // Verify that our counter has incremented.
  100. expect(find.text('0'), findsNothing);
  101. expect(find.text('1'), findsOneWidget);
  102. });
  103. }*/