import 'package:flutter_test/flutter_test.dart'; import 'package:life_helper/data/ai/device_capabilities.dart'; /// #218 AC-6 boundary tests for the RAM gate. /// /// We test the abstract contract's `meetsAiMinRam()` default impl via a /// fake — the real `PlatformDeviceCapabilities.totalRamBytes()` requires /// the MethodChannel + Android runtime (covered by AC-7). class _Fake implements DeviceCapabilities { _Fake(this.bytes); final int? bytes; @override Future totalRamBytes() async => bytes; @override Future meetsAiMinRam() async { final v = await totalRamBytes(); if (v == null) return false; return v >= kAiMinRamBytes; } } void main() { test('kAiMinRamBytes equals 4 GiB', () { expect(kAiMinRamBytes, 4 * 1024 * 1024 * 1024); }); test('null totalRamBytes → meetsAiMinRam false (fail-closed)', () async { expect(await _Fake(null).meetsAiMinRam(), isFalse); }); test('3.9 GiB → meetsAiMinRam false', () async { final bytes = (3.9 * 1024 * 1024 * 1024).round(); expect(await _Fake(bytes).meetsAiMinRam(), isFalse); }); test('exactly 4 GiB - 1 byte → false', () async { expect(await _Fake(kAiMinRamBytes - 1).meetsAiMinRam(), isFalse); }); test('exactly 4 GiB → true (inclusive)', () async { expect(await _Fake(kAiMinRamBytes).meetsAiMinRam(), isTrue); }); test('8 GiB → true', () async { final bytes = 8 * 1024 * 1024 * 1024; expect(await _Fake(bytes).meetsAiMinRam(), isTrue); }); test('0 bytes → false (would also catch broken channel returning 0)', () async { expect(await _Fake(0).meetsAiMinRam(), isFalse); }); }