Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Add comprehensive tests for Omi BLE services #12

Description

@unforced

Problem

Current test coverage (27 tests) only covers models and validators. Missing tests for critical BLE functionality:

  • BLE connection logic
  • Audio packet assembly
  • Codec conversion (PCM8/16, Opus)
  • Platform-specific behavior
  • Error recovery scenarios

Suggested Test Files

Create the following test suite:

test/services/omi/
├── omi_bluetooth_service_test.dart
├── omi_connection_test.dart
├── omi_capture_service_test.dart
├── wav_bytes_util_test.dart
└── platform_utils_test.dart

Example Tests

1. omi_bluetooth_service_test.dart

group('OmiBluetoothService', () {
  test('should discover devices during scan', () async { ... });
  test('should connect to device by ID', () async { ... });
  test('should handle disconnection', () async { ... });
  test('should auto-reconnect to paired device', () async { ... });
});

2. wav_bytes_util_test.dart

group('WavBytesUtil - Frame Assembly', () {
  test('should assemble multi-packet frames correctly', () { ... });
  test('should handle lost frames gracefully', () { ... });
  test('should decode Opus frames to PCM', () { ... });
  test('should build valid WAV header', () { ... });
});

3. omi_capture_service_test.dart

group('OmiCaptureService', () {
  test('should start recording on button event', () async { ... });
  test('should save recording with correct metadata', () async { ... });
  test('should handle codec selection', () async { ... });
});

Mocking Strategy

Use mocktail for mocking BLE dependencies:

dev_dependencies:
  mocktail: ^1.0.0

Benefits

  • Catch regressions early
  • Document expected behavior
  • Enable confident refactoring
  • Improve code quality

Priority

Medium - Important for long-term maintainability

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions