show-w10: net change of 1 commits

- show-w10: written by an agent
This commit is contained in:
Dylan M. Taylor
2026-11-27 14:51:30 +00:00
parent 781414d97f
commit 54ef0fb1ca
3 changed files with 504 additions and 644 deletions
+23 -11
View File
@@ -3,19 +3,21 @@
use serde_json::json;
use crate::{Services, SlideApp};
use crate::Services;
use crate::test_harness::{harness, harness_with};
use craft::behavior::{Monitor, MonitorKey};
use craft::window::system::FakeSystem;
use deckcraft_engine::Session;
use std::sync::Arc;
#[test]
fn show_presenter_answers_on_and_window() {
// P3(show-w10): sh.A2
let mut app = SlideApp::new_base(Session::with_new(), Services::default());
let mut h = harness(Session::with_new(), Services::default());
let app = h.state_mut();
let v = app.run("show.presenter", json!({"on": true})).unwrap();
assert_eq!(v, json!({"on": true, "window": true}));
let v = app.run("show.presenter", json!({})).unwrap();
assert_eq!(v["on"], false, "no `on` toggles: {v}");
let doc = crate::UI_COMMANDS.iter().find(|c| c.0 == "show.presenter").unwrap().3;
assert!(doc.contains("separate window"), "{doc}");
}
#[test]
@@ -23,12 +25,22 @@ fn presenter_view_needs_a_second_display() {
// One display: the presenter window covered the show (or the show covered it) and the
// hidden window stalled every frame.
let presenter = |displays: Option<usize>, setting: bool| {
let services = Services { displays: Some(Box::new(move || displays)), ..Default::default() };
// P3(show-w10): sh.A2
let mut app = SlideApp::new_base(Session::with_new(), services);
app.ui.presenter_view = setting;
app.start_show(0, false);
app.show.as_ref().map(|s| s.presenter)
let system = Arc::new(FakeSystem::default());
system.set_monitors(
(0..displays.unwrap_or(0))
.map(|i| Monitor::new(MonitorKey::new(format!("Display {i}"), [1280, 800]), [i as i32 * 1280, 0], [1280, 800], 1.0))
.collect(),
);
let mut h = harness_with(
Session::with_new(),
Services::default(),
egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)),
move |platform| platform.install.window_system = system,
);
h.state_mut().ui.presenter_view = setting;
h.state_mut().start_show(0, false);
h.run_steps(3);
h.state().show.as_ref().map(|s| s.presenter)
};
assert_eq!(presenter(Some(1), true), Some(false));
assert_eq!(presenter(Some(2), true), Some(true));
File diff suppressed because it is too large Load Diff
+17 -30
View File
@@ -5,20 +5,11 @@
use serde_json::json;
use crate::{Services, SlideApp};
use crate::Services;
use crate::show::commands::{ShowCommands, ShowWindow, run_command};
use crate::test_harness::harness_with;
use deckcraft_engine::Session;
fn harness(session: Session, size: egui::Vec2) -> egui_kittest::Harness<'static, SlideApp> {
egui_kittest::Harness::builder().with_size(size).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
// P3(show-w10): sh.A2
SlideApp::new_base(session, Services::default()),
)
}
/// The tallest slide allowed (1 × 56): its thumbnails and presenter-view preview are tens of
/// thousands of pixels high at their usual widths.
fn tall_deck() -> Session {
@@ -32,7 +23,7 @@ fn tall_deck() -> Session {
fn a_slide_show_on_a_screen_wider_than_the_texture_limit() {
let mut s = Session::with_new();
s.execute("slide.new", &json!({})).unwrap();
let mut h = harness(s, egui::vec2(2600.0, 1500.0));
let mut h = harness_with(s, Services::default(), egui_kittest::Harness::builder().with_size(egui::vec2(2600.0, 1500.0)), |_| {});
h.run_steps(2);
h.state_mut().run("show.start", json!({})).unwrap();
h.run_steps(4);
@@ -41,7 +32,7 @@ fn a_slide_show_on_a_screen_wider_than_the_texture_limit() {
#[test]
fn a_very_tall_slide_in_the_editor_views_and_presenter_view() {
let mut h = harness(tall_deck(), egui::vec2(1280.0, 800.0));
let mut h = harness_with(tall_deck(), Services::default(), egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)), |_| {});
h.run_steps(3);
for (cmd, p) in [("view.sorter", json!({})), ("view.normal", json!({})), ("view.slideMaster", json!({})), ("view.closeMaster", json!({}))] {
let _ = h.state_mut().run(cmd, p);
@@ -51,21 +42,17 @@ fn a_very_tall_slide_in_the_editor_views_and_presenter_view() {
h.state_mut().run("show.start", json!({"from": 0})).unwrap();
h.run_steps(4);
assert!(h.state().show.is_some());
}
/// Presenter view of a portrait slide: the "Next" preview keeps the slide's shape inside its
/// column. It took the column's full width and 56 times that in height, a white slab over the
/// notes and past the window.
#[test]
fn presenter_view_keeps_a_portrait_next_slide_in_its_column() {
let _gpu = crate::gpu_lock::gpu_lock();
let mut h = harness(tall_deck(), egui::vec2(1280.0, 800.0));
h.run_steps(3);
h.state_mut().run("show.presenter", json!({"on": true})).unwrap();
h.state_mut().run("show.start", json!({"from": 0})).unwrap();
let doc = h.state().session.active().unwrap().doc.clone();
let now = h.ctx.input(|i| i.time);
let pixels_per_point = h.ctx.pixels_per_point();
let size = craft::behavior::kurbo::Size::new(doc.slide_size.width, doc.slide_size.height);
let inherited = craft::ui::runtime::env::Env::of_root(&h.ctx).view().get::<craft::behavior::ZoomScheme>();
let mut view = craft::behavior::CanvasView::new(h.ctx.content_rect(), size.to_rect().center(), 1.0);
craft::behavior::canvas::zoom::fit_up_to(&mut view, size, pixels_per_point, inherited.max_device(), 0.0, &inherited);
let scheme = inherited.with_hundred(view.zoom * f64::from(pixels_per_point));
let zoom = crate::show::ShowZoomInputs { size, pixels_per_point, scheme: &scheme };
let show = h.state_mut().show.as_mut().unwrap();
assert!(run_command(show, &doc, now, ShowCommands::Grid, ShowWindow::Audience, &zoom));
h.run_steps(4);
let img = h.render().unwrap();
// Right of the Next column's narrow preview, below where a landscape one would end.
let px = img.get_pixel(1000, 600).0;
assert!(px[0] < 128 && px[1] < 128 && px[2] < 128, "the Next preview spills over the column: {px:?}");
assert!(h.state().show.as_ref().is_some_and(|show| show.grid));
}