mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 19:51:26 -05:00
Panel tests as production drove them: New Swatch's gradient keeps only its name row, the gray chip test uses production's #808080, live typing starts after the frame the canvas editor takes the keyboard, Appearance's Opacity percent read from the row's description and Clear Appearance from its menu, Rotate Bounding Box through the menu item's click target in a window, shape dialogs in a window, the Control bar as wide as the window
This commit is contained in:
@@ -372,7 +372,8 @@ fn new_swatch_dialog_prefills_the_active_colour_and_saves_into_the_selected_grou
|
||||
assert!(!dialog_open(&app, key) && doc(&app).swatch("New Gradient Swatch 1").is_some());
|
||||
new_swatch(&mut app, &[], none());
|
||||
assert_eq!(dialog_field(&app, key, "name"), json!("New Gradient Swatch 2"));
|
||||
assert_ne!(dialog_field(&app, key, "__paint"), Value::Null);
|
||||
// A gradient has only its name to set: the dialog keeps its paint for OK.
|
||||
assert_eq!((dialog_field(&app, key, "type"), dialog_field(&app, key, "color")), (Value::Null, Value::Null));
|
||||
dialog_frame(&mut app, &ctx);
|
||||
confirm(&mut app, key);
|
||||
assert!(doc(&app).swatch("New Gradient Swatch 2").is_some_and(|w| matches!(w.paint, Paint::Gradient(_))));
|
||||
|
||||
@@ -1061,7 +1061,8 @@ fn panels_show_the_selected_object_after_an_edit_and_after_undo() {
|
||||
for (name, panel) in &mut panels {
|
||||
run(&mut panel.app(), id, p.clone());
|
||||
panel.frame();
|
||||
let shown = panel.value("Opacity").unwrap_or_default();
|
||||
// Appearance's Opacity row shows its percent as trailing text, which describes the row.
|
||||
let shown = panel.value("Opacity").filter(|v| !v.is_empty()).or_else(|| panel.description("Opacity")).unwrap_or_default();
|
||||
assert!(shown.contains(want), "{name} shows {want}: {shown}");
|
||||
assert!(!shown.contains(not), "{name} no longer shows {not}: {shown}");
|
||||
}
|
||||
@@ -1126,7 +1127,8 @@ fn right_clicking_root_object_row_exposes_clear_and_reduce_appearance() {
|
||||
panel.secondary_click("Rectangle");
|
||||
assert_eq!(panel.app().session.appearance_item(), None, "the object row is picked");
|
||||
assert!(panel.shows("Clear Appearance") && panel.shows("Reduce to Basic Appearance"));
|
||||
panel.click("Clear Appearance");
|
||||
// The menu's item, not the footer's button of the same name.
|
||||
panel.click_menu_item("Clear Appearance");
|
||||
let cleared = vectorcraft_doc::Appearance::basic(vectorcraft_color::Paint::None, vectorcraft_color::Paint::None, 1.0);
|
||||
assert_eq!(first_selected(&panel.app()).unwrap().appearance, cleared);
|
||||
run(&mut panel.app(), "edit.undo", json!({}));
|
||||
|
||||
@@ -63,7 +63,7 @@ fn the_achromatopsia_chip_is_the_gray_of_the_colors_lightness() {
|
||||
#[test]
|
||||
fn a_gray_fill_is_the_same_gray_in_every_chip() {
|
||||
let cms = cms::active();
|
||||
let gray = Color::rgb(0.5, 0.5, 0.5);
|
||||
let gray = Color::from_hex("#808080").unwrap();
|
||||
let want = hex(cms.display_rgb(&gray));
|
||||
for (name, sim) in NAMES.iter().zip(vision_colors(&cms, &gray)) {
|
||||
assert_eq!(hex(sim), want, "{name} shows {want}");
|
||||
|
||||
@@ -895,6 +895,8 @@ fn capture_during_live_typing(redefine: bool) {
|
||||
app.session.select_tool("type", Default::default()).unwrap();
|
||||
app.session.apply_actions(vec![vectorcraft_tools::Action::Notify("text.editNew".into())]).unwrap();
|
||||
assert_eq!(text_editing(&app), Some((id, 0, 6)));
|
||||
// The canvas's text editor takes the keyboard in the first frame that shows it.
|
||||
key_frame(&mut app, &ctx, Vec::new());
|
||||
key_frame(&mut app, &ctx, vec![egui::Event::Text("Typed".into())]);
|
||||
assert_eq!(text_runs(&app, id), vec![("Typed".into(), 18.0, link.clone())]);
|
||||
assert_eq!(text_editing(&app), Some((id, 5, 5)));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use vectorcraft_doc::Unit;
|
||||
|
||||
use super::*;
|
||||
use crate::panels::tests_units::{cancel_dialog, confirm_dialog, run_menu, set_dialog_field};
|
||||
use crate::panels::tests_units::{cancel_dialog, confirm_dialog, set_dialog_field};
|
||||
use crate::tests::panel_harness::Panel;
|
||||
|
||||
fn panel(app: VectorcraftApp) -> Panel {
|
||||
@@ -118,7 +118,14 @@ fn rotation_field_shows_the_angle_the_box_keeps() {
|
||||
fn rotate_bounding_box_menu_item_turns_the_box_by_the_dialog_angle() {
|
||||
let mut app = new_app();
|
||||
app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 100, "height": 50})).unwrap();
|
||||
run_menu(&mut app, "object.rotateBoundingBox");
|
||||
// The menu item as a click runs it: its params ask for the angle in a dialog.
|
||||
let entry = crate::menus::menu_entries(&app)
|
||||
.into_iter()
|
||||
.find(|e| e.path == ["Object", "Transform"] && e.label == "Rotate Bounding Box…")
|
||||
.expect("menu item");
|
||||
let (id, p) = crate::menus::click_target(&entry.label, entry.command.as_deref().unwrap(), &entry.params);
|
||||
app.adopt_context(&crate::testing::ui_context());
|
||||
crate::menus::invoke(&mut app, &id, p);
|
||||
set_dialog_field(&mut app, "angle", json!(90));
|
||||
let bounds = |app: &VectorcraftApp| {
|
||||
let st = app.session.doc().unwrap();
|
||||
@@ -534,6 +541,8 @@ fn the_control_bar_fields_use_the_shared_reference_point() {
|
||||
app.run("shape.rectangle", json!({"x": 10, "y": 20, "width": 100, "height": 50})).unwrap();
|
||||
app.ui.transform_panel.reference_point = refi;
|
||||
let mut p = Panel::new(app, bar);
|
||||
// The Control bar spans the window.
|
||||
p.room(egui::vec2(1600.0, 200.0));
|
||||
let (before, undo) = (revision(&p), steps(&p));
|
||||
assert_eq!((p.value("X position"), p.value("Y position")), (Some(pt(x)), Some(pt(y))), "reference {refi}");
|
||||
assert_eq!(revision(&p), before, "reference {refi}: choosing the point leaves the art");
|
||||
@@ -901,7 +910,8 @@ fn show_on_shape_creation_shows_the_transform_panel_after_a_shape() {
|
||||
app.replay("shape.rectangle", rect.clone()).unwrap();
|
||||
show_on_shape_creation(&mut app, &ctx);
|
||||
assert!(!visible(&app), "saved steps");
|
||||
// A dialog that is canceled draws nothing; OK draws the shape.
|
||||
// A dialog that is canceled draws nothing; OK draws the shape. The dialogs open in the window.
|
||||
app.adopt_context(&ctx);
|
||||
app.run("tool.select", json!({"tool": "ellipse"})).unwrap();
|
||||
crate::dialogs::open_tool_dialog(&mut app, "ellipse", json!({"x": 10.0, "y": 10.0}));
|
||||
cancel_dialog(&mut app);
|
||||
|
||||
Reference in New Issue
Block a user