Skip to content

Commit

Permalink
initial device definition test
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 5, 2024
1 parent 5d74a05 commit 6895674
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/Backend/device_definition_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart' as flTest;
import 'package:tail_app/Backend/Bluetooth/bluetooth_manager.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_manager_plus.dart';
import 'package:tail_app/Backend/Definitions/Device/device_definition.dart';
import 'package:test/test.dart';

import '../testing_utils/bluetooth_test_utils.dart';
import '../testing_utils/gear_utils.dart';
import '../testing_utils/hive_utils.dart';

void main() {
setUp(() async {
flTest.TestWidgetsFlutterBinding.ensureInitialized();
await setupHive();
});
tearDown(() async {
await deleteHive();
isAnyGearConnected.value = false;
});
group('Stateful Device event listeners', () {
test('Battery Levels', () async {
setupBTMock('MiTail', 'TestMiTail');
ProviderContainer container = await testGearAdd('MiTail', gearMacPrefix: 'Test');
BaseStatefulDevice baseStatefulDevice = container.read(knownDevicesProvider).values.first;
expect(baseStatefulDevice.batteryLevel.value, -1);
expect(baseStatefulDevice.batlevels.isEmpty, true);
baseStatefulDevice.batteryLevel.value = 100;
expect(baseStatefulDevice.batteryLevel.value, 100);
expect(baseStatefulDevice.batlevels.length, 1);
expect(baseStatefulDevice.batlevels.first.y, 100);
baseStatefulDevice.reset();
expect(baseStatefulDevice.batteryLevel.value, -1);
expect(baseStatefulDevice.batlevels.isEmpty, true);
});
});
}

0 comments on commit 6895674

Please sign in to comment.