Files
phantom a2846d8b3a A GOOD MILESTONE : Refactor title bar and toolbar typography, improve tooltip styles, and enhance selection transform functionality
- Updated typography constants for menu bar and tooltips to improve readability and consistency.
- Adjusted button padding and widths in the title bar for better layout.
- Replaced tooltip implementation with a new balloon tooltip style for improved visual feedback.
- Enhanced selection transform logic to support rotation and resizing, ensuring accurate hit testing and bounds calculations.
- Added tests for selection clearing and transformed bounds to ensure functionality and prevent regressions.
- Introduced a new module for managing selection transform dirty bounds during interactive previews.
2026-07-18 20:31:31 +03:00

55 lines
2.1 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Selection pixel-clearing regression tests.
//!
//! **Purpose:** Verifies that destructive selection operations use the active
//! document selection mask rather than the brush stroke's temporary mask cache.
//!
//! **Logic & Workflow:** Each test creates an opaque raster layer through the
//! public engine API, installs a deterministic selection mask, clears selected
//! pixels, and compares alpha values inside and outside that mask.
//!
//! **Side Effects / Dependencies:** Uses only in-memory `hcie-engine-api` state;
//! no files, network services, GUI runtime, or engine internals are accessed.
use hcie_engine_api::Engine;
/// Confirms that selection clearing removes internal pixels and preserves all
/// pixels external to the selection.
///
/// **Purpose:** Prevents a regression where `clear_selection_pixels` consulted
/// an empty stroke cache and consequently cleared the complete active layer.
///
/// **Logic & Workflow:** Creates a 3×3 opaque layer, selects only its center
/// pixel, invokes selection clearing, then checks every resulting alpha value.
///
/// **Arguments & Returns:** Takes no arguments and returns nothing; assertion
/// failures report whether an internal or external pixel was handled wrongly.
///
/// **Side Effects / Dependencies:** Mutates only the local in-memory engine and
/// records the normal undo snapshot generated by the clear operation.
#[test]
fn clear_selection_pixels_clears_inside_and_preserves_outside() {
let mut engine = Engine::new(3, 3);
engine.set_active_layer_pixels(vec![255; 3 * 3 * 4]);
let mut mask = vec![0; 3 * 3];
mask[4] = 255;
engine.set_selection_mask(mask);
engine.clear_selection_pixels();
let pixels = engine
.get_active_layer_pixels()
.expect("a new engine must have an active raster layer");
for pixel_index in 0..9 {
let alpha = pixels[pixel_index * 4 + 3];
if pixel_index == 4 {
assert_eq!(alpha, 0, "selected center pixel must be cleared");
} else {
assert_eq!(
alpha, 255,
"unselected pixel {pixel_index} must be preserved"
);
}
}
}