Files
Qlyra/test/rlottie_disk_cache_test.dart
sevenhill f74057ce9b
Build Android (FCM) / build-android-fcm (push) Canceled after 0s
Build Android / build-android (push) Canceled after 0s
Build iOS / build-ios (push) Canceled after 0s
Build Linux / build-linux (push) Canceled after 0s
Build macOS / build-macos (push) Canceled after 0s
Build Windows / build-windows (push) Canceled after 0s
Release (main) / android (oneme) (push) Canceled after 0s
Release (main) / android (qlyra) (push) Canceled after 0s
Release (main) / windows (push) Canceled after 0s
Release (main) / linux (push) Canceled after 0s
Release (main) / macos (push) Canceled after 0s
Release (main) / ios (push) Canceled after 0s
Release (main) / release (push) Canceled after 0s
Rebrand application as Qlyra
2026-08-30 13:16:17 +03:00

66 lines
1.8 KiB
Dart

import 'dart:io';
import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:qlyra/core/media/rlottie/rlottie_disk_cache.dart';
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class _FakePathProvider extends PathProviderPlatform
with MockPlatformInterfaceMixin {
_FakePathProvider(this.dir);
final String dir;
@override
Future<String?> getApplicationSupportPath() async => dir;
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test('disk cache round-trips rendered frames', () async {
final tmp = Directory.systemTemp.createTempSync('rlottie_cache_test');
PathProviderPlatform.instance = _FakePathProvider(tmp.path);
const px = 32;
const frameCount = 5;
final frames = List.generate(frameCount, (f) {
final buf = Uint8List(px * px * 4);
for (var i = 0; i < buf.length; i++) {
buf[i] = (f * 37 + i) & 0xff;
}
return buf;
});
const url = 'https://example.com/anim.json';
await RlottieDiskCache.instance.store(
url: url,
px: px,
frameCount: frameCount,
frameRate: 30,
durationMs: 166,
frames: frames,
);
final loaded = await RlottieDiskCache.instance.load(url, px);
expect(loaded, isNotNull);
expect(loaded!.px, px);
expect(loaded.frameCount, frameCount);
expect(loaded.frameRate, 30);
expect(loaded.durationMs, 166);
for (var f = 0; f < frameCount; f++) {
expect(
loaded.frames[f],
orderedEquals(frames[f]),
reason: 'frame $f bytes preserved',
);
}
expect(
await RlottieDiskCache.instance.load('https://other/x.json', px),
isNull,
);
tmp.deleteSync(recursive: true);
});
}