This repository has been archived on 2026-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
molotov/crates/molotov-core/tests/asset_manager_test.rs

28 lines
1,005 B
Rust

// SPDX-License-Identifier: GPL-3.0-or-later
use molotov_core::assets::c_api::*;
use std::ffi::CString;
#[test]
fn test_end_to_end_asset_and_mod_overlay_streaming() {
// Register base asset and mod override
let mgr_handle = register_test_asset("content/fonts/arial.ttf", b"DEFAULT_FONT_DATA".to_vec());
if let Ok(mut mgr) = GLOBAL_ASSET_MANAGER.write() {
mgr.add_mod_override("content/fonts/arial.ttf", b"CUSTOM_COMIC_SANS_MOD".to_vec());
}
unsafe {
let path = CString::new("content/fonts/arial.ttf").unwrap();
let asset = AAssetManager_open(mgr_handle, path.as_ptr(), 1);
assert!(!asset.is_null());
let len = AAsset_getLength(asset);
assert_eq!(len, 21);
let mut out = vec![0u8; len as usize];
let read = AAsset_read(asset, out.as_mut_ptr() as *mut _, len as usize);
assert_eq!(read, 21);
assert_eq!(&out, b"CUSTOM_COMIC_SANS_MOD", "Must load custom user mod");
AAsset_close(asset);
}
}