// This is a basic Flutter widget test. // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to // find child widgets in the widget tree, read text, and verify that the values of widget properties // are correct. //import 'package:flutter/material.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; //import 'package:touch_demonstrator/main.dart'; import 'package:touch_demonstrator/pages/PageTouchPoints.dart'; //import 'package:touch_demonstrator/ui/home/uiComponents.dart'; import 'package:touch_demonstrator/ui/pageTouchPoints/Logo.dart'; import 'package:touch_demonstrator/ui/pageTouchPoints/ButtonOrAnimation.dart'; import 'package:touch_demonstrator/src/blocs/appBloc.dart'; import 'package:touch_demonstrator/src/blocs/BlocProvider.dart'; import 'package:touch_demonstrator/ui/pageTouchPoints/AppBarPageTouchPoints.dart'; import 'package:touch_demonstrator/src/blocs/bluetoothBloc.dart'; void main() { testWidgets('debugBloc test', (WidgetTester tester) async { // Create the Widget and tell the tester to build it final AppBloc bloc = AppBloc(); var expectBool = true; bloc.debugBlocGetter.debugEnabledStatus$.listen(expectAsync1((status){ print('status: $status // expectBool= $expectBool'); expectLater(status, emitsInOrder([true, false])); })); for (var i = 0; i < 10; i++) { print('i: $i'); bloc.debugBlocGetter.debugCounterIncrement.add(null); if((i%3)==0){ // expect(bloc.debugBlocGetter.debugEnabledStatus$, emits(expectBool)); expectBool = !expectBool; }; } // expect(bugIconFinder, findsOneWidget); // var value = await Future.value(LogoState.debugEnableCounter); // expect(value, 5); }); testWidgets('Text above logo ', (WidgetTester tester) async { await tester.pumpWidget(TextAboveLogo()); final textFinder = find.text('Touchpad Demonstrator by'); expect(textFinder, findsOneWidget); }); testWidgets('Logo', (WidgetTester tester) async { // Create the Widget and tell the tester to build it var heightLogo = 200.0; final AppBloc bloc = AppBloc(); await tester.pumpWidget(BlocProvider( bloc: bloc, child: MaterialApp(home: Scaffold(/*appBar: buildAppBarPageTouchPoints(context),*/body: Logo(heightLogo)),))); // final myAppBar = buildAppBarPageTouchPoints(); final logoFinder = find.byType(Logo); final bugIconFinder = find.byIcon(Icons.bug_report); // Create finders to find elements in our widget we are looking for. expect(logoFinder, findsOneWidget); expect(bugIconFinder, findsNothing); // bloc.debugBlocGetter.debugEnabledStatus$.listen(expectAsync1((test)=>print('test'))); await tester.pump(); for (var i = 0; i < 7; i++) { await tester.tap(find.byType(Container)); await tester.pump(); print('tap'); } // expect(bugIconFinder, findsOneWidget); // var value = await Future.value(LogoState.debugEnableCounter); // expect(value, 5); }); testWidgets('BluetoothBloc', (WidgetTester tester) async { // Create the Widget and tell the tester to build it final AppBloc bloc = AppBloc(); await tester.pumpWidget(BlocProvider( bloc: bloc, child: Directionality( textDirection: TextDirection.ltr, child: ConnectButtonWithAnimations()))); // Create finders to find elements in our widget we are looking for. final textFinderConnect = find.text('Connect'); expect(textFinderConnect, findsOneWidget); final textFinderDisconnect = find.text('Disconnect'); expect(textFinderDisconnect, findsNothing); }); /* testWidgets('Test Text Above', (WidgetTester tester) async { await tester.pumpWidget(TextAboveLogo()); });*/ // test('page touch points test', () { //final pageTouchPoints = PageTouchPoints(); // }); } /* void main() { testWidgets('page touch points smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. // await tester.pumpWidget(new TouchDemonstrator()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }*/