WIP: UI编辑器自动分图层切图标 #304
@@ -92,6 +92,21 @@ mod tests {
|
||||
"image"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn construction_uses_distinct_root_id_for_root_image() {
|
||||
let image = Component::Image(ImageComponent {
|
||||
target_graphic: None,
|
||||
image_type: ImageType::Simple {
|
||||
preserve_aspect: false,
|
||||
},
|
||||
});
|
||||
let root = node("root-image", vec![image], vec![]);
|
||||
let result = construct_separation_state(&state(root));
|
||||
let tree = &result.unprocessed_trees[0];
|
||||
assert_ne!(tree.root.id, tree.root.children[0].id);
|
||||
assert_eq!(tree.root.children[0].id.as_str(), "root-image");
|
||||
}
|
||||
#[test]
|
||||
fn binding_validation_requires_exact_batch_coverage() {
|
||||
let node = SeparationNode {
|
||||
|
||||
@@ -85,7 +85,14 @@ pub fn construct_separation_state(state: &State) -> SeparationState {
|
||||
(!children.is_empty()).then(|| SeparationTree {
|
||||
src_ui_design: tree.src_ui_design.clone(),
|
||||
root: SeparationNode {
|
||||
id: tree.root.id.clone(),
|
||||
// The synthetic root must never share an ID with a real
|
||||
// UI node. A single-image design may use the original
|
||||
// tree root as an eligible separation leaf.
|
||||
id: NodeId::new(format!(
|
||||
"separation-root-{}",
|
||||
uuid::Uuid::new_v4().simple()
|
||||
))
|
||||
.expect("synthetic separation root id is valid"),
|
||||
global_pos_x_px: 0,
|
||||
global_pos_y_px: 0,
|
||||
width_px: image.pixel_size.x.max(0.0).round() as u32,
|
||||
|
||||
Reference in New Issue
Block a user