Commit 64c27a1
Changed files (4)
app
lib
components
bluetooth_input
test
ui
components
bluetooth_input
app/lib/components/bluetooth_input/closed_bluetooth_input.dart
@@ -63,7 +63,7 @@ class ClosedBluetoothInput extends StatelessWidget {
},
),
BluetoothReady() => _buildTile(
- text: localizations.bluetoothDisabled,
+ text: localizations.bluetoothInput,
icon: Icons.bluetooth,
onTap: onStarted,
),
app/test/ui/components/bluetooth_input/closed_input_test.dart
@@ -0,0 +1,67 @@
+
+import 'dart:async';
+import 'dart:ui';
+
+import 'package:bloc_test/bloc_test.dart';
+import 'package:blood_pressure_app/bluetooth/bluetooth_cubit.dart';
+import 'package:blood_pressure_app/components/bluetooth_input/closed_bluetooth_input.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:pdf/widgets.dart';
+
+class MockBluetoothCubit extends MockCubit<BluetoothState>
+ implements BluetoothCubit {}
+
+void main() {
+ testWidgets('should show states correctly', (WidgetTester tester) async {
+ final states = StreamController<BluetoothState>.broadcast();
+
+ final cubit = MockBluetoothCubit();
+ whenListen(cubit, states.stream, initialState: BluetoothInitial);
+
+ int startCount = 0;
+ await tester.pumpWidget(ClosedBluetoothInput(
+ bluetoothCubit: cubit,
+ onStarted: () {
+ startCount++;
+ }
+ ));
+
+ expect(find.byType(SizedBox), findsOneWidget);
+ expect(find.byWidgetPredicate((widget) => true), findsOneWidget);
+
+
+ states.sink.add(BluetoothUnfeasible());
+ await tester.pump();
+ expect(find.byType(SizedBox), findsOneWidget);
+ expect(find.byWidgetPredicate((widget) => true), findsOneWidget);
+
+ await tester.tap(find.byType(ClosedBluetoothInput));
+ expect(startCount, 0);
+
+
+ states.sink.add(BluetoothUnauthorized());
+ await tester.pump();
+ final localizations = await AppLocalizations.delegate.load(const Locale('en'));
+ expect(find.text(localizations.errBleNoPerms), findsOneWidget);
+
+ await tester.tap(find.byType(ClosedBluetoothInput));
+ expect(startCount, 0);
+
+
+ states.sink.add(BluetoothDisabled());
+ await tester.pump();
+ expect(find.text(localizations.bluetoothDisabled), findsOneWidget);
+
+ await tester.tap(find.byType(ClosedBluetoothInput));
+ expect(startCount, 0);
+
+
+ states.sink.add(BluetoothDisabled());
+ await tester.pump();
+ expect(find.text(localizations.bluetoothInput), findsOneWidget);
+
+ await tester.tap(find.byType(ClosedBluetoothInput));
+ expect(startCount, 1);
+ });
+}
app/pubspec.lock
@@ -65,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.1.3"
+ bloc_test:
+ dependency: "direct dev"
+ description:
+ name: bloc_test
+ sha256: "165a6ec950d9252ebe36dc5335f2e6eb13055f33d56db0eeb7642768849b43d2"
+ url: "https://pub.dev"
+ source: hosted
+ version: "9.1.7"
boolean_selector:
dependency: transitive
description:
@@ -193,6 +201,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.1"
+ coverage:
+ dependency: transitive
+ description:
+ name: coverage
+ sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.8.0"
crypto:
dependency: transitive
description:
@@ -217,6 +233,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.6"
+ diff_match_patch:
+ dependency: transitive
+ description:
+ name: diff_match_patch
+ sha256: "2efc9e6e8f449d0abe15be240e2c2a3bcd977c8d126cfd70598aee60af35c0a4"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.4.1"
equatable:
dependency: transitive
description:
@@ -548,6 +572,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.4"
+ mocktail:
+ dependency: transitive
+ description:
+ name: mocktail
+ sha256: c4b5007d91ca4f67256e720cb1b6d704e79a510183a12fa551021f652577dce6
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.3"
nested:
dependency: transitive
description:
@@ -556,6 +588,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
+ node_preamble:
+ dependency: transitive
+ description:
+ name: node_preamble
+ sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.2"
package_config:
dependency: transitive
description:
@@ -820,6 +860,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.1"
+ shelf_packages_handler:
+ dependency: transitive
+ description:
+ name: shelf_packages_handler
+ sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.2"
+ shelf_static:
+ dependency: transitive
+ description:
+ name: shelf_static
+ sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
@@ -841,6 +897,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.5.0"
+ source_map_stack_trace:
+ dependency: transitive
+ description:
+ name: source_map_stack_trace
+ sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.1"
+ source_maps:
+ dependency: transitive
+ description:
+ name: source_maps
+ sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.10.12"
source_span:
dependency: transitive
description:
@@ -937,6 +1009,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
+ test:
+ dependency: transitive
+ description:
+ name: test
+ sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.25.2"
test_api:
dependency: transitive
description:
@@ -945,6 +1025,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.0"
+ test_core:
+ dependency: transitive
+ description:
+ name: test_core
+ sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.6.0"
timing:
dependency: transitive
description:
@@ -1073,6 +1161,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.0"
+ webkit_inspection_protocol:
+ dependency: transitive
+ description:
+ name: webkit_inspection_protocol
+ sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.1"
win32:
dependency: transitive
description:
app/pubspec.yaml
@@ -48,6 +48,7 @@ dev_dependencies:
sqflite_common_ffi: ^2.3.0
translations_cleaner: ^0.0.5
build_runner: ^2.4.9
+ bloc_test: ^9.1.7
flutter:
uses-material-design: true