style: cargo fmt on the moved files

This commit is contained in:
aiongg
2026-10-26 21:54:30 +00:00
parent 3e38bd7349
commit b7b75ed37a
28 changed files with 78 additions and 144 deletions
+1 -5
View File
@@ -279,11 +279,7 @@ fn cryptomatte_cpu_path_is_bit_exact_inside_and_outside_the_aux_area() {
};
for (x, y) in [(0u32, 0u32), (1, 0), (5, 0), (0, 1), (3, 1), (5, 1)] {
let (c, m) = reduce_by_name(&a, "CryptoObject", &edge_selection(), (y * 6 + x) as usize);
assert_eq!(
out.get(x as i64, y as i64).map(f32::to_bits),
expect(c, m).map(f32::to_bits),
"display {display} matteOnly {matte_only} at ({x}, {y})"
);
assert_eq!(out.get(x as i64, y as i64).map(f32::to_bits), expect(c, m).map(f32::to_bits), "display {display} matteOnly {matte_only} at ({x}, {y})");
}
for (x, y) in [(6u32, 0u32), (19, 0), (0, 2), (12, 9)] {
assert_eq!(
+3 -7
View File
@@ -7,8 +7,7 @@ fn run(id: &str, img: &Image, over: &[(&str, Value)]) -> Image {
for (k, v) in over {
params.values.insert(k.to_string(), v.clone());
}
let ctx =
EffectCtx { params: &params, time: 0.0, layer_size: [img.width as f64, img.height as f64], seed: 1, adjustment: false, env: Default::default() };
let ctx = EffectCtx { params: &params, time: 0.0, layer_size: [img.width as f64, img.height as f64], seed: 1, adjustment: false, env: Default::default() };
(s.render)(&ctx, Buf { img: img.clone(), offset: [0.0, 0.0], scale: 1.0 }).img
}
@@ -331,11 +330,8 @@ fn auto_levels_temporal_smoothing_reads_neighbour_frames() {
fn shadow_highlight_clip_keeps_the_tonal_range() {
let img = ramp();
let lift = [("autoAmounts", Value::Bool(false)), ("shadowAmount", num(80.0))];
let unclipped = run(
"ec.color.shadowhighlight",
&img,
&[lift[0].clone(), lift[1].clone(), ("moreOptions/blackClip", num(0.0)), ("moreOptions/whiteClip", num(0.0))],
);
let unclipped =
run("ec.color.shadowhighlight", &img, &[lift[0].clone(), lift[1].clone(), ("moreOptions/blackClip", num(0.0)), ("moreOptions/whiteClip", num(0.0))]);
let clipped = run("ec.color.shadowhighlight", &img, &[lift[0].clone(), lift[1].clone(), ("moreOptions/blackClip", num(1.0))]);
let min = |im: &Image| im.data.iter().filter(|p| p[3] > 0.99).map(|p| luminance(p[0], p[1], p[2])).fold(f32::MAX, f32::min);
assert!(min(&clipped) < min(&unclipped));
+7 -18
View File
@@ -67,8 +67,7 @@ fn brightness_contrast_modern_keeps_black_and_white_and_legacy_is_linear() {
fn brightness_contrast_modern_matches_ae_ramp_samples() {
let u8 = |v: f32| (v * 255.0).round() as i32;
let go = |b: f64, c: f64, x: u8| {
u8(px("ec.color.brightnesscontrast", &[("brightness", num(b)), ("contrast", num(c))], [x as f32 / 255.0, x as f32 / 255.0, x as f32 / 255.0, 1.0])
[0])
u8(px("ec.color.brightnesscontrast", &[("brightness", num(b)), ("contrast", num(c))], [x as f32 / 255.0, x as f32 / 255.0, x as f32 / 255.0, 1.0])[0])
};
// (brightness, contrast, input, AE 8-bit)
let samples: &[(f64, f64, u8, u8)] = &[
@@ -96,11 +95,8 @@ fn brightness_contrast_modern_matches_ae_ramp_samples() {
/// (153, 51, 51), (204, 153, 128).
#[test]
fn tritone_matches_after_effects() {
let colours = [
("highlights", Value::Color([1.0, 1.0, 0.8, 1.0])),
("midtones", Value::Color([0.6, 0.2, 0.2, 1.0])),
("shadows", Value::Color([0.0, 0.0, 0.3, 1.0])),
];
let colours =
[("highlights", Value::Color([1.0, 1.0, 0.8, 1.0])), ("midtones", Value::Color([0.6, 0.2, 0.2, 1.0])), ("shadows", Value::Color([0.0, 0.0, 0.3, 1.0]))];
let near = |o: [f32; 4], ae: [f32; 3]| (0..3).all(|i| (o[i] * 255.0 - ae[i]).abs() <= 1.0);
let mut red = colours.to_vec();
red.push(("blend", num(25.0)));
@@ -245,11 +241,8 @@ fn exposure_individual_channels_and_bypass() {
let raw = px("ec.color.exposure", &[("master/exposure", num(1.0)), ("bypassLinearLight", Value::Bool(true))], [0.25, 0.25, 0.25, 1.0]);
assert!((raw[0] - 0.5).abs() < 1e-5);
// Negative results are mirrored, not clipped.
let neg = px(
"ec.color.exposure",
&[("master/offset", num(-0.5)), ("bypassLinearLight", Value::Bool(true)), ("master/gamma", num(2.0))],
[0.25, 0.25, 0.25, 1.0],
);
let neg =
px("ec.color.exposure", &[("master/offset", num(-0.5)), ("bypassLinearLight", Value::Bool(true)), ("master/gamma", num(2.0))], [0.25, 0.25, 0.25, 1.0]);
assert!((neg[0] + 0.5).abs() < 1e-4, "{neg:?}");
}
@@ -427,12 +420,8 @@ fn hue_saturation_ranges_adjust_their_hues_only() {
#[test]
fn fill_mask_all_masks_feather_and_invert() {
let sq = |x0: f64, x1: f64| crate::MaskShape {
name: String::new(),
points: vec![[x0, 0.0], [x1, 0.0], [x1, 10.0], [x0, 10.0]],
closed: true,
inverted: false,
};
let sq =
|x0: f64, x1: f64| crate::MaskShape { name: String::new(), points: vec![[x0, 0.0], [x1, 0.0], [x1, 10.0], [x0, 10.0]], closed: true, inverted: false };
let masks = [sq(0.0, 5.0), sq(15.0, 20.0)];
let env = EffectEnv { masks: &masks, ..Default::default() };
let grey = Image::filled(20, 10, [0.5, 0.5, 0.5, 1.0]);
+2 -3
View File
@@ -116,9 +116,8 @@ fn lightning_alpha_obstacle_and_expert_settings() {
}
}
}
let opts = |o: f64| {
vec![("alphaObstacle", num(o)), ("compositeOnOriginal", Value::Bool(false)), ("glowSettings/glowRadius", num(0.0)), ("forking", num(60.0))]
};
let opts =
|o: f64| vec![("alphaObstacle", num(o)), ("compositeOnOriginal", Value::Bool(false)), ("glowSettings/glowRadius", num(0.0)), ("forking", num(60.0))];
let free = run("ec.generate.advancedlightning", &opts(0.0), wall.clone());
let avoid = run("ec.generate.advancedlightning", &opts(10.0), wall.clone());
assert!(alpha_in(&avoid.img, &wall) < alpha_in(&free.img, &wall), "{} vs {}", alpha_in(&avoid.img, &wall), alpha_in(&free.img, &wall));
+4 -10
View File
@@ -158,16 +158,10 @@ fn vegas_traces_contours() {
img.set(x, y, [1.0, 1.0, 1.0, 1.0]);
}
}
let a = run(
"ec.generate.vegas",
&[("blendMode", Value::Enum(0)), ("length", num(1.0)), ("midpointOpacity", num(1.0)), ("endOpacity", num(1.0))],
img.clone(),
);
let b = run(
"ec.generate.vegas",
&[("blendMode", Value::Enum(0)), ("length", num(1.0)), ("midpointOpacity", num(1.0)), ("endOpacity", num(1.0))],
img.clone(),
);
let a =
run("ec.generate.vegas", &[("blendMode", Value::Enum(0)), ("length", num(1.0)), ("midpointOpacity", num(1.0)), ("endOpacity", num(1.0))], img.clone());
let b =
run("ec.generate.vegas", &[("blendMode", Value::Enum(0)), ("length", num(1.0)), ("midpointOpacity", num(1.0)), ("endOpacity", num(1.0))], img.clone());
assert_eq!(a.img.data, b.img.data);
assert!(alpha_sum(&a.img, 14, 14, 50, 50) > 50.0, "edges drawn");
assert!(alpha_sum(&a.img, 26, 26, 38, 38) < 0.5, "interior untouched");
+2 -7
View File
@@ -229,13 +229,8 @@ fn profile_converter_converts_and_round_trips() {
EffectEnv::default(),
);
assert_ne!(a.img.data, img.data);
let b = run_fx(
"ec.utility.colorprofileconverter",
&[("inputProfile", Value::Enum(3)), ("outputProfile", Value::Enum(1))],
a.img,
0.0,
EffectEnv::default(),
);
let b =
run_fx("ec.utility.colorprofileconverter", &[("inputProfile", Value::Enum(3)), ("outputProfile", Value::Enum(1))], a.img, 0.0, EffectEnv::default());
assert!((0..3).all(|k| (b.img.get(0, 0)[k] - img.get(0, 0)[k]).abs() < 1e-4));
// Same profile both sides: identity. Working space defaults to sRGB.
let c = run_fx(
+2 -4
View File
@@ -160,10 +160,8 @@ fn effects_use_a_custom_config() {
let o = fx("ec.color.ociocolorspace", &[("sourceName", Value::Str("g2".into())), ("destinationName", Value::Str("default".into()))]);
assert!((o[0] - 0.25).abs() < 1e-6 && (o[1] - 0.0625).abs() < 1e-6 && (o[2] - 1.0).abs() < 1e-6, "{o:?}");
// Inverse direction.
let o = fx(
"ec.color.ociocolorspace",
&[("sourceName", Value::Str("g2".into())), ("destinationName", Value::Str("lin".into())), ("direction", Value::Enum(1))],
);
let o =
fx("ec.color.ociocolorspace", &[("sourceName", Value::Str("g2".into())), ("destinationName", Value::Str("lin".into())), ("direction", Value::Enum(1))]);
assert!((o[0] - 0.5f32.sqrt()).abs() < 1e-6, "{o:?}");
// Display ▸ view → its colour space.
let o = fx(
+2 -3
View File
@@ -320,9 +320,8 @@ fn particle_world_effect_camera() {
assert!(finite(&with(std::slice::from_ref(&extra))), "{extra:?}");
}
// Moving the camera doesn't restart the simulation.
let key = |pr: &crate::Params| {
sim_key(&EffectCtx { params: pr, time: 1.0, layer_size: [48.0, 48.0], seed: 1, adjustment: false, env: EffectEnv::default() }, 1)
};
let key =
|pr: &crate::Params| sim_key(&EffectCtx { params: pr, time: 1.0, layer_size: [48.0, 48.0], seed: 1, adjustment: false, env: EffectEnv::default() }, 1);
let mut moved = params.clone();
moved.values.insert("extras/effectCamera/rotationZ".into(), num(30.0));
assert_eq!(key(&params), key(&moved));
+1 -1
View File
@@ -31,8 +31,8 @@ pub use foam::{FoamDisc, FoamEnv, FoamPlan, foam_full_plan};
use pieces::Cam;
#[cfg(test)]
pub(crate) use pieces::draw_pieces;
pub(crate) use pieces::{rot_axis, sort_far_first};
pub use pieces::{Piece, PiecePlan, PieceTex, piece_plan};
pub(crate) use pieces::{rot_axis, sort_far_first};
pub use pixels::{PixelPlan, pixel_plan};
pub use registry::specs;
#[cfg(test)]
+3 -6
View File
@@ -90,8 +90,7 @@ fn shatter_at_rest_then_breaks() {
assert_eq!(t1, run("ec.sim.shatter", &v, src.clone(), 0.5));
assert!(sum_diff(&t1, &src) > 10.0);
for pat in 0..SHATTER_PATTERNS.len() as u32 {
let vv =
[("view", Value::Enum(0)), ("shape/pattern", Value::Enum(pat)), ("force1/force1Position", pt(16.0, 16.0)), ("shape/origin", pt(16.0, 16.0))];
let vv = [("view", Value::Enum(0)), ("shape/pattern", Value::Enum(pat)), ("force1/force1Position", pt(16.0, 16.0)), ("shape/origin", pt(16.0, 16.0))];
let r = run("ec.sim.shatter", &vv, src.clone(), 0.0);
assert!(max_diff(&r, &src) < 0.05, "pattern {pat} tiles the layer: {}", max_diff(&r, &src));
}
@@ -186,8 +185,7 @@ fn wave_world_seek_and_waves() {
assert!(a.data.iter().any(|p| (p[0] - 0.5).abs() > 0.05), "waves");
let flat = run("ec.sim.waveworld", &[("view", Value::Enum(1)), ("producer1/producer1Amplitude", num(0.0))], Image::new(32, 32), 1.0);
assert!(flat.data.iter().all(|p| (p[0] - 0.5).abs() < 1e-5));
let wire =
run("ec.sim.waveworld", &[("producer1/producer1Position", pt(16.0, 16.0)), ("simulation/gridResolution", num(10.0))], Image::new(32, 32), 0.3);
let wire = run("ec.sim.waveworld", &[("producer1/producer1Position", pt(16.0, 16.0)), ("simulation/gridResolution", num(10.0))], Image::new(32, 32), 0.3);
assert!(wire.data.iter().any(|p| p[1] > 0.3));
}
@@ -460,8 +458,7 @@ fn foam_flow_map_pop_velocity_wobble_textures_and_reflection() {
let still = with(&[], 1.0);
let flowing = with(&[("flowMap/flowMap", Value::Layer(Some(1))), ("flowMap/flowMapSteepness", num(1.0))], 1.0);
assert!(cx(&flowing) < cx(&still) - 1.0, "{} vs {}", cx(&flowing), cx(&still));
let hq =
with(&[("flowMap/flowMap", Value::Layer(Some(1))), ("flowMap/flowMapSteepness", num(1.0)), ("flowMap/simulationQuality", Value::Enum(2))], 1.0);
let hq = with(&[("flowMap/flowMap", Value::Layer(Some(1))), ("flowMap/flowMapSteepness", num(1.0)), ("flowMap/simulationQuality", Value::Enum(2))], 1.0);
assert_eq!(
hq,
with(&[("flowMap/flowMap", Value::Layer(Some(1))), ("flowMap/flowMapSteepness", num(1.0)), ("flowMap/simulationQuality", Value::Enum(2))], 1.0)
+2 -4
View File
@@ -123,8 +123,7 @@ fn property_mapper_and_layer_map_read_layers() {
0.7,
);
assert_eq!(a.data, b.data);
let st =
Pg { persistent: Some(mapper(Image::filled(4, 4, [1.0, 0.0, 0.5, 1.0]), [(15, 0, 0.0, 120.0), (0, 0, 0.0, 1.0), (9, 0, 0.0, 2.0)])), ..bare(1) };
let st = Pg { persistent: Some(mapper(Image::filled(4, 4, [1.0, 0.0, 0.5, 1.0]), [(15, 0, 0.0, 120.0), (0, 0, 0.0, 1.0), (9, 0, 0.0, 2.0)])), ..bare(1) };
let mut s = PgState::default();
s.parts.push(PgParticle::new([1.0, 1.0], [0.0; 2], [1.0; 4], 2.0, 0, SRC_GRID));
st.step(&mut s);
@@ -189,8 +188,7 @@ fn barrel_radius_square_or_disc() {
#[test]
fn mapper_drives_position_and_opacity_in_ae_order() {
let st =
Pg { persistent: Some(mapper(Image::filled(4, 4, [1.0, 0.5, 0.25, 1.0]), [(12, 0, 0.0, 30.0), (20, 0, 0.0, 1.0), (4, 0, 0.0, 1.0)])), ..bare(1) };
let st = Pg { persistent: Some(mapper(Image::filled(4, 4, [1.0, 0.5, 0.25, 1.0]), [(12, 0, 0.0, 30.0), (20, 0, 0.0, 1.0), (4, 0, 0.0, 1.0)])), ..bare(1) };
assert_eq!(MAP_TARGETS[12], "X");
assert_eq!(MAP_TARGETS[20], "Opacity");
assert_eq!(MAP_TARGETS[26], "Scale Speed");
@@ -189,11 +189,8 @@ impl Offload for Inline {
#[test]
fn render_runs_through_the_offload() {
let mut s = Session {
exporter: Some(Arc::new(crate::rq_tests::MockExporter { log: Default::default() })),
offload: Some(Arc::new(Inline)),
..Default::default()
};
let mut s =
Session { exporter: Some(Arc::new(crate::rq_tests::MockExporter { log: Default::default() })), offload: Some(Arc::new(Inline)), ..Default::default() };
s.execute("file.openDemoProject", serde_json::json!({})).unwrap();
s.execute("renderQueue.add", serde_json::json!({"output": "/x.gif"})).unwrap();
let ids = s.start_render(false).unwrap();
+8 -8
View File
@@ -1,5 +1,3 @@
mod session;
mod three_d;
mod anim_presets;
mod anim_tools;
mod camera_track;
@@ -15,8 +13,10 @@ mod face;
mod fidelity;
mod frame_export;
mod fuzz_open;
mod history;
mod import_project;
mod key_metadata_order;
mod key_time;
mod keylight;
mod limits;
mod lottie;
@@ -26,13 +26,18 @@ mod markers;
mod mask_warp;
mod menu_cmds;
mod model3d;
mod models;
mod motion_blur_depth;
mod paint;
mod panels;
mod project_items;
mod proxy;
mod quick_offset;
mod replace_source;
mod rig3d;
pub(crate) mod roto;
mod sequence;
mod session;
mod settings;
mod shortcut_cmds;
pub(crate) mod stubs;
@@ -40,14 +45,9 @@ mod styles;
mod tail;
mod text;
mod text_edit;
mod three_d;
mod timeline;
mod timeline_interchange;
pub(crate) mod track;
mod vector_import;
mod viewer;
mod history;
mod models;
mod paint;
mod panels;
pub(crate) mod roto;
mod key_time;
+1 -1
View File
@@ -26,7 +26,6 @@ use effectcraft_time::{FrameRate, Tick};
use crate::Gpu;
mod three_d;
mod adjust;
mod adv3d;
mod deferred;
@@ -54,6 +53,7 @@ mod fx_warp;
#[cfg(all(test, not(target_arch = "wasm32")))]
mod init;
mod particles;
mod three_d;
mod wgsl_grammar;
/// One GPU test at a time in this process: the calling test thread holds a process-wide lock
+1 -1
View File
@@ -8,10 +8,10 @@ use effectcraft_render::three_d::adv;
use effectcraft_render::{Accelerator, Backend, LayerCache, NoFootage, RenderOpts, Renderer};
use effectcraft_time::Tick;
use crate::tests::{Pattern, diff, n, tolerance};
use crate::tests::adv3d::{off_share, run_of, scene, scene_project};
use crate::tests::deferred::{deferred_gpu, render_passes};
use crate::tests::particles::{Host, agree, params};
use crate::tests::{Pattern, diff, n, tolerance};
/// The device's readbacks have landed (the browser's event loop; natively a poll).
fn settle(g: &crate::Gpu) {
+1 -1
View File
@@ -7,8 +7,8 @@
use effectcraft_keyframe::Value;
use effectcraft_time::Tick;
use crate::tests::{c, n};
use crate::tests::fx_pixel2::{e, env_case, env_case_allow, env_case_at, off, on, pt};
use crate::tests::{c, n};
fn layer(id: u64) -> Value {
Value::Layer(Some(id))
+1 -1
View File
@@ -7,8 +7,8 @@ use effectcraft_project::{BitDepth, LayerSource, build};
use effectcraft_render::RenderOpts;
use effectcraft_time::Tick;
use crate::tests::{Scene, check, compare_at, n, opts, set};
use crate::tests::fx_sim::{case, composited, e, off, on};
use crate::tests::{Scene, check, compare_at, n, opts, set};
fn v2(x: f64, y: f64) -> Value {
Value::Vec2([x, y])
+8 -11
View File
@@ -236,7 +236,11 @@ fn render_queue_exports_demo_comp() {
let path = r["outputPath"].as_str().unwrap().to_string();
assert!(path.ends_with("_240x134.mp4"), "{path}");
// A second item: PNG sequence, rendered in the background.
s.execute("renderQueue.add", json!({"format": "png", "output": dir.join("seq_[###].png").to_string_lossy(), "resolution": 0.0625, "timeSpan": "custom", "start": 0.0, "end": 0.2})).unwrap();
s.execute(
"renderQueue.add",
json!({"format": "png", "output": dir.join("seq_[###].png").to_string_lossy(), "resolution": 0.0625, "timeSpan": "custom", "start": 0.0, "end": 0.2}),
)
.unwrap();
let r = s.execute("renderQueue.render", json!({"wait": false})).unwrap();
assert_eq!(r["items"].as_array().unwrap().len(), 2);
let t0 = std::time::Instant::now();
@@ -265,8 +269,7 @@ fn value(s: &effectcraft_engine::Session, l: u64, path: &str) -> effectcraft_eng
let cid = s.active_comp_id().unwrap();
let comp = s.project.comp(cid).unwrap();
let layer = comp.layer(effectcraft_engine::project::LayerId(l)).unwrap();
let ctx =
effectcraft_engine::render::EvalCtx { project: &s.project, comp_id: cid, comp, time: Default::default(), expr: s.expr.as_deref(), footage: None };
let ctx = effectcraft_engine::render::EvalCtx { project: &s.project, comp_id: cid, comp, time: Default::default(), expr: s.expr.as_deref(), footage: None };
ctx.value(layer, layer.props.prop(path).unwrap())
}
@@ -520,14 +523,8 @@ fn stereo_rig_expressions_follow_the_master_camera() {
let v3 = |s: &effectcraft_engine::Session, path: &str| {
let comp = s.project.comp(left).unwrap();
let layer = &comp.layers[0];
let ctx = effectcraft_engine::render::EvalCtx {
project: &s.project,
comp_id: left,
comp,
time: Default::default(),
expr: s.expr.as_deref(),
footage: None,
};
let ctx =
effectcraft_engine::render::EvalCtx { project: &s.project, comp_id: left, comp, time: Default::default(), expr: s.expr.as_deref(), footage: None };
ctx.value(layer, layer.props.prop(path).unwrap()).as_vec3()
};
let close = |a: [f64; 3], b: [f64; 3]| (0..3).all(|i| (a[i] - b[i]).abs() < 1e-6);
+1 -1
View File
@@ -1,8 +1,8 @@
//! M13.12: transparency groups (isolated, knockout, group alpha) and soft masks on a group's
//! combined result.
use crate::*;
use crate::tests::{page_pdf, render};
use crate::*;
fn near(a: [f32; 4], b: [f32; 4]) -> bool {
(0..4).all(|i| (a[i] - b[i]).abs() < 0.02)
+1 -1
View File
@@ -1,8 +1,8 @@
//! M13.12: CCITT images in PDF pages, EPS text and parser robustness over truncated and
//! corrupt inputs (generated fixtures).
use crate::*;
use crate::tests::{coverage, page_pdf, render, shape_names};
use crate::*;
fn eps(body: &[u8]) -> Doc {
let mut b = b"%!PS-Adobe-3.0 EPSF-3.0\n%%BoundingBox: 0 0 200 100\n".to_vec();
+1 -1
View File
@@ -1,7 +1,7 @@
//! M13.12: function-based and mesh shadings (generated fixtures).
use crate::*;
use crate::tests::{Objs, page_pdf, render};
use crate::*;
/// Mesh vertex data: 8-bit flags, 16-bit coordinates (Decode `[0 65535 0 65535 …]`, so raw
/// values are page units) and 8-bit components.
+4 -4
View File
@@ -6,11 +6,8 @@ use effectcraft_time::{FrameRate, Tick};
use crate::render_frame;
mod auto;
mod remap;
mod roi;
mod styles;
mod audio_fx;
mod auto;
mod aux_channels;
mod collapse;
mod color;
@@ -22,6 +19,9 @@ mod mask_expansion;
mod motion_tile;
mod nested;
mod paint;
mod remap;
mod roi;
mod styles;
mod time;
fn setup() -> (Project, ItemId, Comp) {
+3 -3
View File
@@ -12,14 +12,14 @@ use crate::{Outcome, run_code};
mod callable;
mod ease_presets;
mod evalfile;
mod include;
mod panels;
#[cfg(not(windows))]
mod services;
mod tasks;
mod ui;
mod ui_more;
mod evalfile;
#[cfg(not(windows))]
mod services;
mod ui_mouse;
fn session() -> Session {
+4 -12
View File
@@ -313,11 +313,8 @@ fn hanging_punctuation_overhangs_the_box() {
let p = ParagraphStyle { width: Some(400.0), hanging: true, ..Default::default() };
let l = layout_rich_uncached(text, &[(0..text.len(), s.clone())], &[p]);
assert!(l.lines[0].x < -1.0, "opening quote hangs left: {}", l.lines[0].x);
let r = layout_rich_uncached(
text,
&[(0..text.len(), s)],
&[ParagraphStyle { width: Some(400.0), hanging: true, align: Align::Right, ..Default::default() }],
);
let r =
layout_rich_uncached(text, &[(0..text.len(), s)], &[ParagraphStyle { width: Some(400.0), hanging: true, align: Align::Right, ..Default::default() }]);
assert!(r.lines[0].x + r.lines[0].width > 401.0, "closing quote hangs right");
}
@@ -348,13 +345,8 @@ fn rtl_paragraph_carets_run_right_to_left() {
fn named_instance_sets_the_base_variations() {
const FAMILY: &str = "EffectCraft Layout Instance Test";
fonts::add_font_data(crate::sfnt::test_font::variable(FAMILY, &[("Light", 300.0, None), ("Black", 900.0, None)], true));
let st = |style: &str, variations: Vec<(String, f32)>| TextStyle {
family: FAMILY.into(),
style: style.into(),
size: 50.0,
variations,
..Default::default()
};
let st =
|style: &str, variations: Vec<(String, f32)>| TextStyle { family: FAMILY.into(), style: style.into(), size: 50.0, variations, ..Default::default() };
let coords = |l: &Layout| l.glyphs.iter().map(|g| crate::variable::coords(g.variations).to_vec()).collect::<Vec<_>>();
let black = layout_uncached("Hi", &st("Black", vec![]), &ParagraphStyle::default());
assert!(!black.glyphs.is_empty());
+1 -2
View File
@@ -832,8 +832,7 @@ fn the_frames_an_edit_keeps_match_a_fresh_render() {
}
let cam = id(s.execute("layer.newCamera", json!({"comp": comp.0})).unwrap(), "layer");
s.execute("layer.timing", json!({"layers": [cam], "in": 2, "out": 3})).unwrap();
let moved =
kept(&mut s, comp, json!({"cmd": "prop.set", "params": {"comp": comp.0, "layer": cam, "path": "transform/position", "value": [40, 8, -30]}}));
let moved = kept(&mut s, comp, json!({"cmd": "prop.set", "params": {"comp": comp.0, "layer": cam, "path": "transform/position", "value": [40, 8, -30]}}));
assert!(moved.contains(&0) && moved.contains(&100), "frames far from the camera stay: {moved:?}");
assert!(!(56..=91).any(|f| moved.contains(&f)), "frames whose shutter samples the camera render again: {moved:?}");
}
+8 -16
View File
@@ -90,10 +90,7 @@ fn ime_delete_surrounding_chars_keeps_the_selection_for_the_commit() {
let (mut app, lid) = editor("abcdef", 1, 4);
feed(
&mut app,
vec![
egui::Event::Ime(egui::ImeEvent::DeleteSurrounding { before_chars: 1, after_chars: 99 }),
egui::Event::Ime(egui::ImeEvent::Commit("XY".into())),
],
vec![egui::Event::Ime(egui::ImeEvent::DeleteSurrounding { before_chars: 1, after_chars: 99 }), egui::Event::Ime(egui::ImeEvent::Commit("XY".into()))],
);
assert_eq!(doc_text(&app, lid), "XY", "the commit replaces the selection");
app.session.execute("edit.undo", json!({})).unwrap();
@@ -418,9 +415,8 @@ fn an_application_edit_in_the_same_frame_dominates_the_ime_cause() {
let (mut app, lid) = editor("ab", 2, 2);
let mut pass = ImePass::new(egui::ViewportId::ROOT);
pass.frame(&mut app, vec![], true, false).expect("editing");
let mixed = pass
.frame(&mut app, vec![egui::Event::Text("x".into()), egui::Event::Ime(egui::ImeEvent::Commit("日".into()))], true, false)
.expect("still editing");
let mixed =
pass.frame(&mut app, vec![egui::Event::Text("x".into()), egui::Event::Ime(egui::ImeEvent::Commit("日".into()))], true, false).expect("still editing");
assert_eq!(doc_text(&app, lid), "abx日");
assert_eq!(mixed.change_cause, egui::ImeChangeCause::Other, "the earlier application edit dominates");
@@ -428,9 +424,8 @@ fn an_application_edit_in_the_same_frame_dominates_the_ime_cause() {
let (mut app, lid) = editor("ab", 2, 2);
let mut pass = ImePass::new(egui::ViewportId::ROOT);
pass.frame(&mut app, vec![], true, false).expect("editing");
let mixed = pass
.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Commit("日".into())), egui::Event::Text("x".into())], true, false)
.expect("still editing");
let mixed =
pass.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Commit("日".into())), egui::Event::Text("x".into())], true, false).expect("still editing");
assert_eq!(doc_text(&app, lid), "ab日x");
assert_eq!(mixed.change_cause, egui::ImeChangeCause::Other, "the later application edit dominates");
}
@@ -520,8 +515,7 @@ fn a_failed_batch_with_a_transient_edit_does_not_revive_a_wide_selection_composi
let (mut app, lid) = editor(&text, 0, 5000);
let mut pass = ImePass::new(egui::ViewportId::ROOT);
pass.frame(&mut app, vec![], true, false).expect("editing");
pass.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Preedit { text: "に".into(), active_range_chars: None })], true, false)
.expect("still editing");
pass.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Preedit { text: "に".into(), active_range_chars: None })], true, false).expect("still editing");
let owner = ime_owner(&app).expect("an editor owner");
assert!(matches!(
pass.ctx.data(|d| d.get_temp::<ImeComposition>(ime_composition_id(pass.viewport))),
@@ -556,8 +550,7 @@ fn a_wide_content_change_invalidates_the_active_composition() {
let (mut app, lid) = editor(&text, 0, 5000);
let mut pass = ImePass::new(egui::ViewportId::ROOT);
pass.frame(&mut app, vec![], true, false).expect("editing");
pass.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Preedit { text: "に".into(), active_range_chars: None })], true, false)
.expect("still editing");
pass.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Preedit { text: "に".into(), active_range_chars: None })], true, false).expect("still editing");
let replaced = "b".repeat(5000);
app.session.execute("layer.setText", json!({"layer": lid.0, "text": replaced})).unwrap();
@@ -578,8 +571,7 @@ fn a_wide_selection_change_invalidates_the_active_composition() {
let (mut app, lid) = editor(&text, 0, 5000);
let mut pass = ImePass::new(egui::ViewportId::ROOT);
pass.frame(&mut app, vec![], true, false).expect("editing");
pass.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Preedit { text: "に".into(), active_range_chars: None })], true, false)
.expect("still editing");
pass.frame(&mut app, vec![egui::Event::Ime(egui::ImeEvent::Preedit { text: "に".into(), active_range_chars: None })], true, false).expect("still editing");
// Still wider than the IME window limit, so this exercises the unavailable-text
// selection identity rather than merely making the surrounding text available.
+2 -7
View File
@@ -36,13 +36,8 @@ impl Scrub {
fn frame(&mut self, events: Vec<Event>, focused: bool) {
self.time += 0.02;
let mut raw = RawInput {
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))),
time: Some(self.time),
events,
focused,
..Default::default()
};
let mut raw =
RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), time: Some(self.time), events, focused, ..Default::default() };
raw.events.push(Event::ModifiersChanged(self.modifiers));
prepare_input(&self.ctx, &mut raw, self.injected);
let mut out = self.ctx.run_ui(raw, |ui| {
+2 -1
View File
@@ -28,7 +28,8 @@ fn corrupt_future_or_unknown_workspace_keeps_defaults_and_original_file() {
}
let twice =
r#"{"Split":{"vertical":true,"size":{"Ratio":0.5},"a":{"Tabs":{"panels":["Project"],"active":0}},"b":{"Tabs":{"panels":["Project"],"active":0}}}}"#;
let bad_split = r#"{"Split":{"vertical":true,"size":{"Ratio":7.0},"a":{"Tabs":{"panels":["Project"],"active":0}},"b":{"Tabs":{"panels":["Timeline"],"active":0}}}}"#;
let bad_split =
r#"{"Split":{"vertical":true,"size":{"Ratio":7.0},"a":{"Tabs":{"panels":["Project"],"active":0}},"b":{"Tabs":{"panels":["Timeline"],"active":0}}}}"#;
for text in [
"{".into(),
"{}".into(),