This version of the module is deprecated: This package is deprecated. moonbit-community/proton should be preferred.
///|
test "native ABI is loaded" {
inspect(abi_version(), content="1")
let info = runtime_info().unwrap()
inspect(info.abi_version, content="1")
assert_true(info.build_mode == "abi-only" || info.build_mode == "runtime")
assert_true(info.runtime_available == (info.build_mode == "runtime"))
assert_true(info.features.contains("event_polling"))
assert_true(info.features.contains("bridge_polling"))
}///|
test "typed runtime config JSON" {
let config = RuntimeConfig::new(
runtime_root="app-runtime",
helper_path="cef_process.exe",
cache_dir="cache",
)
let json = config.to_json_string()
assert_true(json.contains("\"abi_version\":1"))
assert_true(json.contains("\"runtime_root\":\"app-runtime\""))
assert_true(json.contains("\"helper_path\":\"cef_process.exe\""))
assert_true(json.contains("\"cache_dir\":\"cache\""))
}///|
test "bundled runtime config JSON" {
let json = RuntimeConfig::bundled(cache_dir="cache").to_json_string()
assert_true(json.contains("\"use_bundled\":true"))
assert_true(json.contains("\"cache_dir\":\"cache\""))
}///|
test "runtime and window lifecycle" {
let runtime = Runtime::new().unwrap()
let window = Window::new(
runtime,
config=WindowConfig::new(
title="Proton",
width=320,
height=240,
initial_url="about:blank",
),
).unwrap()
match runtime.poll_event() {
Ok(Some(event)) => inspect(event.event_type(), content="window_created")
_ => fail("expected window_created")
}
debug_inspect(
window.load_html("<p>Hello Proton</p>", "proton://app/"),
content="Ok(())",
)
debug_inspect(window.destroy(), content="Ok(())")
debug_inspect(runtime.destroy(), content="Ok(())")
}///|
test "runtime wait event readiness" {
let runtime = Runtime::new().unwrap()
let empty = runtime
.wait(interest_mask=runtime_wait_event, timeout_ms=0)
.unwrap()
inspect(empty.is_timeout(), content="true")
let window = Window::new(runtime).unwrap()
let ready = runtime
.wait(interest_mask=runtime_wait_event, timeout_ms=0)
.unwrap()
inspect(ready.has_event(), content="true")
match runtime.poll_event() {
Ok(Some(event)) => inspect(event.event_type(), content="window_created")
_ => fail("expected window_created")
}
debug_inspect(window.destroy(), content="Ok(())")
debug_inspect(runtime.destroy(), content="Ok(())")
}fn BridgeConfig::new(ops~ : Array[String], max_payload_bytes? : Int, request_timeout_ms? : Int) -> BridgeConfigtype Runtimefn Runtime::respond_bridge_request(self : Runtime, response : BridgeResponse) -> Result[Unit, NativeError]fn Runtime::wait(self : Runtime, interest_mask~ : Int, timeout_ms~ : Int) -> Result[RuntimeWaitReady, NativeError]fn RuntimeConfig::new(runtime_root? : String, helper_path? : String, resources_dir? : String, locales_dir? : String, cache_dir? : String, remote_debugging_port? : Int) -> RuntimeConfigtype Windowfn WindowConfig::new(title? : String, width? : Int, height? : Int, initial_url? : String) -> WindowConfig