color-ui: tests follow the contract

This commit is contained in:
bflatastic
2026-11-21 22:03:44 +07:00
parent 53aff18738
commit 03fae1e210
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
use craft_color_ui::AreaMode;
use craft_color_ui::ui::{AreaShape, ColorArea, Gamut};
use craft_theme::{ColorModel, HsbModel, Srgba};
use craft_ui::contract::{Bind, Props as _, Show as _};
use craft_ui::contract::{Bind, Show as _};
use craft_ui::testing::{Fixture, Story, StoryData, StoryOutput, trial};
use egui::{Color32, Pos2, Rect, Shape, Ui, Vec2};
+1 -1
View File
@@ -209,7 +209,7 @@ fn a_square_wheel_hands_the_inner_press_to_the_square_and_its_markers_pick() {
let square = rig.fixture.by_label("Saturation and brightness").expect("the square").rect;
rig.fixture.click_at(pos2(square.right() + 2.0, square.center().y));
rig.fixture.idle(2);
let [hue, saturation, brightness] = rig.values.get().values;
let [hue, saturation, brightness, _] = rig.values.get().values;
assert_eq!(hue, 200.0, "the square leaves the hue");
assert_eq!(saturation, 100.0, "beside the square's right edge is full saturation");
assert!((brightness - 50.0).abs() < 4.0, "level with the square's middle is half brightness: {brightness}");
+1 -1
View File
@@ -82,7 +82,7 @@ fn a_pair_well_drags_its_payload_and_takes_a_drop_a_mixed_well_does_neither() {
fixture.settle();
let wells = fixture.by_role(Role::RADIO_BUTTON);
let [a_primary, a_secondary, b_primary, b_secondary] = [0, 1, 2, 3].map(|i| wells[i].rect);
let mut drag = |fixture: &mut Fixture, from: egui::Pos2, to: egui::Pos2| {
let drag = |fixture: &mut Fixture, from: egui::Pos2, to: egui::Pos2| {
*log.borrow_mut() = Log::default();
fixture.drag_at(from, to - from);
};
+1 -1
View File
@@ -383,7 +383,7 @@ fn the_color_picker_dialogs_swatch_view_marks_the_current_colour_and_a_pick_is_a
fixture.click(&toggle).idle(4);
let selected = |fixture: &Fixture, name: &str| {
let cell = fixture.by_label(name).unwrap_or_else(|| panic!("the swatch view shows {name}"));
fixture.tree().data_of(cell.node).and_then(|data| data.is_selected()).unwrap_or(false)
fixture.tree().selected_of(cell.node).unwrap_or(false)
};
assert!(selected(&fixture, "Red"), "the cell equal to the current colour is marked");
assert!(!selected(&fixture, "Blue"), "and no other");