M1: the Frame tool's Phone presets have the iPhone 17 family (#1691) (#1720)

iPhone 17, 17 Pro, 17 Pro Max and Air, at the sizes the prototype device list uses; a test keeps presets named like a device at its size.
This commit is contained in:
BFlat
2026-10-31 06:13:47 +07:00
committed by GitHub
parent 477b83560b
commit 1ea19482d3
4 changed files with 32 additions and 3 deletions
+2 -1
View File
File diff suppressed because one or more lines are too long
+4
View File
@@ -13,6 +13,10 @@ pub const PLACED_IMAGE_MAX_SIDE: f64 = 4096.0;
/// Frame presets shown by the Frame tool (category, name, width, height).
pub const FRAME_PRESETS: &[(&str, &str, f64, f64)] = &[
("Phone", "iPhone 17", 402.0, 874.0),
("Phone", "iPhone 17 Pro", 402.0, 874.0),
("Phone", "iPhone 17 Pro Max", 440.0, 956.0),
("Phone", "iPhone Air", 420.0, 912.0),
("Phone", "iPhone 16", 393.0, 852.0),
("Phone", "iPhone 16 Pro", 402.0, 874.0),
("Phone", "iPhone 16 Pro Max", 440.0, 956.0),
+24 -1
View File
@@ -1,4 +1,5 @@
//! Frame presets: placement beside existing frames and orientation swaps.
//! Frame presets: placement beside existing frames, orientation swaps and sizes shared with the
//! prototype devices.
use serde_json::json;
@@ -28,3 +29,25 @@ fn presets_land_beside_existing_frames_and_swap_orientation() {
s.undo().unwrap();
assert_eq!(s.doc().unwrap().node(a).unwrap().width, 393.0);
}
/// #1691: the iPhone 17 family is there, and a preset named like a prototype device has its size.
#[test]
fn presets_keep_the_sizes_of_the_prototype_devices() {
use crate::cmd::create::FRAME_PRESETS;
use figcraft_doc::proto::PrototypeSettings;
let mut s = Session::new();
for (name, size) in
[("iPhone 17", (402.0, 874.0)), ("iPhone 17 Pro", (402.0, 874.0)), ("iPhone 17 Pro Max", (440.0, 956.0)), ("iPhone Air", (420.0, 912.0))]
{
let id = id_of(&s.execute("frame.create", &json!({"preset": name})).unwrap()["id"]).unwrap();
let n = s.doc().unwrap().node(id).unwrap();
assert_eq!((n.name.as_str(), n.width, n.height), (name, size.0, size.1));
}
let shared = FRAME_PRESETS.iter().filter_map(|p| Some((p, PrototypeSettings::DEVICES.iter().find(|d| d.name == p.1)?)));
let mut n = 0;
for ((_, name, w, h), device) in shared {
assert_eq!((*w, *h), (device.width, device.height), "{name}");
n += 1;
}
assert!(n >= 8, "{n} presets are devices");
}
+2 -1
View File
File diff suppressed because one or more lines are too long