mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-20 06:20:50 +01:00
Adapt the bake job tests to RunningBake and mesh_id
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0cf1edb328
commit
2e021b851b
2 files changed
+15
-3
No files matched your search
@@ -125,9 +125,11 @@ fn a_ready_result_waits_for_the_map_stream_to_close() {
|
||||
result_sender.send(Ok(output)).unwrap();
|
||||
let app = harness.state_mut();
|
||||
app.start_bake(vec![0]);
|
||||
let mesh_id = app.session.mesh_id;
|
||||
app.bake = Some(BakeJob {
|
||||
queue: Vec::new(),
|
||||
total: 1,
|
||||
mesh_id,
|
||||
current: Some(RunningBake {
|
||||
set_index: 0,
|
||||
progress: Arc::new(Progress::new()),
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::sync::atomic::Ordering;
|
||||
|
||||
use egui_kittest::Harness;
|
||||
use texturecraft_engine::bake::Progress;
|
||||
use texturecraft_ui_egui::{BakeJob, TextureCraftApp};
|
||||
use texturecraft_ui_egui::{BakeJob, RunningBake, TextureCraftApp};
|
||||
|
||||
/// An app with a running bake job (its worker never answers) started on mesh `mesh_id`.
|
||||
fn harness_with_job(mesh_id: impl FnOnce(u64) -> u64) -> (Harness<'static, TextureCraftApp>, Arc<Progress>) {
|
||||
@@ -14,11 +14,21 @@ fn harness_with_job(mesh_id: impl FnOnce(u64) -> u64) -> (Harness<'static, Textu
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session));
|
||||
h.run_steps(4);
|
||||
let progress = Arc::new(Progress::new());
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
let (tx, receiver) = std::sync::mpsc::channel();
|
||||
let (maps_tx, maps) = std::sync::mpsc::channel();
|
||||
let id = mesh_id(h.state().session.mesh_id);
|
||||
// Leak the sender so the channel stays empty instead of closed.
|
||||
std::mem::forget(tx);
|
||||
h.state_mut().bake = Some(BakeJob { queue: vec![], current: Some((0, progress.clone(), rx)), total: 1, mesh_id: id });
|
||||
std::mem::forget(maps_tx);
|
||||
let running = RunningBake {
|
||||
set_index: 0,
|
||||
progress: progress.clone(),
|
||||
receiver,
|
||||
maps,
|
||||
maps_done: Arc::new(std::sync::atomic::AtomicUsize::new(0)),
|
||||
maps_total: 1,
|
||||
};
|
||||
h.state_mut().bake = Some(BakeJob { queue: vec![], current: Some(running), total: 1, mesh_id: id });
|
||||
(h, progress)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user