From 0249876623c6713a19f931798e7b04e3830c83c1 Mon Sep 17 00:00:00 2001 From: Ivan Pashchenko Date: Wed, 27 Mar 2024 16:23:43 +0100 Subject: [PATCH] IJPL-442: add tests for CEF vmoptions GitOrigin-RevId: 27e3304c08bb8e7517096c0157bec957f1f07f59 --- native/XPlatLauncher/tests/default_tests.rs | 20 ++++++++++++++++++++ native/XPlatLauncher/tests/utils/mod.rs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/native/XPlatLauncher/tests/default_tests.rs b/native/XPlatLauncher/tests/default_tests.rs index 4025ac4f6dc6..c343cbdae3c3 100644 --- a/native/XPlatLauncher/tests/default_tests.rs +++ b/native/XPlatLauncher/tests/default_tests.rs @@ -10,6 +10,9 @@ mod tests { use xplat_launcher::jvm_property; use crate::utils::*; + #[cfg(target_os = "windows")] + use xplat_launcher::cef_generated::CEF_VERSION; + #[test] fn correct_launcher_startup_test() { run_launcher(LauncherRunSpec::standard().assert_status()); @@ -79,10 +82,27 @@ mod tests { let path = PathBuf::from(vm_option.split_once('=').unwrap().1); assert_eq!(vm_options_file.canonicalize().unwrap(), path.canonicalize().unwrap()); + // hardcoded vmoptions + assert_vm_option_presence(&dump, "-Dide.native.launcher=true"); + dump.vmOptions.iter().find(|s| s.starts_with("-XX:ErrorFile=")) .unwrap_or_else(|| panic!("'-XX:ErrorFile=' is not in {:?}", dump.vmOptions)); } + #[test] + #[cfg(target_os = "windows")] + fn cef_sandbox_vm_options_test() { + let test = prepare_test_env(LauncherLocation::Standard); + let vm_options_name = "xplat64.exe.vmoptions"; + let vm_options_file = test.dist_root.join("bin").join(vm_options_name); + + let dump = run_launcher_ext(&test, LauncherRunSpec::standard().with_dump().assert_status()).dump(); + + assert_vm_option_presence(&dump, format!("-Djcef.sandbox.cefVersion={CEF_VERSION}").as_ref()); + dump.vmOptions.iter().find(|s| s.starts_with("-Djcef.sandbox.ptr=")) + .unwrap_or_else(|| panic!("'-Djcef.sandbox.ptr=' is not in {:?}", dump.vmOptions)); + } + #[test] fn path_macro_expansion_test() { let test = prepare_test_env(LauncherLocation::Standard); diff --git a/native/XPlatLauncher/tests/utils/mod.rs b/native/XPlatLauncher/tests/utils/mod.rs index ab9539f43d0b..778133952b59 100644 --- a/native/XPlatLauncher/tests/utils/mod.rs +++ b/native/XPlatLauncher/tests/utils/mod.rs @@ -156,7 +156,7 @@ struct TestEnvironmentShared { fn prepare_test_env_impl<'a>(launcher_location: LauncherLocation, with_jbr: bool) -> Result> { INIT.call_once(|| { - let shared = init_test_environment_once().expect("Failed to init shared test environment"); + let shared = init_test_environment_once().context("Failed to init shared test environment").unwrap(); unsafe { SHARED = Some(shared) }