2024-03-11 18:42:48 +01:00
|
|
|
import 'dart:ffi';
|
|
|
|
import 'dart:io';
|
|
|
|
|
2024-03-12 19:53:16 +01:00
|
|
|
import 'package:dart_openmvg/openmvg_c_shim.dart';
|
|
|
|
import 'package:dart_openmvg/dynloader.dart';
|
|
|
|
import 'package:dart_openmvg/util.dart';
|
2024-03-11 18:42:48 +01:00
|
|
|
import 'package:ffi/ffi.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
import "package:path/path.dart" show dirname, join;
|
|
|
|
|
2024-03-12 19:53:16 +01:00
|
|
|
final assets = join(HERE.path, "assets");
|
2024-03-11 18:42:48 +01:00
|
|
|
final testFrames = join(assets, "test", "frames");
|
|
|
|
final firstFrame = join(testFrames, "0001.png");
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
group('Unit Tests', () {
|
|
|
|
setUp(() {});
|
|
|
|
|
|
|
|
tearDown(() {
|
|
|
|
// Tear down code
|
|
|
|
});
|
|
|
|
test('newFrame', () {
|
2024-03-12 19:53:16 +01:00
|
|
|
final frameData = readUint8Ptr(File(firstFrame));
|
|
|
|
final frame = newFrame(frameData.ptr, frameData.length, 768, 768, 1204);
|
|
|
|
expect(frame.ref.h, 768);
|
|
|
|
expect(frame.ref.w, 768);
|
|
|
|
expect(frame.ref.h, 768);
|
|
|
|
final data = getImageData(frame);
|
|
|
|
expect(data.ref.error, 0);
|
|
|
|
|
|
|
|
// clean up the memory. ;-)
|
|
|
|
calloc.free(data);
|
|
|
|
calloc.free(frame);
|
2024-03-11 18:42:48 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|