mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-03 08:50:47 -06:00
- review.thesaurus's params doc parses under describe's grammar; describe's edit.copy test
expects the landing branch's {text, html?} answer.
- The Language dialog test picks the landing branch's "Français (France)" entry; the Format
Background test allows the pane's title to appear twice.
- Progress docs rebuilt from the landing branch's versions with land-r6's rows applied on top,
so the union merge no longer drops the pen-pressure, ui.pointer and ui.key rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
2.9 KiB
Rust
76 lines
2.9 KiB
Rust
//! Format Background pane: picture transparency, tiling, and Apply to All.
|
||
|
||
use deckcraft_engine::Session;
|
||
use deckcraft_model::style::PictureMode;
|
||
use deckcraft_model::{Background, Fill};
|
||
use egui_kittest::Harness;
|
||
use egui_kittest::kittest::Queryable;
|
||
use serde_json::json;
|
||
|
||
use crate::{Services, SlideApp};
|
||
|
||
/// 1×1 PNG.
|
||
const PNG: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";
|
||
|
||
fn harness(mut app: SlideApp) -> Harness<'static, SlideApp> {
|
||
app.ui.tab = "Design".into();
|
||
app.ui.pane = Some("background".into());
|
||
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
|
||
|ui, app: &mut SlideApp| {
|
||
app.logic(ui.ctx());
|
||
app.ui(ui);
|
||
},
|
||
app,
|
||
);
|
||
h.run_steps(3);
|
||
h
|
||
}
|
||
|
||
fn picture_mode(h: &Harness<'_, SlideApp>) -> PictureMode {
|
||
match &h.state().session.active().unwrap().doc.slides[0].background {
|
||
Some(Background::Fill { fill: Fill::Picture(pf) }) => pf.mode.clone(),
|
||
other => panic!("expected a picture background, got {other:?}"),
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn picture_fill_shows_transparency_and_tiling() {
|
||
let mut s = Session::with_new();
|
||
s.execute("design.background", &json!({"picture": PNG, "name": "dot.png"})).unwrap();
|
||
let mut h = harness(SlideApp::new(s, Services::default()));
|
||
assert!(h.query_all_by_label("Format Background").next().is_some(), "the pane is open");
|
||
let _ = h.get_by_label("Picture or texture fill");
|
||
assert!(h.query_all_by_label("Transparency").next().is_some());
|
||
h.get_by_label("Tile picture as texture").click();
|
||
h.run_steps(2);
|
||
let _ = h.get_by_label("Offset X");
|
||
let _ = h.get_by_label("Scale X");
|
||
let _ = h.get_by_label("Alignment");
|
||
let _ = h.get_by_label("Mirror");
|
||
assert!(matches!(picture_mode(&h), PictureMode::Tile { .. }));
|
||
}
|
||
|
||
#[test]
|
||
fn solid_fill_shows_transparency_without_tile_options() {
|
||
let mut s = Session::with_new();
|
||
s.execute("design.background", &json!({"color": "accent1"})).unwrap();
|
||
let h = harness(SlideApp::new(s, Services::default()));
|
||
assert!(h.query_all_by_label("Transparency").next().is_some());
|
||
let _ = h.get_by_label("Solid fill");
|
||
assert!(h.query_by_label("Tile picture as texture").is_none());
|
||
}
|
||
|
||
#[test]
|
||
fn apply_to_all_copies_the_picture() {
|
||
let mut s = Session::with_new();
|
||
s.execute("design.background", &json!({"picture": PNG, "name": "dot.png"})).unwrap();
|
||
s.execute("slide.new", &json!({})).unwrap();
|
||
s.execute("slide.go", &json!({"index": 0})).unwrap();
|
||
let mut h = harness(SlideApp::new(s, Services::default()));
|
||
h.get_by_label("Apply to All").click();
|
||
h.run_steps(2);
|
||
let doc = &h.state().session.active().unwrap().doc;
|
||
assert!(matches!(doc.slides[1].background, Some(Background::Fill { fill: Fill::Picture(_) })));
|
||
assert_eq!(doc.slides[1].background, doc.slides[0].background);
|
||
}
|