I am writing a Dart library to access a C shared object using Flutter.
So far, the example app I created is working (somewhat) as expected, but i want to include Unit testing too keep the library somewhat stable.
Details:
- Shared Objects are in APP/android/src/main/jniLibs/{abi}/liboqs.so
- The example App in example/lib/main.dart and works as expected
- Library is in APP/lib/liboqs_flutter.dart
The library uses
static final ffi.DynamicLibrary _liboqs = Platform.isAndroid
? ffi.DynamicLibrary.open("liboqs.so")
: ffi.DynamicLibrary.process();
To set up the library.
But when I attempt to access this library using flutter_test (e.g. to run the init function LiboqsFlutter.init() which runs a static final C native function OQS_init, I get:
Failed to load "/{HOME DIRECTOR}/liboqs_flutter/test/liboqs_flutter_test.dart": Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, OQS_init): symbol not found)
I understand that flutter test does not have access to the 'main' assets, but how can I force through that, so I can properly test my code?
This issue offers two solutions:
- Use flutter_driver
- Build the library using cmake with an opener function as per this example code.
but I do not fully understand exactly how to make these work for me. How does flutter driver help me here? Should the #2 code be added to the test or the original library and called in the test? If I already have prebuilt shared objects in main/jniLibs folder, do I really need to rebuild the project when I test it? That seems like a lot of wasted time just to test the app.