Plugin Test Harness
Runs a built plugin jar on the real SDK runtime and a fake car, so a plugin's host tests need no setup code.
start copies the jar into a temporary "unit" under the test's temp directory, installs what the unit would hold after the user installed the package (grants, icons), starts SdkRuntime on FakePlatform and waits until the plugin is ENABLED. Drive the plugin through ui and car, move time with advance, and assert on what the UI shows and what the plugin stored.
void startsEnabled(@TempDir File tmp) {
try (PluginTestHarness h = PluginTestHarness.start(tmp)) {
h.await(() -> !h.ui().render(h.pageKey("main")).isEmpty(), "the page");
}
}
Where the files come from: the plugin jar is -Dmibsdk.pluginJar (or jar); the icon PNGs are <name>.png in -Dmibsdk.pluginIcons (or icons), by default src/main/icons of the project under test. The build sets both properties for a plugin's tests.
What the "unit" is given, so a test sees the same thing every time:
sdk.propertiesisplugin.start.delay.ms=0(no start delay),heap.low.bytes=0(no heap guard),ui.publish.min.ms=0(no UI throttle) andlog.file=<tmp>/mibsdk.log.grants.propertiesgrants the permissions given to grants, by default every permission the plugin'splugin.jsondeclares.- The unit has the features given to features, by default every Features constant.
- Icons are installed as mibpkg does: each icon in
plugin.jsonis copied toicons/<id>/<sha16>.png, where sha16 is the first 16 lowercase hex characters of the PNG's SHA-256, with anindex.propertiesline<name>=<sha16>,<width>,<height>. iconSha gives the sha16 for an assertion such as"[png:" + h.iconSha("cup") + "] Coffee". - The Scheduler's clock is the real uptime plus advance.
- The plugin's storage starts with the values given to storedValues, by default empty.
After restart the harness has a new runtime, UI and car: call ui and car again. Waits last 5 seconds. A harness is for one plugin on one thread; close stops the runtime.
Functions
condition; fails with what, the plugin's pages and the runtime log.-Dmibsdk.pluginJar and the icons in -Dmibsdk.pluginIcons.builder(tmp).start().data/<id>.properties; empty if none.