diff --git a/Cargo.lock b/Cargo.lock index 34c2e112..84a1a752 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5215,7 +5215,6 @@ dependencies = [ "gltf", "half", "image", - "lz4_flex", "png", "quick-xml 0.41.0", "rayon", diff --git a/Cargo.toml b/Cargo.toml index e4f86a12..de6fc98d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,6 @@ default-members = ["crates/core", "crates/texel", "crates/geom", "crates/compose version = "0.6.1" edition = "2024" license = "MIT OR Apache-2.0" -rust-version = "1.95" -repository = "https://github.com/storytold/texturecraft" [workspace.dependencies] craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "3dff4793f1a5bd1f99a4fe3280d48f515158dff3" } @@ -53,10 +51,8 @@ rfd = "0.17" zip = { version = "9", default-features = false, features = ["deflate"] } gltf = { version = "1.4", default-features = false, features = ["import", "utils", "names", "KHR_materials_emissive_strength"] } flate2 = "1" -lz4_flex = { version = "0.11", default-features = false, features = ["safe-decode", "safe-encode"] } quick-xml = "0.41" mikktspace = { version = "0.3", default-features = false, features = ["glam"] } -proptest = "1" rmcp = { version = "3.5", default-features = false, features = ["server", "macros", "transport-io"] } tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "sync", "net", "io-util", "time"] } schemars = "1" diff --git a/apps/texturecraft-cli/tests/cli.rs b/apps/texturecraft-cli/tests/cli.rs index 4cb6a5aa..ce209c3e 100644 --- a/apps/texturecraft-cli/tests/cli.rs +++ b/apps/texturecraft-cli/tests/cli.rs @@ -16,17 +16,6 @@ fn cli_binary_path(runner_path: Option) -> OsString { runner_path.unwrap_or_else(|| env!("CARGO_BIN_EXE_texturecraft-cli").into()) } -#[test] -fn cli_binary_prefers_relocated_runner_path() { - let relocated = OsString::from("relocated archive/texturecraft-cli"); - assert_eq!(cli_binary_path(Some(relocated.clone())), relocated); -} - -#[test] -fn cli_binary_defaults_to_cargo_path() { - assert_eq!(cli_binary_path(None), OsString::from(env!("CARGO_BIN_EXE_texturecraft-cli"))); -} - fn cli(args: &[&str]) -> Output { Command::new(cli_binary()).args(args).output().unwrap() } diff --git a/apps/texturecraft-web/Cargo.toml b/apps/texturecraft-web/Cargo.toml index e5512768..bb5c79a6 100644 --- a/apps/texturecraft-web/Cargo.toml +++ b/apps/texturecraft-web/Cargo.toml @@ -13,12 +13,11 @@ workspace = true name = "texturecraft-web" path = "src/main.rs" -[dependencies] +[target.'cfg(target_arch = "wasm32")'.dependencies] texturecraft-engine = { workspace = true } texturecraft-ui-egui = { workspace = true } log = { workspace = true } -[target.'cfg(target_arch = "wasm32")'.dependencies] # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "persistence"] } wasm-bindgen = "0.2" diff --git a/apps/texturecraft-web/src/main.rs b/apps/texturecraft-web/src/main.rs index cd4045c4..742cb5a8 100644 --- a/apps/texturecraft-web/src/main.rs +++ b/apps/texturecraft-web/src/main.rs @@ -1,6 +1,6 @@ //! TextureCraft in the browser. //! -//! Runs the same [`texturecraft_ui_egui::TextureCraftApp`] as the desktop app through eframe's web +//! Runs the same `TextureCraftApp` as the desktop app through eframe's web //! runner (wgpu: WebGPU where available, WebGL2 otherwise). Build with `trunk build --release` //! from this directory (`packaging/web/package.sh` zips the result). //! diff --git a/apps/texturecraft/src/control_server.rs b/apps/texturecraft/src/control_server.rs index b502fe55..cf0a6df4 100644 --- a/apps/texturecraft/src/control_server.rs +++ b/apps/texturecraft/src/control_server.rs @@ -134,7 +134,7 @@ fn serve(stream: TcpStream, token: &str, tx: &Sender, ctx: &egui #[cfg(test)] mod tests { - use std::io::BufRead; + use std::io::{BufRead, Read}; use super::*; @@ -196,33 +196,28 @@ mod tests { assert_eq!(call(&mut w, &mut r, r#"{"id":4,"method":"ping"}"#).unwrap()["id"], 4, "bad JSON keeps an authenticated connection"); } + fn assert_reply(reader: &mut BufReader, expected: Value) -> std::io::Result<()> { + let expected = format!("{expected}\n"); + let mut received = vec![0; expected.len()]; + reader.read_exact(&mut received)?; + assert_eq!(received, expected.as_bytes(), "unexpected control server reply"); + Ok(()) + } + #[test] - fn connections_are_limited_and_idle_ones_time_out() { + fn authenticated_connections_hold_server_slots() -> std::io::Result<()> { let addr = server(); - let idle: Vec<_> = (0..MAX_CONNECTIONS).map(|_| connect(addr)).collect(); - // Let the server take every idle connection before the one over the limit. - std::thread::sleep(Duration::from_millis(300)); - // Read without writing: the server closes at once, and unread input would reset the - // connection before its reply arrives. - let (_, mut r) = connect(addr); - let mut full = String::new(); - r.read_line(&mut full).unwrap(); - assert_eq!(serde_json::from_str::(&full).unwrap()["error"], "too many connections"); - // Unauthenticated connections are closed after AUTH_TIMEOUT, which frees their slots. - for (_, mut r) in idle { - let mut rest = String::new(); - assert_eq!(r.read_line(&mut rest).unwrap(), 0); - } - // A slot frees once its thread has ended, which can trail the client's EOF a little. let right = format!(r#"{{"id":1,"method":"auth","params":{{"token":"{TOKEN}"}}}}"#); - let authed = (0..50).any(|_| { - let (mut w, mut r) = connect(addr); - let ok = call(&mut w, &mut r, &right).is_some_and(|v| v["ok"] == true); - if !ok { - std::thread::sleep(Duration::from_millis(100)); - } - ok - }); - assert!(authed, "slots are freed after the auth deadline"); + let mut held = Vec::with_capacity(MAX_CONNECTIONS); + for _ in 0..MAX_CONNECTIONS { + let (mut writer, mut reader) = connect(addr); + writeln!(writer, "{right}")?; + // The reply confirms that this connection is holding a slot. + assert_reply(&mut reader, json!({"ok": true, "id": 1}))?; + held.push((writer, reader)); + } + + let (_writer, mut reader) = connect(addr); + assert_reply(&mut reader, json!({"id": null, "ok": false, "error": "too many connections"})) } } diff --git a/apps/texturecraft/src/main.rs b/apps/texturecraft/src/main.rs index 0ebfaa86..7787e1cf 100644 --- a/apps/texturecraft/src/main.rs +++ b/apps/texturecraft/src/main.rs @@ -330,19 +330,6 @@ mod tests { assert_eq!(args.gpu.as_deref(), Some("3080")); } - #[test] - fn only_a_run_without_a_control_port_checks_for_updates_at_start() { - assert!(checks_for_updates_at_start(None)); - assert!(!checks_for_updates_at_start(Some(9000))); - } - - #[test] - fn bundled_app_icon_decodes_to_rgba() { - let icon = icon().unwrap(); - assert!(icon.width > 0 && icon.height > 0); - assert_eq!(icon.rgba.len(), (icon.width * icon.height * 4) as usize); - } - #[test] fn rejects_missing_or_invalid_gpu_args() { assert!(parse_args_from(["--gpu".to_string()]).is_err()); diff --git a/crates/automation/src/render.rs b/crates/automation/src/render.rs index d626849e..c12ce621 100644 --- a/crates/automation/src/render.rs +++ b/crates/automation/src/render.rs @@ -228,14 +228,6 @@ mod tests { out } - #[test] - fn the_unlit_switch_decides_whether_a_channel_view_is_lit() { - let mut s = texturecraft_engine::sample_session(128, 64).unwrap(); - assert!(!shade(&s).solo_lit, "channel views are flat by default"); - execute(&mut s, "display.set", &json!({"soloUnlit": false})).unwrap(); - assert!(shade(&s).solo_lit); - } - #[test] fn renders_with_an_imported_hdr_environment() { let mesh = texturecraft_engine::geom::primitives::material_ball(); diff --git a/crates/automation/tests/perf.rs b/crates/automation/tests/perf.rs index 8b49f36f..ef73dc98 100644 --- a/crates/automation/tests/perf.rs +++ b/crates/automation/tests/perf.rs @@ -141,18 +141,6 @@ fn sample_for_project_bake(resolution: u32) -> Headless { backend } -#[test] -fn project_bake_uses_documented_ray_count() { - let backend = sample_for_project_bake(256); - - for texture_set in 0..backend.session.set_count() { - let task = backend.session.bake_task(texture_set).unwrap(); - assert_eq!(task.settings.maps.ao.parameters.rays.rays, 32); - assert_eq!(task.settings.maps.thickness.parameters.rays.rays, 32); - assert_eq!(task.settings.maps.bent_normal.parameters.rays.rays, 32); - } -} - /// The whole-project bake at benchmark settings (1024², 32 rays, AA 1), then 2048². #[test] #[ignore] diff --git a/crates/bake/src/tests.rs b/crates/bake/src/tests.rs index dab94f80..eaa64cf2 100644 --- a/crates/bake/src/tests.rs +++ b/crates/bake/src/tests.rs @@ -1056,24 +1056,6 @@ fn occlusion_falls_off_linearly_to_the_max_distance() { assert!((ambient_occlusion - 0.5).abs() < 0.01, "{ambient_occlusion}"); } -#[test] -fn secondary_ray_defaults_preserve_per_map_distances() { - let parameters = BakeSettings::default(); - let expected_rays = RaySettings { - rays: 64, - min_distance: 0.00001, - max_distance: 1.0, - relative_to_bounding_box: true, - spread: 180.0, - distribution: RayDistribution::Cosine, - }; - - assert_eq!(parameters.maps.ao.parameters.rays, expected_rays); - assert_eq!(parameters.maps.ao.parameters.attenuation, texturecraft_core::AmbientOcclusionAttenuation::Linear); - assert_eq!(parameters.maps.bent_normal.parameters.rays, expected_rays); - assert_eq!(parameters.maps.thickness.parameters.rays, RaySettings { max_distance: 0.1, ..expected_rays }); -} - #[test] fn bent_normals_and_thickness_have_their_own_rays() { let m = floor_and_wall(false); diff --git a/crates/compose/src/pattern.rs b/crates/compose/src/pattern.rs index 4e134daf..d75805dc 100644 --- a/crates/compose/src/pattern.rs +++ b/crates/compose/src/pattern.rs @@ -780,12 +780,6 @@ mod tests { assert!((at(0.25, &exact) - blended).abs() > 1e-3, "the exact pattern is not the blend, so the coarse read shows"); } - /// A stored cylinder axis past Z (only a hand-edited project holds one) wraps round Y - #[test] - fn a_cylinder_axis_past_z_reads_as_y() { - assert_eq!([0, 1, 2, 3, u8::MAX].map(cylinder_axis_index), [0, 1, 2, 1, 1]); - } - /// A decal saved before image placement reads its frame coordinates bit for bit as it did: its image at them, its procedural at them times the pattern scale #[test] fn an_unplaced_decal_reads_its_frame_coordinates_bit_for_bit() { diff --git a/crates/compose/src/solo.rs b/crates/compose/src/solo.rs index 11427c3a..64d6b9f7 100644 --- a/crates/compose/src/solo.rs +++ b/crates/compose/src/solo.rs @@ -173,9 +173,4 @@ mod tests { assert!(view.layers[&instance].visible && view.layers[&folder].visible && view.layers[&inner].visible); } - - #[test] - fn a_layer_in_no_stack_gives_nothing() { - assert!(solo_project(&project(), LayerId(99), true).is_none()); - } } diff --git a/crates/compose/src/tile_length.rs b/crates/compose/src/tile_length.rs index d84b08ee..04926df0 100644 --- a/crates/compose/src/tile_length.rs +++ b/crates/compose/src/tile_length.rs @@ -147,9 +147,4 @@ mod tests { assert!(length[0] > 0.0, "{length:?}"); assert!(tiling_for_length(&flat, SIZE, length).unwrap()[0] > 0.0, "a written-back tiling is never 0"); } - - #[test] - fn spherical_has_no_physical_size() { - assert_eq!(tile_length(&Projection::Spherical { scale: 1.0, uv: UvTransform::default(), offset: [0.0; 3], projector: Default::default() }, SIZE), None); - } } diff --git a/crates/core/src/project.rs b/crates/core/src/project.rs index c836f0ba..649f4f6d 100644 --- a/crates/core/src/project.rs +++ b/crates/core/src/project.rs @@ -829,17 +829,6 @@ mod tests { assert_eq!(p.next_layer_name(0, "Layer"), "Layer 2"); } - #[test] - fn serde_round_trip_is_stable() { - let mut p = project(); - let l = paint(&mut p, "x"); - p.insert_layer(0, l, None, false).unwrap(); - let json = serde_json::to_string(&p).unwrap(); - let back: Project = serde_json::from_str(&json).unwrap(); - assert_eq!(back, p); - assert_eq!(serde_json::to_string(&back).unwrap(), json); - } - #[test] fn per_map_bake_settings_round_trip() { use crate::{BackfaceMode, PositionMode, RayDistribution, RaySettings, SelfOcclusion}; diff --git a/crates/core/tests/bake_settings.rs b/crates/core/tests/bake_settings.rs index 800efd98..1616604f 100644 --- a/crates/core/tests/bake_settings.rs +++ b/crates/core/tests/bake_settings.rs @@ -118,7 +118,6 @@ fn components_keep_their_own_defaults() { })) .unwrap(); assert_eq!(settings, bake::BakeSettings::default()); - assert_eq!(settings.maps.thickness.parameters.rays.max_distance, 0.1); } #[test] diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index b8da2ca6..e34e9327 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -448,7 +448,7 @@ mod tests { fn no_bindable_command_asks_for_a_parameter() { // Effect commands need a selected effect, which this session lacks for spec in command_specs().iter().filter(|c| c.bindable() && c.shortcut.is_none() && !c.id.starts_with("effect.")) { - let mut session = crate::sample_session(256, 64).unwrap(); + let mut session = crate::sample_session(texturecraft_core::MIN_RESOLUTION, 16).unwrap(); if (spec.enabled)(&session).is_ok() && let Err(err) = execute(&mut session, spec.id, &Value::Null) { diff --git a/crates/engine/src/filter_about.rs b/crates/engine/src/filter_about.rs index c7d7375b..f0255e1b 100644 --- a/crates/engine/src/filter_about.rs +++ b/crates/engine/src/filter_about.rs @@ -69,17 +69,3 @@ const ABOUT: &[(&str, FilterAbout)] = &[ pub fn of(id: &str) -> Option { ABOUT.iter().find(|(entry, _)| *entry == id).map(|(_, about)| *about) } - -#[cfg(test)] -mod tests { - use super::of; - use crate::filter_lib::FILTERS; - - #[test] - fn every_library_filter_is_described_and_tagged() { - for def in FILTERS { - let about = of(def.id).unwrap_or_else(|| panic!("{} has no description", def.id)); - assert!(about.description.ends_with('.') && !about.tags.is_empty(), "{}", def.id); - } - } -} diff --git a/crates/engine/src/link_cmds.rs b/crates/engine/src/link_cmds.rs index f080daf8..a20182f6 100644 --- a/crates/engine/src/link_cmds.rs +++ b/crates/engine/src/link_cmds.rs @@ -359,7 +359,7 @@ pub fn source_extension(name: &str) -> &'static str { fn cook_source( bytes: Vec, size: u32, - baked: Option, + #[cfg(not(target_arch = "wasm32"))] baked: Option, mut budget: LinkMemoryBudget, canceled: Arc, reservation: CookReservation, @@ -384,7 +384,9 @@ fn cook_source( size, values: Map::new(), input_identifiers: Vec::new(), + #[cfg(not(target_arch = "wasm32"))] baked, + #[cfg(not(target_arch = "wasm32"))] budget, canceled, }; @@ -439,7 +441,15 @@ impl Session { let mut source = Vec::new(); source.try_reserve_exact(bytes.len()).map_err(|error| EngineError::Other(format!("cannot allocate linked source: {error}")))?; source.extend_from_slice(bytes); - let (job, material) = cook_source(source, size, self.doc.baked.get(&ts).cloned(), budget, Arc::default(), reservation)?; + let (job, material) = cook_source( + source, + size, + #[cfg(not(target_arch = "wasm32"))] + self.doc.baked.get(&ts).cloned(), + budget, + Arc::default(), + reservation, + )?; self.add_cooked_material(&material, job.package, job.source_ext, place) } @@ -542,6 +552,7 @@ impl Session { /// Prepare a re-cook with current parameter values and matching baked mesh maps pub fn link_job(&self, id: LayerId, overrides: &Map) -> Result { let link = link_of(self, "material.link", id)?; + #[cfg(not(target_arch = "wasm32"))] let (texture_set, _, _) = self.doc.project.locate(id).ok_or_else(|| EngineError::Other(format!("layer {} is not in a stack", id.0)))?; let mut values = self.link_values(id)?; values.extend(overrides.clone()); @@ -554,7 +565,9 @@ impl Session { size: self.link_size(id)?, values, input_identifiers: link.inputs.clone(), + #[cfg(not(target_arch = "wasm32"))] baked: self.doc.baked.get(&texture_set).cloned(), + #[cfg(not(target_arch = "wasm32"))] budget: self.link_memory_budget(), canceled: Arc::default(), }) diff --git a/crates/engine/src/link_cmds/link_job.rs b/crates/engine/src/link_cmds/link_job.rs index dba31f78..145be0e3 100644 --- a/crates/engine/src/link_cmds/link_job.rs +++ b/crates/engine/src/link_cmds/link_job.rs @@ -1,12 +1,12 @@ use std::sync::{Arc, atomic::AtomicBool}; -use super::{CookReservation, CookedMaterial, EngineError, LinkMemoryBudget, Result}; +use super::{CookReservation, CookedMaterial, EngineError, Result}; use serde_json::{Map, Value}; use texturecraft_core::LayerId; #[cfg(not(target_arch = "wasm32"))] use { - super::{CookedMap, MaterialInterface, cook_report::CookReport, materialcraft_tool, quiet}, + super::{CookedMap, LinkMemoryBudget, MaterialInterface, cook_report::CookReport, materialcraft_tool, quiet}, std::{io::Read, path::Path}, texturecraft_core::{BakedMap, Channel}, }; @@ -27,7 +27,9 @@ pub struct LinkJob { pub values: Map, /// Graph inputs matched to mesh maps and encoded one at a time in the worker. pub input_identifiers: Vec, + #[cfg(not(target_arch = "wasm32"))] pub(super) baked: Option, + #[cfg(not(target_arch = "wasm32"))] pub(super) budget: LinkMemoryBudget, pub canceled: Arc, } diff --git a/crates/engine/src/template_cmds.rs b/crates/engine/src/template_cmds.rs index 27de192d..db283d7e 100644 --- a/crates/engine/src/template_cmds.rs +++ b/crates/engine/src/template_cmds.rs @@ -533,11 +533,7 @@ mod tests { } #[test] - fn the_list_names_templates_like_the_reference() { - assert_eq!(template_label(DEFAULT_TEMPLATE, true), "Default (OpenPBR)"); - assert_eq!(template_label("Unlit - Emissive", true), "Unlit - Emissive (starter_assets)"); - assert_eq!(template_label("Mine", false), "Mine (your_assets)"); - + fn a_listed_template_resolves_by_its_display_label() { let mut s = Session::new_project("t", texturecraft_geom::primitives::material_ball(), "builtin:material_ball", None, 128).unwrap(); execute(&mut s, "project.template.save", &json!({"name": "Mine"})).unwrap(); let labels: Vec = diff --git a/crates/engine/tests/it/filter_card.rs b/crates/engine/tests/it/filter_card.rs index 4009ece3..4c2a29ce 100644 --- a/crates/engine/tests/it/filter_card.rs +++ b/crates/engine/tests/it/filter_card.rs @@ -145,11 +145,10 @@ fn restore_defaults_puts_the_filters_parameters_back() { fn filter_list_describes_and_tags_every_filter() { let mut s = session(); let listed = execute(&mut s, "filter.list", &Value::Null).unwrap(); - for def in listed.as_array().unwrap() { + let entries = listed.as_array().unwrap(); + assert_eq!(entries.len(), texturecraft_engine::filter_lib::FILTERS.len()); + for def in entries { assert!(def["description"].as_str().is_some_and(|text| !text.is_empty()), "{def}"); assert!(def["tags"].as_array().is_some_and(|tags| !tags.is_empty()), "{def}"); } - let blur = listed.as_array().unwrap().iter().find(|def| def["id"] == "blur").unwrap(); - - assert_eq!(blur["tags"], json!(["blur", "soften"])); } diff --git a/crates/engine/tests/it/filter_light.rs b/crates/engine/tests/it/filter_light.rs index 770d57e3..1e91c781 100644 --- a/crates/engine/tests/it/filter_light.rs +++ b/crates/engine/tests/it/filter_light.rs @@ -2,7 +2,7 @@ use serde_json::json; use texturecraft_engine::core::{Channel, DirectionalLight, EffectKind, Filter, LayerId, LightingOutput}; -use texturecraft_engine::filter_lib::{LIBRARY_DROP_SHADOW, LIBRARY_ENVIRONMENT_LIGHTING, LIBRARY_GLOW, library_baked_lighting}; +use texturecraft_engine::filter_lib::{LIBRARY_ENVIRONMENT_LIGHTING, LIBRARY_GLOW, library_baked_lighting}; use texturecraft_engine::geom::primitives; use texturecraft_engine::{Session, execute}; @@ -54,22 +54,16 @@ fn glow_settings_set_clamp_and_refuse() { assert_eq!(filter_of(&s, effect), LIBRARY_GLOW); } -/// Drop Shadow: the workflow's defaults, then Angle wrapping, Distance both ways, Size, Spread, Opacity and Color #[test] -fn drop_shadow_defaults_and_settings() { +fn drop_shadow_clamps_settings_and_rejects_invalid_color() { let mut s = session(); let effect = masked(&mut s, "Drop Shadow"); - assert_eq!(filter_of(&s, effect), LIBRARY_DROP_SHADOW, "the workflow's defaults"); set(&mut s, effect, json!({"angle": 450.0, "distance": -0.9, "size": 2.0, "spread": 0.3, "opacity": 0.25, "color": "#ffffff"})); assert_eq!(filter_of(&s, effect), Filter::DropShadow { angle: 90.0, distance: -0.5, size: 1.0, spread: 0.3, opacity: 0.25, color: [1.0; 3] }); refused(&mut s, effect, &[json!({"color": [1.0]})]); - - let listed = execute(&mut s, "filter.list", &json!({})).unwrap(); - - assert!(listed.as_array().unwrap().iter().any(|f| f["id"] == "dropShadow" && f["mask"] == true)); } /// A content fill layer with library filter `id` on its content: the effect diff --git a/crates/engine/tests/session.rs b/crates/engine/tests/session.rs index 52427422..dd4972cf 100644 --- a/crates/engine/tests/session.rs +++ b/crates/engine/tests/session.rs @@ -1,11 +1,15 @@ use serde_json::{Value, json}; -use texturecraft_engine::core::Channel; +use texturecraft_engine::core::{Channel, MIN_RESOLUTION}; use texturecraft_engine::geom::glam::Vec2; use texturecraft_engine::geom::primitives; use texturecraft_engine::{Session, command_specs, execute}; fn session() -> Session { - let mut s = Session::new_project("t", primitives::sphere(1.0, 48, 24), "builtin:sphere", None, 256).unwrap(); + session_at(256) +} + +fn session_at(texture_size: u32) -> Session { + let mut s = Session::new_project("t", primitives::sphere(1.0, 48, 24), "builtin:sphere", None, texture_size).unwrap(); s.viewport = texturecraft_engine::geom::glam::Vec2::new(400.0, 400.0); s.camera.yaw = 0.0; s.camera.pitch = 0.0; @@ -229,20 +233,8 @@ fn polygon_fill_boxes_survive_hostile_params() { } } -/// A small project still gets the production bake defaults; only panic_hunt overrides them. -#[test] -fn new_project_keeps_full_resolution_bake_defaults() { - let s = session(); - assert!(!s.doc.project.texture_sets.is_empty()); - for texture_set in &s.doc.project.texture_sets { - assert_eq!(texture_set.resolution, 256); - assert_eq!(texture_set.bake, texturecraft_engine::core::BakeSettings::default()); - assert_eq!(texture_set.bake.common.output_size(), (2048, 2048)); - assert_eq!(texture_set.bake.maps.ao.parameters.rays.rays, 64); - } -} - /// Every command must return Ok or Err — never panic — for hostile params. +/// Small texture and bake sizes retain the same command and parameter cases without a full-size bake per case. #[test] fn panic_hunt() { let hostile = [ @@ -259,11 +251,9 @@ fn panic_hunt() { } for p in &hostile { - let mut s = session(); - - // Match the fixture resolution to avoid a full 2048px bake for each unrelated input + let mut s = session_at(MIN_RESOLUTION); for texture_set in &mut s.doc.project.texture_sets { - texture_set.bake.common.resolution = texturecraft_engine::core::BakeResolution::R256; + texture_set.bake.common.resolution = texturecraft_engine::core::BakeResolution::R64; } let _ = execute(&mut s, spec.id, p); s.update(); @@ -433,7 +423,7 @@ fn hunt_filters(hostile: &[Value]) { let extremes: Vec = [3.0e38, -3.0e38, 0.0].into_iter().map(filter_extreme).collect(); for def in texturecraft_engine::filter_lib::FILTERS { - let mut s = session(); + let mut s = session_at(MIN_RESOLUTION); execute(&mut s, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1], "roughness": 0.4})).unwrap(); for target in ["content", "mask"] { if target == "mask" { @@ -471,7 +461,7 @@ fn hunt_filters(hostile: &[Value]) { /// An empty filter effect on the content and on a mask swapped through `effect.set` to every library filter with each of `hostile` and `extremes`, and rendered fn hunt_filter_swaps(hostile: &[Value], extremes: &[Value]) { - let mut s = session(); + let mut s = session_at(MIN_RESOLUTION); execute(&mut s, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1], "roughness": 0.4})).unwrap(); for target in ["content", "mask"] { if target == "mask" { @@ -495,24 +485,8 @@ fn hunt_filter_swaps(hostile: &[Value], extremes: &[Value]) { } } -/// A colour param is `[r, g, b]` in linear 0..1 or `"#rrggbb"` in sRGB, and the same digits differ -/// between the two, so every command that takes a colour says which form is which. #[test] -fn colour_params_name_their_colour_space() { - for spec in command_specs() { - if ["color?", "colors?", "Color?"].iter().any(|k| spec.params.contains(k)) { - assert!(spec.params.contains("linear"), "{}: {}", spec.id, spec.params); - let hex = spec.params.matches("\"#rrggbb\"").count(); - assert_eq!(hex, spec.params.matches("\"#rrggbb\" sRGB").count(), "{}: {}", spec.id, spec.params); - } - } - // These read their colours through `color_param`, which takes both forms. - for id in - ["layer.add.fill", "layer.fill.set", "effect.add.fill", "effect.add.filter", "tool.material", "mask.add.colorSelection", "resource.text", "display.set"] - { - let spec = command_specs().iter().find(|c| c.id == id).unwrap(); - assert!(spec.params.contains("[r,g,b] linear or \"#rrggbb\" sRGB"), "{id}: {}", spec.params); - } +fn an_srgb_hex_colour_matches_its_linear_rgb_value() { let base_color = |color: Value| { let mut s = session(); execute(&mut s, "layer.add.fill", &json!({ "color": color })).unwrap(); diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index 486db142..fbc4138a 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -27,9 +27,7 @@ png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "b130ac1fa44f923c3024884ab8ceb5ccdb88f15f" } -gltf = { workspace = true } flate2 = { workspace = true } -lz4_flex = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } zip = { workspace = true } @@ -42,3 +40,6 @@ base64 = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] sysinfo = { workspace = true } + +[dev-dependencies] +gltf = { workspace = true } diff --git a/crates/formats/src/mesh_import/stl.rs b/crates/formats/src/mesh_import/stl.rs index 95eeee6b..7e8e06e9 100644 --- a/crates/formats/src/mesh_import/stl.rs +++ b/crates/formats/src/mesh_import/stl.rs @@ -64,13 +64,3 @@ pub(crate) fn read(bytes: &[u8]) -> Result { fn stl_limits() -> craft_mesh::Limits { craft_mesh::Limits { max_vertices: MAX_VERTICES, ..craft_mesh::Limits::default() } } - -#[cfg(test)] -mod tests { - #[test] - fn shared_reader_accepts_the_app_vertex_limit() { - let limits = super::stl_limits(); - assert_eq!(limits.max_vertices, super::MAX_VERTICES); - assert_eq!(limits.max_triangles, texturecraft_geom::MAX_TRIANGLES); - } -} diff --git a/crates/formats/src/mesh_import/usd/tests.rs b/crates/formats/src/mesh_import/usd/tests.rs index f4a84c23..9eef4537 100644 --- a/crates/formats/src/mesh_import/usd/tests.rs +++ b/crates/formats/src/mesh_import/usd/tests.rs @@ -2,9 +2,7 @@ use std::io::Read as _; -use craft_usd::scene::{ - Budget, MAX_DECODED_BYTES, Prop, SceneError, UsdAttr, UsdLayer, UsdPrim, UsdValue, Val, read_layer, read_layer_with_budget, write_usda, write_usdc, -}; +use craft_usd::scene::{Budget, Prop, SceneError, UsdAttr, UsdLayer, UsdPrim, UsdValue, Val, read_layer, read_layer_with_budget, write_usda, write_usdc}; use texturecraft_geom::Mesh; use texturecraft_geom::glam::{Vec2, Vec3, Vec4}; @@ -406,55 +404,6 @@ fn usd_extension_detects_the_encoding() { assert!(import_mesh_bytes("a.usdz", &binary).is_err()); } -#[test] -fn integer_coding_round_trips() { - let values: Vec = vec![0, 1, 2, 3, 3, 3, -5, 1000, -70000, i64::from(i32::MAX), i64::from(i32::MIN), 7, 7, 7, 8]; - for (w_enum, width) in [(craft_usd::integers::Width::I32, 4), (craft_usd::integers::Width::I64, 8)] { - let enc = craft_usd::integers::encode(&values, w_enum, MAX_DECODED_BYTES).unwrap(); - assert!(enc.len() <= craft_usd::codec::encoded_ints_len(values.len(), width)); - assert_eq!(craft_usd::integers::decode(&enc, values.len(), w_enum, MAX_DECODED_BYTES).unwrap(), values); - assert!(craft_usd::integers::decode(&enc[..enc.len() - 1], values.len(), w_enum, MAX_DECODED_BYTES).is_err()); - } - let wide = vec![i64::MAX, i64::MIN, 0, 1 << 40]; - let enc_wide = craft_usd::integers::encode(&wide, craft_usd::integers::Width::I64, MAX_DECODED_BYTES).unwrap(); - assert_eq!(craft_usd::integers::decode(&enc_wide, 4, craft_usd::integers::Width::I64, MAX_DECODED_BYTES).unwrap(), wide); - let big: Vec = (0..5000u32).flat_map(|i| (i % 7).to_le_bytes()).collect(); - let comp = craft_usd::compress::compress(&big, MAX_DECODED_BYTES).unwrap(); - assert_eq!(craft_usd::decompress(&comp, big.len()).unwrap(), big); - assert!(craft_usd::decompress(&[0, 0xF0], 10).is_err()); -} - -#[test] -fn shared_crate_lz4_writer_preserves_bytes() { - for len in [0, 1, 15, 16, 255, 4096] { - let data: Vec = (0..len).map(|i| (i % 251) as u8).collect(); - let mut previous = vec![0]; - previous.extend(lz4_flex::block::compress(&data)); - assert_eq!(craft_usd::compress::compress(&data, MAX_DECODED_BYTES).unwrap(), previous); - } -} - -#[test] -fn shared_integer_decoder_rejects_oversized_output() { - assert!(craft_usd::integers::decode(&[], MAX_DECODED_BYTES / 8 + 1, craft_usd::integers::Width::I64, MAX_DECODED_BYTES).is_err()); - assert!(craft_usd::integers::decode(&[], 0, craft_usd::integers::Width::I32, MAX_DECODED_BYTES).unwrap().is_empty()); -} - -#[test] -fn shared_crate_lz4_retains_chunk_and_budget_policy() { - let mut frame = vec![2]; - for raw in [b"abc".as_slice(), b"def".as_slice()] { - let block = lz4_flex::block::compress(raw); - frame.extend((block.len() as i32).to_le_bytes()); - frame.extend(block); - } - frame.extend(b"old reader ignores this tail"); - assert_eq!(craft_usd::decompress(&frame, 6).unwrap(), b"abcdef"); - assert!(craft_usd::decompress(&frame, 5).is_err()); - assert!(craft_usd::decompress(&[1, 255, 255, 255, 255], 64).is_err()); - assert!(craft_usd::decompress(&[128], 64).is_err()); -} - #[test] fn malformed_usd_never_panics() { // A small two-material mesh keeps the byte loops fast. @@ -513,13 +462,6 @@ fn loose_layer_textures_are_packaged() { } } -#[test] -fn shared_integer_writer_preserves_tie_wire_and_rejects_oversized_budget() { - assert_eq!(craft_usd::integers::encode(&[1, 3, 4, 6], craft_usd::integers::Width::I32, MAX_DECODED_BYTES).unwrap(), vec![2, 0, 0, 0, 17, 1, 1]); - assert!(craft_usd::integers::encode(&[1], craft_usd::integers::Width::I32, 16).is_err()); - assert!(craft_usd::integers::encode(&[], craft_usd::integers::Width::I64, 0).unwrap().is_empty()); -} - /// Keep the final mesh contract of the binary fixture used before the shared USD cutover. #[test] fn crafted_usdc_references_time_samples_and_inlined_values_reach_mesh() { diff --git a/crates/render/Cargo.toml b/crates/render/Cargo.toml index ee15b556..c9f0692f 100644 --- a/crates/render/Cargo.toml +++ b/crates/render/Cargo.toml @@ -13,7 +13,6 @@ texturecraft-core = { workspace = true } texturecraft-texel = { workspace = true } texturecraft-geom = { workspace = true } texturecraft-compose = { workspace = true } -texturecraft-bake = { workspace = true } wgpu = { workspace = true } bytemuck = { workspace = true } half = { workspace = true } @@ -22,6 +21,7 @@ rayon = { workspace = true } serde = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] +texturecraft-bake = { workspace = true } pollster = "0.4" # The browser's WebGPU resolves error scopes later: their results are awaited on the page. diff --git a/crates/render/src/neutral_material.rs b/crates/render/src/neutral_material.rs index d3331185..57c372c5 100644 --- a/crates/render/src/neutral_material.rs +++ b/crates/render/src/neutral_material.rs @@ -51,25 +51,3 @@ impl NeutralMaterial { if self.bent_normal { [self.bent_normal_diffuse, self.bent_normal_specular, 0.0, 0.0] } else { [0.0; 4] } } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn every_frame_takes_the_whole_quality() { - let quality = |samples_per_pixel| NeutralMaterial { samples_per_pixel, ..NeutralMaterial::default() }; - assert_eq!(quality(16).samples_per_frame(), 16); - assert_eq!(quality(256).samples_per_frame(), 256); - assert_eq!(quality(u32::MAX).samples_per_frame(), MAX_SAMPLES_PER_PIXEL, "a damaged file is held to the highest quality"); - assert_eq!(quality(0).samples_per_frame(), 1); - } - - #[test] - fn the_bent_normal_reaches_the_shader_only_when_on() { - let off = NeutralMaterial::default(); - assert_eq!(off.bent_normal_globals(), [0.0; 4]); - let on = NeutralMaterial { bent_normal: true, bent_normal_diffuse: 0.5, bent_normal_specular: 0.25, ..off }; - assert_eq!(on.bent_normal_globals(), [0.5, 0.25, 0.0, 0.0]); - } -} diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index 05eb9ae9..ff8aa145 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -702,20 +702,6 @@ mod tests { assert_eq!(panels_of(&workspace), [Panel::Assets, Panel::Viewport, Panel::TextureSetList, Panel::Layers, Panel::TextureSetSettings, Panel::Properties]); } - #[test] - fn the_default_right_column_gives_properties_about_two_thirds_under_the_texture_sets() { - let workspace = default_workspace(); - let Some(Node::Split { second: right, .. }) = workspace.layout.root.as_ref() else { panic!("assets | rest") }; - let Node::Split { second: column, .. } = right.as_ref() else { panic!("viewport | right column") }; - let Node::Split { second: below_sets, .. } = column.as_ref() else { panic!("texture sets | rest") }; - let Node::Split { size: SplitSize::Ratio(layers), first, second, .. } = below_sets.as_ref() else { panic!("layers | properties") }; - assert!(matches!(first.as_ref(), Node::Tabs { panels, .. } if panels.first() == Some(&Panel::Layers))); - assert!(matches!(second.as_ref(), Node::Tabs { panels, .. } if panels == &[Panel::Properties])); - - let properties = 1.0 - layers; - assert!((2.0 / 3.0..0.7).contains(&properties), "Properties takes about 69% of the column, at least two thirds: {properties}"); - } - #[test] fn a_saved_split_keeps_its_own_share() { let mut workspace = default_workspace(); @@ -729,14 +715,6 @@ mod tests { assert_eq!(back.workspace(), &workspace, "a layout saved with the old split opens unchanged"); } - #[test] - fn default_dock_round_trips() { - let dock = Dock::default(); - let json = serde_json::to_string(&dock).unwrap(); - let back: Dock = serde_json::from_str(&json).unwrap(); - assert_eq!(back, dock); - } - #[test] fn the_bake_dock_round_trips_with_the_log_under_both_settings_columns() { let dock = Dock::for_baking(); diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index d1d19dc1..235ebc5e 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -421,19 +421,6 @@ mod tests", set_language("en"); } - #[test] - fn shared_lookup_overrides_and_missing_translations() { - static CATALOGS: &craft_i18n::Embedded = &[("es", "\tSave\tGuardar\n\tOpen\tAbrir\n", "\tSave\tGuardar proyecto\n")]; - let (runtime, problems) = craft_i18n::I18n::new(CATALOGS, &["es"]); - assert!(problems.is_empty()); - assert!(runtime.check_all().is_empty()); - let lang = runtime.from_code("es").unwrap(); - assert_eq!(runtime.t(lang, "Save"), "Guardar proyecto"); - assert_eq!(runtime.t(lang, "Open"), "Abrir"); - assert_eq!(runtime.t(lang, "New feature"), "New feature"); - assert_eq!(runtime.t(craft_i18n::Lang::EN, "Save"), "Save"); - } - #[test] fn saved_language_codes_and_spanish_lookup() { let _lock = LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); @@ -441,28 +428,19 @@ mod tests", set_language(language.code); assert_eq!(current().code, if available(language.code) { language.code } else { "en" }); } + const MISSING: &str = "missing test label"; set_language("es"); - assert_eq!(tr("Layers"), if available("es") { "Capas" } else { "Layers" }); + let spanish = tr("Layers"); + let missing = tr(MISSING); set_language("en"); - } - - #[test] - fn lookup_is_fast() { - let _lock = LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); - let keys = keys(); - set_language("ja"); - let started = std::time::Instant::now(); - let mut total_chars = 0usize; - for _ in 0..100 { - for key in &keys { - total_chars += tr(key).len(); - } - } - let ns_per_lookup = started.elapsed().as_secs_f64() * 1e9 / (100 * keys.len()) as f64; + let english = tr("Layers"); + set_language("es"); + let spanish_again = tr("Layers"); set_language("en"); - assert!(total_chars > 0); - // A frame looks up a few hundred strings, each expected below one microsecond - assert!(ns_per_lookup < 1000.0, "{ns_per_lookup:.0} ns per lookup"); + assert_eq!(spanish, if available("es") { "Capas" } else { "Layers" }); + assert_eq!(missing, MISSING); + assert_eq!(english, "Layers"); + assert_eq!(spanish_again, spanish); } } diff --git a/crates/ui-egui/src/render_mode/tests.rs b/crates/ui-egui/src/render_mode/tests.rs index b51c9760..114bef4c 100644 --- a/crates/ui-egui/src/render_mode/tests.rs +++ b/crates/ui-egui/src/render_mode/tests.rs @@ -359,9 +359,3 @@ fn loading_textures_are_taken_in_at_a_limited_rate() { assert!(take_in_textures(true, 1.0 + LOADING_RESTART_S, 1.0)); assert!(take_in_textures(true, 0.0, f64::MIN), "the first frame always"); } - -/// The placeholder appears only before the first image has been traced. -#[test] -fn nothing_traced_yet_shows_the_placeholder() { - assert!(!show_image(false, 0)); -} diff --git a/crates/ui-egui/src/resource_picker_item.rs b/crates/ui-egui/src/resource_picker_item.rs index 4c029ecd..4d02d20c 100644 --- a/crates/ui-egui/src/resource_picker_item.rs +++ b/crates/ui-egui/src/resource_picker_item.rs @@ -63,12 +63,6 @@ mod tests { assert!(!item("Rust").matches("dust")); } - #[test] - fn an_empty_search_keeps_every_item() { - assert!(item("Rust").matches("")); - assert!(item("").matches("")); - } - #[test] fn a_search_lowercases_a_label_beyond_ascii() { assert!(item("ÜBERZUG Grün").matches("überzug")); diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index da935fbe..809a20fd 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -142,15 +142,6 @@ mod tests { h.run_steps(2); } - #[test] - fn default_runtime_is_idle() { - let rt = Runtime::default(); - assert!(!rt.startup_check); - assert!(!rt.check_requested); - assert!(!rt.updater.prompt_open()); - assert_eq!(rt.updater.status(), &Status::Idle); - } - #[test] fn the_menu_item_runs_a_check_that_reports_its_outcome() { let _language = language(); diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 96d8b6a4..3c5a3d7e 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -2536,16 +2536,6 @@ mod tests { assert!((u - egui::vec2(0.0, -1.0)).length() < 1e-4 && (v - egui::vec2(-1.0, 0.0)).length() < 1e-4, "a counter-clockwise quarter turn: U up, V left"); } - #[test] - fn one_switch_turns_the_wireframe_on_in_both_views_and_polygon_fill_shows_it_without_changing_the_switch() { - let mut ui = crate::state::UiState::default(); - assert!(!wireframe_shown(&ui, false), "off by default"); - assert!(wireframe_shown(&ui, true), "polygon fill shows the polygons it fills"); - assert!(!ui.mesh_wireframe); - ui.mesh_wireframe = true; - assert!(wireframe_shown(&ui, false)); - } - #[test] fn the_hover_label_names_the_set_and_the_tile_under_the_cursor() { assert_eq!(hover_label_text("UdimMat", true, true, Some(1001)).as_deref(), Some("UdimMat - 1001")); diff --git a/crates/ui-egui/tests/it/alpha_parameters.rs b/crates/ui-egui/tests/it/alpha_parameters.rs index 3a261eed..09e48082 100644 --- a/crates/ui-egui/tests/it/alpha_parameters.rs +++ b/crates/ui-egui/tests/it/alpha_parameters.rs @@ -50,16 +50,6 @@ fn show_group(harness: &mut Harness<'_, TextureCraftApp>) { harness.run_steps(SETTLE_FRAMES); } -#[test] -fn the_group_shows_hardness_and_every_shared_parameter() { - let harness = app_with_brush(BrushSettings::default()); - - for label in ["Parameters", "Hardness", "Size X", "Size Y", "Roundness", "Contrast"] { - assert!(harness.query_by_label(label).is_some(), "{label} is in the Alpha tab"); - } - assert!(invert_checkbox(&harness).is_some()); -} - #[test] fn restore_defaults_puts_back_hardness_and_the_parameters_but_keeps_the_alpha() { let brush = BrushSettings { hardness: 0.9, alpha: BrushAlpha::Star, alpha_params: changed_params(), size: 0.1, flow: 0.4, ..BrushSettings::default() }; diff --git a/crates/ui-egui/tests/it/bake_mode.rs b/crates/ui-egui/tests/it/bake_mode.rs index 787f8645..b2603842 100644 --- a/crates/ui-egui/tests/it/bake_mode.rs +++ b/crates/ui-egui/tests/it/bake_mode.rs @@ -559,18 +559,6 @@ fn the_view_menu_picks_the_neutral_or_the_painted_material_in_bake_mode() { harness.get_by_value("Material"); } -#[test] -fn the_baking_visualization_panel_opens_like_the_reference_at_first_launch() { - let harness = harness(None); - for shown in ["Show for Selected Texture Set Only", "Mesh", "Matching Error", "Cage Surface", "Cage Wireframe Opacity"] { - harness.get_by_label(shown); - } - for closed in ["Missing Seams on Hard Edges", "Project Mesh", "Roughness"] { - assert!(harness.query_by_label(closed).is_none(), "{closed} sits in a section that starts closed"); - } - assert!(harness.state().ui.bake_visualization.missing_seams.shown, "missing seams are ticked in every reference capture"); -} - #[test] fn texture_set_names_show_in_full_beside_their_resolution() { let mut harness = harness(None); diff --git a/crates/ui-egui/tests/it/brush_section_reset.rs b/crates/ui-egui/tests/it/brush_section_reset.rs index c01726ad..8504adc1 100644 --- a/crates/ui-egui/tests/it/brush_section_reset.rs +++ b/crates/ui-egui/tests/it/brush_section_reset.rs @@ -177,16 +177,6 @@ fn enter_and_space_on_the_focused_reset_icon_reset_only_its_section() { } } -#[test] -fn reset_icons_identify_their_sections() { - let harness = app_with_brush(changed_brush()); - - for (title, _, _, _) in SECTIONS { - let label = format!("{title}: Reset to defaults"); - assert!(harness.query_by_role_and_label(egui::Role::Button, &label).is_some(), "the reset button must name its {title} section"); - } -} - #[test] fn narrow_headers_keep_title_clicks_separate_from_reset() { use texturecraft_ui_egui::widgets::section_with_reset; diff --git a/crates/ui-egui/tests/it/camera_views.rs b/crates/ui-egui/tests/it/camera_views.rs index 83e05d2c..b4ef8539 100644 --- a/crates/ui-egui/tests/it/camera_views.rs +++ b/crates/ui-egui/tests/it/camera_views.rs @@ -354,13 +354,3 @@ fn next_camera_advances_from_the_destination_before_the_glide_ends() { assert!((harness.state().session.camera.yaw.to_degrees() - 50.0).abs() < 0.5, "two presses reach the second camera"); } - -#[test] -fn the_view_picker_offers_the_combined_normal_view() { - let mut h = harness(); - h.get_all_by_role(egui::Role::ComboBox).find(|node| node.value().as_deref() == Some("Material")).expect("the view picker").click(); - h.run_steps(2); - h.get_by_label("Normal+height+mesh").click(); - h.run_steps(2); - assert_eq!(h.state().session.view, texturecraft_engine::ViewMode::NormalHeightMesh); -} diff --git a/crates/ui-egui/tests/it/display_environment.rs b/crates/ui-egui/tests/it/display_environment.rs index 5635d651..66cfff9f 100644 --- a/crates/ui-egui/tests/it/display_environment.rs +++ b/crates/ui-egui/tests/it/display_environment.rs @@ -45,13 +45,8 @@ fn values(h: &Harness<'_, TextureCraftApp>) -> Vec { } #[test] -fn the_sliders_run_over_the_reference_ranges_and_defaults() { +fn the_sliders_clamp_drags_to_their_supported_ranges() { let mut h = app(); - let shown = values(&h); - for expected in ["0", "0.00", "35", "0"] { - assert!(shown.iter().any(|value| value == expected), "{expected} is shown: {shown:?}"); - } - assert_eq!(display(&h).env_blur, 0.35, "the blur default is 35 of 100"); drag(&mut h, "Environment Opacity", 3000.0); assert_eq!(display(&h).env_opacity, 1.0, "opacity ends at 100"); @@ -140,15 +135,6 @@ fn the_environment_section_is_greyed_while_a_mesh_map_shows() { assert!(!h.get_by_role_and_label(Role::Button, "Studio Soft").accesskit_node().is_disabled()); } -#[test] -fn the_tabs_end_with_render_and_visualization_settings() { - let h = app(); - for label in ["Environment settings", "Camera settings", "Post effects", "Render settings", "Visualization settings"] { - assert!(h.query_all_by_label(label).next().is_some(), "the tab {label}"); - } - assert!(h.query_all_by_label("Viewer settings").next().is_none(), "the fourth tab is no longer Viewer settings"); -} - #[test] fn settings_general_has_a_working_background_color_with_two_eyedroppers() { let mut h = app(); diff --git a/crates/ui-egui/tests/it/display_post_effects.rs b/crates/ui-egui/tests/it/display_post_effects.rs index 96a355fa..df35a767 100644 --- a/crates/ui-egui/tests/it/display_post_effects.rs +++ b/crates/ui-egui/tests/it/display_post_effects.rs @@ -74,15 +74,6 @@ fn drag(harness: &mut Harness<'_, TextureCraftApp>, label: &str, x: f32) { harness.run_steps(SETTLE_FRAMES); } -#[test] -fn the_defaults_are_off() { - let harness = app(); - let d = display(&harness); - assert!(!d.post_effects); - assert_eq!(amounts(&d), [0.0; 4]); - assert!(reset_icon(&harness).accesskit_node().is_disabled(), "nothing to reset yet"); -} - #[test] fn each_slider_sets_only_its_own_amount() { for (i, label) in SLIDERS.into_iter().enumerate() { diff --git a/crates/ui-egui/tests/it/export_settings.rs b/crates/ui-egui/tests/it/export_settings.rs index 0e7e158a..98af3660 100644 --- a/crates/ui-egui/tests/it/export_settings.rs +++ b/crates/ui-egui/tests/it/export_settings.rs @@ -108,9 +108,8 @@ fn the_lists_hold_the_reference_entries() { } #[test] -fn the_default_template_has_the_reference_name_and_old_settings_follow_it() { +fn a_saved_legacy_preset_name_resolves_to_its_current_name() { let mut h = harness(); - assert_eq!(h.state().ui.export.preset, "Document channels + Normal + AO (No Alpha)"); h.state_mut().ui.export.preset = "Document channels + Normal + AO".into(); h.run_steps(3); assert_eq!(h.state().ui.export.preset, "Document channels + Normal + AO (No Alpha)"); @@ -159,21 +158,6 @@ fn the_output_directory_resets_and_the_dilation_follows_the_padding() { assert!(h.query_by_label("Dilation (pixels)").is_some(), "the menu stays open"); } -#[test] -fn export_actions_explain_what_they_change() { - let mut h = harness(); - for (button, tip) in [ - ("Include all", "Select every texture set, UV tile and output map"), - ("Reset all", "Restore the export defaults and select every texture"), - ("Cancel", "Restore the settings from when you opened this window"), - ("Save settings", "Keep these settings for the next export"), - ("Export", "Write the selected textures using the settings above"), - ] { - hover(&mut h, button); - assert!(h.query_by_label(tip).is_some(), "{button}: {tip}"); - } -} - #[test] fn the_page_reset_puts_the_parameters_back() { let mut h = harness(); diff --git a/crates/ui-egui/tests/it/filter_light.rs b/crates/ui-egui/tests/it/filter_light.rs index 40e8190c..700b118e 100644 --- a/crates/ui-egui/tests/it/filter_light.rs +++ b/crates/ui-egui/tests/it/filter_light.rs @@ -61,19 +61,6 @@ fn drop_shadow_angle_drag_is_one_undo_step() { assert!(matches!(filter_of(&harness, effect), Filter::DropShadow { angle, .. } if angle == 90.0), "{:?}", filter_of(&harness, effect)); } -/// The Sun card's angles read Sun Horizontal Angle and Sun Vertical Angle; Light 1 and 2 keep Horizontal Angle and Vertical Angle -#[test] -fn baked_lighting_stylized_sun_angles_take_the_sun_names() { - let (harness, _) = app_with("bakedLighting", "content", TALL_WINDOW_HEIGHT); - - for label in ["Sun Horizontal Angle", "Sun Vertical Angle"] { - assert_eq!(harness.query_all_by_role_and_label(Role::Slider, label).count(), 1, "{label}"); - } - for label in ["Horizontal Angle", "Vertical Angle"] { - assert_eq!(harness.query_all_by_role_and_label(Role::Slider, label).count(), 2, "{label}: Light 1 and 2"); - } -} - /// Baked Lighting Stylized's cards edit their own settings: Sun Intensity's right end, Light 1's Intensity and Output's Specular only #[test] fn baked_lighting_stylized_cards_set_the_sun_a_light_and_the_output() { diff --git a/crates/ui-egui/tests/it/filter_simple.rs b/crates/ui-egui/tests/it/filter_simple.rs index 9157f62d..a5c68c1f 100644 --- a/crates/ui-egui/tests/it/filter_simple.rs +++ b/crates/ui-egui/tests/it/filter_simple.rs @@ -67,17 +67,6 @@ fn posterize_switch_under_its_slider() { assert_eq!(filter_of(&harness, effect), Filter::Posterize { levels: 8.0, alpha: true }); } -/// Clamp's Min and Max, Smoothstep's Minimum and Maximum and Sharpen Intensity -#[test] -fn reference_names_on_the_sliders() { - for (filter, labels) in [("clamp", &["Min", "Max"][..]), ("smoothstep", &["Minimum", "Maximum"]), ("sharpen", &["Sharpen Intensity"])] { - let (harness, _) = app_with(filter, "mask", WINDOW_HEIGHT); - for label in labels { - assert!(harness.query_by_role_and_label(Role::Slider, label).is_some(), "{filter}: {label}"); - } - } -} - /// Histogram Shift's Position: a click on its middle shifts by a half turn back #[test] fn histogram_shift_position_middle_is_a_half_turn_back() { @@ -178,14 +167,6 @@ fn fxaa_rows() { assert_eq!(filter_of(&harness, effect), Filter::Fxaa { alpha: true }); } -/// Blur's Blur Intensity takes the reference's name and starts at 0.30 -#[test] -fn blur_intensity_takes_the_reference_name() { - let (harness, _) = app_with("blur", "mask", WINDOW_HEIGHT); - let intensity = harness.get_by_role_and_label(Role::Slider, "Blur Intensity"); - assert_eq!(intensity.accesskit_node().numeric_value().map(|value| (value * 100.0).round()), Some(30.0)); -} - /// Blur Directional's Intensity and Angle take the reference's names, and Intensity's right end is the widest blur #[test] fn blur_directional_rows_take_the_reference_names() { diff --git a/crates/ui-egui/tests/it/help_menu_664.rs b/crates/ui-egui/tests/it/help_menu_664.rs index 96f5ea43..db39c6a8 100644 --- a/crates/ui-egui/tests/it/help_menu_664.rs +++ b/crates/ui-egui/tests/it/help_menu_664.rs @@ -1,5 +1,4 @@ -//! Help ▸ Release notes... opens the releases page; Help ▸ Export log... saves the log to a text file; -//! Help ▸ Join the community (Discord)... opens the community Discord. +//! Help > Export log... saves the log with each entry's time and level. use egui_kittest::Harness; use egui_kittest::kittest::Queryable; @@ -25,55 +24,6 @@ fn click_help_item(h: &mut Harness<'_, TextureCraftApp>, label: &str) { h.run_steps(4); } -#[test] -fn release_notes_opens_the_releases_page() { - for id in ["ui.help.releaseNotes", "ui.help.exportLog"] { - assert!(texturecraft_ui_egui::keymap::bindings().iter().any(|binding| binding.id == id)); - } - - let mut h = harness(); - h.get_by_label("Help").click(); - h.run_steps(3); - h.get_by_label("Release notes...").click(); - - // The open-url command is in the output of the frame that handled the click only - h.step(); - let opened = h - .output() - .platform_output - .commands - .iter() - .any(|c| matches!(c, egui::OutputCommand::OpenUrl(u) if u.url == "https://github.com/storytold/texturecraft/releases")); - assert!(opened, "the releases page was opened"); -} - -const DISCORD: &str = "https://discord.gg/artcraft"; - -fn opened(h: &Harness<'_, TextureCraftApp>, url: &str) -> bool { - h.output().platform_output.commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(u) if u.url == url)) -} - -#[test] -fn join_the_community_opens_the_discord() { - let mut h = harness(); - h.get_by_label("Help").click(); - h.run_steps(3); - h.get_by_label("Join the community (Discord)...").click(); - h.step(); - assert!(opened(&h, DISCORD), "the community Discord was opened"); -} - -#[test] -fn join_the_community_is_bindable_and_a_bound_key_opens_the_discord() { - assert!(texturecraft_ui_egui::keymap::bindings().iter().any(|b| b.id == "ui.help.discord"), "ui.help.discord can be bound"); - let mut h = harness(); - h.state_mut().ui.keymap.insert("ui.help.discord".into(), "F12".into()); - h.run_steps(2); - h.event(egui::Event::Key { key: egui::Key::F12, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }); - h.step(); - assert!(opened(&h, DISCORD), "the bound key opened the community Discord"); -} - #[test] fn export_log_writes_every_line_with_time_and_level() { let mut h = harness(); @@ -97,11 +47,3 @@ fn export_log_writes_every_line_with_time_and_level() { assert_eq!(lines.len(), logged.len() + 1); let _ = std::fs::remove_dir_all(&dir); } - -#[test] -fn a_canceled_export_log_dialog_writes_nothing() { - let mut h = harness(); - h.state_mut().file_dialogs.set_override(Some(Box::new(|_| Answer::Cancelled))); - click_help_item(&mut h, "Export log..."); - assert!(h.state().toasts.is_empty()); -} diff --git a/crates/ui-egui/tests/it/levels_editor.rs b/crates/ui-egui/tests/it/levels_editor.rs index d962f022..0a1656a3 100644 --- a/crates/ui-egui/tests/it/levels_editor.rs +++ b/crates/ui-egui/tests/it/levels_editor.rs @@ -283,17 +283,6 @@ fn a_typed_value_keeps_input_low_below_input_high() { assert!((levels(&harness, effect).in_low - 0.49).abs() < 1e-4, "{:?}", levels(&harness, effect)); } -#[test] -fn the_levels_filter_shows_the_same_editor() { - let (harness, _) = levels_harness("effect.add.filter", json!({"target": "mask", "filter": "levels"})); - for label in ["Input low", "Gamma", "Input high", "Output low", "Output high"] { - harness.get_by_role_and_label(Role::Slider, label); - } - for button in ["Reset", "Auto", "Invert"] { - harness.get_by_role_and_label(Role::Button, button); - } -} - /// Bounds of the handle pointers in paint order, the last one drawn on top fn painted_handles(harness: &Harness<'_, TextureCraftApp>) -> Vec { let centres = HANDLE_LABELS.map(|label| handle(harness, label)); diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index 9196bd46..ef91cc44 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -80,7 +80,6 @@ mod shelf_hover_preview; mod shelf_panel; mod shift_lines_2d; mod shift_lines_3d; -mod shortcut_gestures; mod shortcut_keys; mod shortcut_list; mod side_panels; diff --git a/crates/ui-egui/tests/it/mask_export.rs b/crates/ui-egui/tests/it/mask_export.rs index 808c4055..c58fd4ff 100644 --- a/crates/ui-egui/tests/it/mask_export.rs +++ b/crates/ui-egui/tests/it/mask_export.rs @@ -68,16 +68,6 @@ fn export_mask_to_file_writes_the_mask_where_the_dialog_answered() { let _ = std::fs::remove_dir_all(file.parent().unwrap()); } -#[test] -fn a_canceled_dialog_writes_nothing() { - let mut h = harness(true); - h.state_mut().file_dialogs.set_override(Some(Box::new(|_| Answer::Cancelled))); - open_menu(&mut h); - h.get_by_label("Export mask to file...").click(); - h.run_steps(4); - assert!(h.state().toasts.is_empty()); -} - #[test] fn copy_mask_to_clipboard_puts_the_gray_image_on_the_clipboard() { let mut h = harness(true); diff --git a/crates/ui-egui/tests/it/named_layouts.rs b/crates/ui-egui/tests/it/named_layouts.rs index 18264949..8aa12225 100644 --- a/crates/ui-egui/tests/it/named_layouts.rs +++ b/crates/ui-egui/tests/it/named_layouts.rs @@ -110,23 +110,14 @@ fn invoke(harness: &mut Harness<'_, TextureCraftApp>, params: serde_json::Value) } #[test] -fn the_layout_items_are_in_the_menu_catalog_and_open_their_dialogs() { - use texturecraft_ui_egui::menus::CATALOG; - use texturecraft_ui_egui::named_layouts::LayoutDialog; - - for id in ["ui.layout.saveAs", "ui.layout.manage"] { - assert!(CATALOG.iter().any(|item| item.id == id && item.menu == "Window" && item.sub == Some("Layouts")), "{id}"); - } +fn managing_layouts_requires_a_saved_layout() { let mut harness = app(); - assert!(!texturecraft_ui_egui::menus::enabled(harness.state(), "ui.layout.manage"), "nothing to manage yet"); - - assert_eq!(invoke(&mut harness, serde_json::json!({"id": "ui.layout.saveAs"}))["ok"], true); - assert!(matches!(harness.state().ui.layout_dialog, Some(LayoutDialog::Save(_)))); + let command = "ui.layout.manage"; + assert!(!texturecraft_ui_egui::menus::enabled(harness.state(), command)); harness.state_mut().ui.save_named_layout("A"); - harness.state_mut().ui.layout_dialog = None; - assert_eq!(invoke(&mut harness, serde_json::json!({"id": "ui.layout.manage"}))["ok"], true); - assert!(matches!(harness.state().ui.layout_dialog, Some(LayoutDialog::Manage { .. }))); + + assert!(texturecraft_ui_egui::menus::enabled(harness.state(), command)); } #[test] diff --git a/crates/ui-egui/tests/it/nav_buttons.rs b/crates/ui-egui/tests/it/nav_buttons.rs index 9138d0e9..b21569e0 100644 --- a/crates/ui-egui/tests/it/nav_buttons.rs +++ b/crates/ui-egui/tests/it/nav_buttons.rs @@ -184,13 +184,6 @@ fn a_press_in_the_gap_between_buttons_or_in_the_margin_paints_nothing() { } } -#[test] -fn the_2d_view_has_no_orbit_button() { - let view = Rect::from_min_size(Pos2::ZERO, vec2(600.0, 500.0)); - assert!(button_rect(view, NavView::Uv, NavButton::Orbit).is_none()); - assert!(button_rect(view, NavView::Scene, NavButton::Orbit).is_some()); -} - #[test] fn buttons_stay_clear_of_the_pickers_the_gizmo_and_the_split_divider_at_1280_by_800() { let (harness, _) = app(ViewLayout::Split); diff --git a/crates/ui-egui/tests/it/new_project_window.rs b/crates/ui-egui/tests/it/new_project_window.rs index 7d95b501..1f97f815 100644 --- a/crates/ui-egui/tests/it/new_project_window.rs +++ b/crates/ui-egui/tests/it/new_project_window.rs @@ -1,9 +1,6 @@ -//! File > New project: the sections and their order, the defaults, settings shown disabled with a -//! hint until TextureCraft has them, Create waiting for a mesh file, and the settings that reach -//! the `file.new` command. +//! New project creation, including mesh selection, disabled controls and settings passed to file.new. use egui::Role; -use egui::accesskit::Toggled; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; use texturecraft_engine::template_cmds::DEFAULT_TEMPLATE; @@ -89,81 +86,15 @@ fn create_keeps_the_mesh_buffer_for_retry_and_drops_it_after_success() { assert_eq!(h.state().session.doc.project.name, "retry"); } -fn top(h: &Harness<'_, TextureCraftApp>, label: &str) -> f32 { - h.get_all_by_label(label).map(|node| node.rect().top()).fold(f32::INFINITY, f32::min) -} - fn disabled(h: &Harness<'_, TextureCraftApp>, role: Role, label: &str) -> bool { h.get_by_role_and_label(role, label).accesskit_node().is_disabled() } -fn ticked(h: &Harness<'_, TextureCraftApp>, role: Role, label: &str) -> bool { - h.get_by_role_and_label(role, label).accesskit_node().toggled() == Some(Toggled::True) -} - #[test] -fn the_sections_follow_the_project_setup_order() { - let h = harness(); - let order = [ - "BASIC SETTINGS", - "3D mesh", - "Project template", - "Document resolution (px)", - "ADVANCED SETTINGS", - "Normal map format", - "Compute tangent space per fragment", - "UV Tile settings (UDIMs)", - "You can enable or disable UV tiles later in Texture Set Settings.", - "Use UV Tile workflow", - "Keep UV tiles together per material", - "Use a separate texture set for each tile", - "Import settings", - "Import cameras", - "Auto-unwrap", - "Import baked maps", - "Import mesh normal maps and baked maps for all materials.", - "Normal map filename: _normal", - "Physical size", - "Use the mesh file’s unit scale", - "Custom unit scale", - "Scale material fills in real-world units", - "Color management", - "Working color space", - ]; - let tops: Vec = order.iter().map(|label| top(&h, label)).collect(); - for (pair, labels) in tops.windows(2).zip(order.windows(2)) { - assert!(pair[0] < pair[1], "{} comes before {}: {pair:?}", labels[0], labels[1]); - } - assert!(h.query_by_label("Linear - sRGB Chrominance (ITU-R BT.709)").is_some()); -} - -#[test] -fn the_defaults_match_the_reference() { +fn the_uv_layout_control_is_disabled_when_uv_tiles_are_off() { let h = harness(); - assert!(h.query_by_label("No file selected").is_some()); - assert!(h.query_by_value("Default (OpenPBR)").is_some(), "the default template"); - assert!(h.query_by_value("1024 x 1024").is_some()); - assert!(h.query_by_value("OpenGL").is_some()); - assert!(h.query_by_value("Legacy").is_some()); - assert!(!ticked(&h, Role::CheckBox, "Compute tangent space per fragment")); - assert!(!ticked(&h, Role::CheckBox, "Use UV Tile workflow")); - assert!(ticked(&h, Role::RadioButton, "Keep UV tiles together per material")); - assert!(disabled(&h, Role::RadioButton, "Keep UV tiles together per material"), "greyed while UV tiles are off"); - assert!(ticked(&h, Role::CheckBox, "Import cameras") && !disabled(&h, Role::CheckBox, "Import cameras")); - assert!(ticked(&h, Role::CheckBox, "Auto-unwrap")); - assert!(ticked(&h, Role::RadioButton, "Use the mesh file’s unit scale")); - assert!(!ticked(&h, Role::CheckBox, "Scale material fills in real-world units")); -} - -#[test] -fn template_controls_name_and_built_in_meshes_are_gone() { - let h = harness(); - - for label in ["Template name", "Save current project as template", "Name", "UV tiles (UDIM)"] { - assert!(h.query_by_label(label).is_none(), "{label} is not in the window"); - } - assert!(h.query_by_label_contains("Built-in:").is_none(), "no built-in mesh dropdown"); + assert!(disabled(&h, Role::RadioButton, "Keep UV tiles together per material")); } #[test] diff --git a/crates/ui-egui/tests/it/project_config.rs b/crates/ui-egui/tests/it/project_config.rs index 6bfb2a84..91dec76d 100644 --- a/crates/ui-egui/tests/it/project_config.rs +++ b/crates/ui-egui/tests/it/project_config.rs @@ -17,10 +17,6 @@ const TRIANGLE: &str = "v 0 0 0\nv 1 0 0\nv 0 1 0\nvt 0 0\nvt 1 0\nvt 0 1\nf 1/1 const FORMAT_HINT: &str = "For the whole project: how normal map images set as mesh maps are read (set them again after a change), and the default for export"; const TITLE: &str = "Project configuration"; -/// The window sits at the middle of the 1600-point-wide screen and is 560 points wide -const WINDOW_MIDDLE_X: f32 = 800.0; -const WINDOW_HALF_WIDTH: f32 = 280.0; - fn temp_dir(test: &str) -> TempDir { TempDir::new(test) } @@ -86,21 +82,6 @@ fn own_tick(h: &Harness<'_, TextureCraftApp>) -> bool { h.state().ui.windows.project_config.as_ref().is_some_and(|c| c.reimport) } -#[test] -fn the_menu_opens_the_window() { - let dir = temp_dir("menu"); - let mut h = app_on_a_quad(&dir); - - assert!(!window_is_open(&h)); - - open_window(&mut h); - - assert!(window_is_open(&h)); - assert!(h.query_by_label("3D MESH").is_some(), "the 3D mesh section"); - assert!(!reimport_ticked(&h), "nothing is ticked at first"); - assert!(h.state().ui.rail_panel.is_none(), "the Display panel stays where it was"); -} - #[test] fn many_texture_sets_keep_dialog_actions_reachable_in_a_short_viewport() { let dir = temp_dir("many-tiles"); @@ -130,69 +111,12 @@ fn many_texture_sets_keep_dialog_actions_reachable_in_a_short_viewport() { } #[test] -fn every_setting_has_an_info_icon_and_the_window_ends_with_a_note() { - let dir = temp_dir("info"); - let mut h = app_on_a_quad(&dir); - - open_window(&mut h); - - let icons: Vec<_> = h.get_all_by_label(egui_phosphor::regular::INFO).collect(); - let tip = "Green channel convention of normal maps: OpenGL (Y+) or DirectX (Y-). Imported and exported normal maps follow it."; - - assert!(h.query_by_label("Changing the mesh or normal format can recalculate texture channels.").is_some(), "the note above the buttons"); - assert_eq!( - icons.len(), - 13, - "3D mesh, Reimport mesh, Normal map format, tangent space, UV tiles and its two layouts, Import cameras, Preserve strokes, Auto-unwrap, \ - Physical size, Color management, Working color space" - ); - assert!(h.query_by_label(tip).is_none(), "no tooltip before hovering"); - - // The format icon is third in the window's rows - let mut centers: Vec<_> = icons.iter().map(|n| n.rect().center()).collect(); - centers.sort_by(|a, b| a.y.total_cmp(&b.y)); - let format_center = centers[2]; - h.hover_at(format_center); - h.run_steps(30); - - assert!(h.query_by_label(tip).is_some(), "hovering the normal map format icon explains it"); -} - -#[test] -fn the_window_follows_the_reference_layout() { - let dir = temp_dir("layout"); +fn unsupported_project_settings_are_disabled() { + let dir = temp_dir("unsupported-settings"); let mut h = app_on_a_quad(&dir); h.set_size(egui::vec2(1600.0, 2000.0)); - open_window(&mut h); - let order = [ - "3D MESH", - "Reimport mesh", - "PROJECT SETTINGS", - "Compute tangent space per fragment", - "UV Tile settings (UDIMs)", - "Change the UV tiles of a texture set in Texture Set Settings", - "Use UV Tile workflow", - "Use a separate texture set for each tile", - "Import settings", - "Import cameras", - "Preserve stroke positions on mesh", - "Auto-unwrap", - "Physical size", - "Working color space", - ]; - - // Only the window's own rows: a dock panel may show the same text (the fill's Scale switch offers Physical size) - let in_window = |node: &egui_kittest::Node<'_>| (node.rect().center().x - WINDOW_MIDDLE_X).abs() <= WINDOW_HALF_WIDTH; - let top = |label: &str| h.get_all_by_label(label).filter(in_window).map(|n| n.rect().top()).fold(f32::INFINITY, f32::min); - for labels in order.windows(2) { - assert!(top(labels[0]) < top(labels[1]), "{} comes before {}", labels[0], labels[1]); - } - - assert!(h.query_by_label("Custom unit scale").is_none(), "Physical size starts collapsed"); - - let disabled = |role: Role, label: &str| h.get_by_role_and_label(role, label).accesskit_node().is_disabled(); for (role, label) in [ (Role::CheckBox, "Compute tangent space per fragment"), (Role::CheckBox, "Use UV Tile workflow"), @@ -202,14 +126,8 @@ fn the_window_follows_the_reference_layout() { (Role::CheckBox, "Auto-unwrap"), (Role::Button, "Auto-unwrap options"), ] { - assert!(disabled(role, label), "{label} is disabled"); + assert!(h.get_by_role_and_label(role, label).accesskit_node().is_disabled(), "{label}"); } - - let center = h.get_by_role_and_label(Role::CheckBox, "Compute tangent space per fragment").rect().center(); - h.hover_at(center); - h.run_steps(30); - - assert!(h.query_by_label("Not available yet").is_some(), "the hint of a setting TextureCraft does not have yet"); } #[test] diff --git a/crates/ui-egui/tests/it/reference_order.rs b/crates/ui-egui/tests/it/reference_order.rs index f3943aee..dc191571 100644 --- a/crates/ui-egui/tests/it/reference_order.rs +++ b/crates/ui-egui/tests/it/reference_order.rs @@ -31,57 +31,6 @@ fn named<'a>(found: &'a [(f32, String, bool)], name: &str) -> Option<&'a (f32, S found.iter().find(|(_, label, _)| label == name || label.starts_with(&format!("{name} ("))) } -#[test] -fn every_menu_lists_its_items_in_the_reference_order() { - // Items the reference has and TextureCraft lacks are absent; TextureCraft's own sit where they fit - let expected = [ - "File: New project... | Open... | - | Open sample project... | - | Close | - | Save | Save as... | More save options > Save as template... | More save options > Save and reduce file size | More save options > Save as copy... | Remove unused resources... | - | Import resources... | Import MaterialX material... | Import PBR texture folder... | Import material... | Export Textures... | Export Mesh... | - | Quit", - "Edit: Undo | Redo | Project Configuration... | Reimport mesh | Settings...", - "Mode: Bake Mesh Maps | Painting | Rendering (path traced)", - "Window: Views > Assets | Views > Common Settings | Views > Display Settings | Views > Export | Views > History | Views > Layers | Views > Log | Views > Mesh Map Bakers | Views > Mesh Map Settings | Views > Properties | Views > Python Console | Views > Renderer Settings | Views > Shader Settings | Views > Online assets | Views > Texture Sets | Views > Texture Set Settings | Toolbars > Docks | Toolbars > Plugins | Toolbars > Tools | - | Save UI Layout > Painting mode | Save UI Layout > Rendering mode | Save UI Layout > Baking mode | Load UI Layout | Layouts > Save current layout as... | Layouts > Manage layouts... | - | Hide UI | Reset panel layout | Reset UI", - "Viewport: Display material | Display next channel | Display previous channel | Display next mesh map | Display previous mesh map | UV checker | - | Frame texture set | Show entire mesh | Front view | Back view | Left view | Right view | Top view | Bottom view | - | Perspective | Orthographic | - | 3D/2D views | 3D view only | 2D view only | Swap 3D/2D | - | Navigation buttons | - | Enable quick mask | Edit quick mask | Invert quick mask", - "Help: Release notes... | Documentation... | Shortcuts list... | - | Join the community (Discord)... | ArtCraft website... | Report a bug... | Show log... | Export log... | - | Check for Updates... | About TextureCraft...", - ]; - let actual: Vec = menus::TOP - .iter() - .map(|top| { - let items: Vec = menus::CATALOG - .iter() - .filter(|item| item.menu == *top) - .map(|item| match item.sub { - Some(sub) => format!("{sub} > {}", item.label), - None => item.label.to_string(), - }) - .collect(); - format!("{top}: {}", items.join(" | ")) - }) - .collect(); - for (expected, actual) in expected.iter().zip(&actual) { - assert_eq!(expected, actual); - } - assert_eq!(menus::TOP, ["File", "Edit", "Mode", "Window", "Viewport", "Help"], "the reference's top menus, minus the scripting ones"); -} - -#[test] -fn the_tool_shelf_keeps_the_reference_order() { - let harness = harness(texturecraft_engine::sample_session(256, 64).unwrap()); - let shelf = buttons_in(&harness, 0.0..60.0); - let order = ["Paint", "Eraser", "Path", "Projection", "Polygon fill", "Smudge", "Clone", "Material picker", "Geometry mask"]; - let row_positions: Vec = order.iter().map(|name| named(&shelf, name).unwrap_or_else(|| panic!("{name} on the shelf: {shelf:?}")).0).collect(); - - assert!(row_positions.windows(2).all(|pair| pair[0] < pair[1]), "{row_positions:?}"); -} - -#[test] -fn the_right_bar_keeps_the_reference_order() { - let harness = harness(texturecraft_engine::sample_session(256, 64).unwrap()); - let bar = buttons_in(&harness, 1562.0..1600.0); - let order = ["Export", "Log", "Display Settings", "Shader Settings", "History"]; - let row_positions: Vec = order.iter().map(|name| named(&bar, name).unwrap_or_else(|| panic!("{name} on the bar: {bar:?}")).0).collect(); - - assert!(row_positions.windows(2).all(|pair| pair[0] < pair[1]), "{row_positions:?}"); -} - #[test] fn the_blank_screen_enables_what_the_reference_enables() { let harness = harness(Session::closed().unwrap()); diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index 477283c9..028a265f 100644 --- a/crates/ui-egui/tests/it/settings_window.rs +++ b/crates/ui-egui/tests/it/settings_window.rs @@ -11,23 +11,6 @@ use texturecraft_ui_egui::{TextureCraftApp, menus}; use crate::memory_storage::MemoryStorage; -/// The section captions of the General page, top to bottom. -const SECTIONS: [&str; 13] = [ - "INTERFACE OPTIONS", - "LAYER STACK OPTIONS", - "CAMERA OPTIONS", - "BAKING OPTIONS", - "PREVIEW OPTIONS", - "TEMPORARY FILES", - "SPARSE VIRTUAL TEXTURE", - "IRAY HARDWARE", - "APPEARANCE", - "VIEWPORT", - "RESOURCES", - "AUTOSAVE", - "FOLDERS", -]; - fn harness(session: Session) -> Harness<'static, TextureCraftApp> { let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); @@ -97,24 +80,6 @@ fn the_left_column_switches_between_the_three_pages() { assert_eq!(page(&h), Some(SettingsPage::General)); } -#[test] -fn the_general_page_lists_the_reference_sections_in_order_without_privacy() { - let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); - open_settings(&mut h); - - // Rows below the scrolled view are laid out too, in page order - let mut shown: Vec = h - .query_all(egui_kittest::kittest::by().predicate(|node| node.label().or_else(|| node.value()).is_some_and(|text| SECTIONS.contains(&text.as_str())))) - .filter_map(|node| node.accesskit_node().label().or_else(|| node.accesskit_node().value())) - .collect(); - - // A label on screen also has a node for its text run - shown.dedup(); - assert_eq!(shown, SECTIONS.map(String::from).to_vec()); - assert!(h.query_by_label("PRIVACY").is_none(), "no Privacy section"); - assert!(h.query_by_label("Automatically send usage statistics").is_none()); -} - #[test] fn the_general_page_starts_at_the_reference_defaults() { let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); diff --git a/crates/ui-egui/tests/it/shelf_panel.rs b/crates/ui-egui/tests/it/shelf_panel.rs index d8b7a30c..cbfdf687 100644 --- a/crates/ui-egui/tests/it/shelf_panel.rs +++ b/crates/ui-egui/tests/it/shelf_panel.rs @@ -3,7 +3,6 @@ use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; use texturecraft_engine::brush_preset_cmds::UserBrush; -use texturecraft_engine::core::ProceduralKind; use texturecraft_engine::core::project::ENVIRONMENTS; use texturecraft_engine::materials::{MATERIALS, SmartMaterial}; use texturecraft_engine::smart_masks::SMART_MASKS; @@ -19,7 +18,6 @@ const NARROW_WINDOW: egui::Vec2 = egui::vec2(1100.0, 1032.0); const MATERIALS_TYPE: usize = 0; const SMART_MASKS_TYPE: usize = 2; const BRUSHES_TYPE: usize = 4; -const TEXTURES_TYPE: usize = 6; const ENVIRONMENTS_TYPE: usize = 7; /// How far the saved brush's spacing differs from the current brush's, so loading it shows const SAVED_SPACING_CHANGE: f32 = 0.25; @@ -329,26 +327,6 @@ fn saved_smart_materials_keep_their_type_pickable_in_your_assets() { assert!(button(&harness, "Materials").accesskit_node().is_disabled(), "no plain material is"); } -#[test] -fn saved_smart_materials_are_read_whatever_the_type_and_after_a_refresh() { - let mut harness = shelf(REFERENCE_WINDOW); - assert!(harness.state().library.is_some(), "read on the Materials type"); - - button(&harness, "Refresh").click(); - harness.run_steps(2); - - assert!(harness.state().library.is_some(), "read again after a refresh"); -} - -#[test] -fn procedurals_are_in_the_textures_type() { - let mut harness = shelf(REFERENCE_WINDOW); - harness.state_mut().ui.shelf_tab = TEXTURES_TYPE; - harness.run_steps(3); - - assert!(harness.query_by_label(ProceduralKind::ALL[0].label()).is_some()); -} - /// The reference's type dropdown, top to bottom const TYPE_DROPDOWN: [&str; 10] = ["Materials", "Smart materials", "Smart masks", "Filters", "Brushes", "Alphas", "Textures", "Environments", "Fonts", "Show all"]; diff --git a/crates/ui-egui/tests/it/shortcut_gestures.rs b/crates/ui-egui/tests/it/shortcut_gestures.rs deleted file mode 100644 index fdcddf9f..00000000 --- a/crates/ui-egui/tests/it/shortcut_gestures.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! The shortcut window's fixed list names the mouse gestures and hold keys of the painting tools. - -use egui_kittest::Harness; -use egui_kittest::kittest::Queryable as _; - -#[test] -fn the_gesture_grid_of_the_shortcut_window_lists_the_stencil_clone_line_and_path_gestures() { - let mut h = Harness::builder() - .with_size(egui::vec2(700.0, 900.0)) - .with_context_setup(texturecraft_ui_egui::theme::install) - .build_ui(texturecraft_ui_egui::keymap::fixed_gestures_grid); - h.run_steps(3); - for text in [ - "Shift + LMB", - "Paint a straight line from where the last stroke ended", - "S + LMB drag", - "Projection: rotate the stencil", - "S + RMB drag", - "S + MMB drag", - "V + LMB", - "Clone: pick the point to copy from", - "Path: add a point; on the curve it inserts one", - "Path: close it (needs 3 points)", - "Path: apply it with the brush", - "Path: remove the selected or last point", - "Path: cancel it", - "Shift + RMB drag", - "Alt + Shift + LMB drag", - "Camera snap rotate", - ] { - assert!(h.query_by_label(text).is_some(), "the overview lacks {text}"); - } -} diff --git a/crates/ui-egui/tests/it/shortcut_keys.rs b/crates/ui-egui/tests/it/shortcut_keys.rs index 3d10749b..927edd86 100644 --- a/crates/ui-egui/tests/it/shortcut_keys.rs +++ b/crates/ui-egui/tests/it/shortcut_keys.rs @@ -113,12 +113,3 @@ fn a_command_without_a_default_key_runs_from_the_key_it_is_bound_to() { h.run_steps(2); assert_eq!(h.state().session.doc.project.layers.len(), before + 1, "F7 added a fill layer"); } - -#[test] -fn the_shortcut_editor_lists_a_command_without_a_key_and_hides_one_that_needs_a_parameter() { - let mut h = harness(); - h.state_mut().ui.windows.shortcuts = true; - h.run_steps(4); - assert!(h.query_by_label("Toggle layer visibility").is_some(), "Toggle layer visibility is listed"); - assert!(h.query_by_label("Select texture set").is_none(), "Select texture set needs a texture set"); -} diff --git a/crates/ui-egui/tests/it/shortcut_list.rs b/crates/ui-egui/tests/it/shortcut_list.rs index f99db223..c603cbde 100644 --- a/crates/ui-egui/tests/it/shortcut_list.rs +++ b/crates/ui-egui/tests/it/shortcut_list.rs @@ -4,8 +4,7 @@ use egui::{Event, Key, Modifiers, Role}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; use serde_json::json; -use texturecraft_ui_egui::keymap::{self, NOT_AVAILABLE_ACTIONS, bindings, shortcut_of}; -use texturecraft_ui_egui::state::Mode; +use texturecraft_ui_egui::keymap::{NOT_AVAILABLE_ACTIONS, bindings}; use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness() -> Harness<'static, TextureCraftApp> { @@ -21,46 +20,6 @@ fn press(h: &mut Harness<'_, TextureCraftApp>, key: Key, modifiers: Modifiers) { h.run_steps(3); } -#[test] -fn the_list_starts_with_the_reference_names_and_keys_in_the_reference_order() { - let expected = [ - ("Hide UI", "Tab"), - ("Undo", "Ctrl+Z"), - ("Redo", "Ctrl+Y"), - ("Open project", "Ctrl+O"), - ("Close project", "Ctrl+F4"), - ("Save project", "Ctrl+S"), - ("Save as project", "Ctrl+Shift+S"), - ("New project", "Ctrl+N"), - ("Quit application", "Ctrl+Q"), - ("Export Textures...", "Ctrl+Shift+E"), - ("Reimport mesh", "Ctrl+Shift+R"), - ("Switch to baking mode", "Ctrl+Shift+B"), - ("Switch to edition mode", "F9"), - ("Switch to rendering mode (path traced)", "F10"), - ("Show mesh wireframe", ""), - ("Camera projection: Perspective view", "F5"), - ("Camera projection: Orthographic view", "F6"), - ("Display next channel", "C"), - ("Display previous channel", "Shift+C"), - ("Display material", "M"), - ("Display next mesh map", "B"), - ("Display previous mesh map", "Shift+B"), - ("Show entire mesh/path", "F"), - ("Select next camera", ">"), - ("Select previous camera", "<"), - ("Enable quick mask", "Y"), - ("Edit quick mask", "U"), - ("Invert quick mask", "Ctrl+Shift+I"), - ("Viewers layout: 3D/2D", "F1"), - ("Viewers layout: 3D only", "F2"), - ("Viewers layout: 2D only", "F3"), - ("Viewers layout: Swap 3D/2D", "F4"), - ]; - let actual: Vec<(&str, &str)> = bindings().iter().take(expected.len()).map(|b| (b.label, keymap::shown(b.default.unwrap_or("")))).collect(); - assert_eq!(actual, expected); -} - #[test] fn no_two_default_shortcuts_are_the_same() { let mut seen = std::collections::BTreeMap::new(); @@ -76,29 +35,13 @@ fn no_two_default_shortcuts_are_the_same() { } #[test] -fn the_menus_keep_their_texts_and_quit_keeps_ctrl_q() { - let label = |id: &str| menus::CATALOG.iter().find(|item| item.id == id).map(|item| item.label); - assert_eq!(label("file.open"), Some("Open...")); - assert_eq!(label("file.saveAs"), Some("Save as...")); - assert_eq!(label("ui.quit"), Some("Quit")); - assert_eq!(label("ui.mode.bake"), Some("Bake Mesh Maps")); - assert_eq!(label("viewport.frame"), Some("Show entire mesh")); - assert_eq!(shortcut_of(&keymap::Keymap::new(), "ui.quit"), Some("Ctrl+Q")); - assert_eq!(shortcut_of(&keymap::Keymap::new(), "ui.mode.bake"), Some("Ctrl+Shift+B")); -} - -#[test] -fn the_settings_page_lists_the_reference_names_and_shows_the_missing_functions_disabled() { +fn the_settings_page_disables_editing_shortcuts_for_unavailable_actions() { let mut h = harness(); let ctx = h.ctx.clone(); menus::invoke(h.state_mut(), &ctx, "ui.settings"); h.run_steps(4); h.get_by_role_and_label(Role::Tab, "Shortcuts").click(); h.run_steps(4); - for name in ["Open project", "Save as project", "Quit application", "Switch to baking mode", "Show entire mesh/path", "Viewers layout: Swap 3D/2D"] { - assert!(h.query_by_label(name).is_some(), "{name} is listed"); - } - assert!(h.query_by_label("Open...").is_none(), "the menu's text is not the list's"); for (_, row) in &NOT_AVAILABLE_ACTIONS { let action = row.label; h.get_by_label(action).scroll_to_me(); @@ -107,27 +50,6 @@ fn the_settings_page_lists_the_reference_names_and_shows_the_missing_functions_d } } -#[test] -fn the_listed_keys_run_their_commands() { - let mut h = harness(); - press(&mut h, Key::B, Modifiers::COMMAND | Modifiers::SHIFT); - assert_eq!(h.state().ui.mode, Mode::Baking, "Ctrl+Shift+B switches to baking mode"); - press(&mut h, Key::F9, Modifiers::NONE); - assert_eq!(h.state().ui.mode, Mode::Painting, "F9 switches to edition mode"); - press(&mut h, Key::F10, Modifiers::NONE); - assert_eq!(h.state().ui.mode, Mode::Rendering); - press(&mut h, Key::F9, Modifiers::NONE); - - // Show mesh wireframe has no key until one is given - assert!(!h.state().ui.mesh_wireframe); - h.state_mut().ui.keymap.insert("ui.wireframe".into(), "F7".into()); - h.run_steps(2); - press(&mut h, Key::F7, Modifiers::NONE); - assert!(h.state().ui.mesh_wireframe, "the wireframe is shown"); - press(&mut h, Key::F7, Modifiers::NONE); - assert!(!h.state().ui.mesh_wireframe, "and hidden again"); -} - #[test] fn greater_and_less_select_the_next_and_previous_camera() { let mut h = harness(); @@ -161,13 +83,3 @@ fn a_key_listed_for_a_missing_function_is_reported_as_shared() { assert!(h.query_by_label_contains("One or several errors").is_some(), "Space is Toggle animation's"); assert!(h.get_by_label("OK").accesskit_node().is_disabled()); } - -#[test] -fn the_shortcut_window_shows_the_reference_keys_and_the_missing_functions() { - let mut h = harness(); - h.state_mut().ui.windows.shortcuts = true; - h.run_steps(4); - assert!(h.query_by_label("Pause Engine Computation").is_some() && h.query_by_label("Toggle animation").is_some()); - assert!(h.query_all_by_label(">").next().is_some() && h.query_all_by_label("<").next().is_some(), "the camera keys read as the reference's"); - assert!(h.query_by_label("Shift+Period").is_none()); -} diff --git a/crates/ui-egui/tests/it/symmetry.rs b/crates/ui-egui/tests/it/symmetry.rs index d148d41f..e5ea44f6 100644 --- a/crates/ui-egui/tests/it/symmetry.rs +++ b/crates/ui-egui/tests/it/symmetry.rs @@ -398,14 +398,3 @@ fn escape_cancels_picking_the_symmetry_point() { assert!(!harness.state().picking_symmetry_plane); assert_eq!(harness.state().session.tool.brush.symmetry.offset, [0.0; 3]); } - -#[test] -fn the_smudge_tool_offers_the_symmetry_toggle() { - let mut harness = app_harness(); - harness.state_mut().session.tool.tool = Tool::Smudge; - harness.run_steps(2); - - harness.get_by_label("Symmetry").click(); - harness.run_steps(2); - assert_eq!(brush(&mut harness)["symmetry"], json!([true, false, false]), "the toggle mirrors the smudge on X"); -} diff --git a/crates/ui-egui/tests/it/templates_681.rs b/crates/ui-egui/tests/it/templates_681.rs index c73ebe1d..4c147db4 100644 --- a/crates/ui-egui/tests/it/templates_681.rs +++ b/crates/ui-egui/tests/it/templates_681.rs @@ -93,27 +93,6 @@ fn save_and_reduce_file_size_is_greyed_with_the_hint() { assert!(!menus::implemented("ui.saveReduced")); } -#[test] -fn the_project_template_info_tooltip_lists_the_settings_templates_apply() { - let mut h = app(); - h.state_mut().ui.windows.new_project = true; - h.run_steps(4); - let row = h.get_by_label("Project template").rect().center().y; - let icon = h - .get_all_by_label(egui_phosphor::regular::INFO) - .find(|node| (node.rect().center().y - row).abs() < 6.0) - .expect("the info icon in the Project template row"); - - // The icon's node is wider than the glyph: hover its left part - let at = icon.rect().center() - egui::vec2(6.0, 0.0); - h.hover_at(egui::pos2(1.0, 1.0)); - h.run_steps(2); - h.hover_at(at); - h.run_steps(30); - let tip = "Templates set the starting channels, resolution, normal map format and shader settings."; - assert!(h.query_by_label(tip).is_some(), "hovering the info icon of the Project template row"); -} - #[test] fn new_project_opens_on_the_template_of_the_last_project() { let dir = TempDir::new("last-template"); diff --git a/crates/ui-egui/tests/it/view_mode_picker.rs b/crates/ui-egui/tests/it/view_mode_picker.rs index 98f32d58..e0009a84 100644 --- a/crates/ui-egui/tests/it/view_mode_picker.rs +++ b/crates/ui-egui/tests/it/view_mode_picker.rs @@ -4,7 +4,6 @@ use egui::Role; use egui_kittest::Harness; use egui_kittest::kittest::Queryable as _; use texturecraft_engine::ViewMode; -use texturecraft_engine::core::Channel; use texturecraft_ui_egui::TextureCraftApp; fn harness() -> Harness<'static, TextureCraftApp> { @@ -38,39 +37,6 @@ fn query_field<'a>(h: &'a Harness<'_, TextureCraftApp>) -> egui_kittest::Node<'a h.get_all_by_role(Role::TextInput).find(|node| node.value().as_deref() == Some("u:image PRs")).expect("the query starts as in the reference") } -#[test] -fn the_combo_lists_the_reference_sections_and_names() { - let mut h = harness(); - open(&mut h, "Material"); - for label in [ - "Lighting", - "Material", - "Single channel", - "Base color", - "Base metalness", - "Specular roughness", - "Normal", - "Height", - "Normal+height+mesh", - "Mesh maps", - "World space normal", - "ID", - "Ambient occlusion", - "Curvature", - "Position", - "Thickness", - "Bent normals", - "Opacity", - "Other...", - ] { - assert!(h.query_all_by_label(label).next().is_some(), "{label}"); - } - for old in ["Metallic", "Roughness", "Mesh map: Normal", "Mesh map: World Space Normal", "Ambient Occlusion", "Bent Normals"] { - assert!(h.query_by_label(old).is_none(), "{old} is not offered"); - } - assert!(h.query_all_by_label("Normal").count() >= 2, "Normal is a channel and a mesh map"); -} - #[test] fn the_section_titles_cannot_be_picked() { let mut h = harness(); @@ -79,25 +45,6 @@ fn the_section_titles_cannot_be_picked() { assert_eq!(h.state().session.view, ViewMode::Material, "a title is no mode"); } -#[test] -fn a_channel_shows_under_its_reference_name_in_this_combo_only() { - let mut h = harness(); - open(&mut h, "Material"); - pick(&mut h, "Specular roughness"); - assert_eq!(h.state().session.view, ViewMode::Channel(Channel::Roughness)); - picker(&h, "Specular roughness"); - assert_eq!(Channel::Roughness.label(), "Roughness", "other places keep the channel's name"); -} - -#[test] -fn a_mesh_map_shows_without_a_prefix() { - let mut h = harness(); - open(&mut h, "Material"); - pick(&mut h, "Ambient occlusion"); - assert_eq!(h.state().session.view, ViewMode::MeshMap(texturecraft_engine::core::BakedMap::AmbientOcclusion)); - picker(&h, "Ambient occlusion"); -} - fn png() -> Vec { let mut png = Vec::new(); let image = image::RgbaImage::from_pixel(4, 4, image::Rgba([200, 40, 40, 255])); @@ -190,15 +137,3 @@ fn removing_the_shown_image_brings_the_material_back() { assert_eq!(h.state().session.view, ViewMode::Material); picker(&h, "Material"); } - -#[test] -fn bake_mode_keeps_its_own_view_list() { - let mut h = harness(); - h.state_mut().ui.mode = texturecraft_ui_egui::state::Mode::Baking; - h.run_steps(4); - open(&mut h, "Neutral Material"); - h.get_by_label("Mesh map: Ambient Occlusion").scroll_to_me(); - h.run_steps(3); - assert!(h.query_by_label("Mesh map: Ambient Occlusion").is_some(), "mesh maps keep their prefix in Bake mode"); - assert!(h.query_by_label("Lighting").is_none() && h.query_by_label("Mesh maps").is_none(), "no section titles in Bake mode"); -} diff --git a/xtask/src/version.rs b/xtask/src/version.rs index b2f31b20..746d57c0 100644 --- a/xtask/src/version.rs +++ b/xtask/src/version.rs @@ -139,10 +139,4 @@ mod tests { assert!(validate(bad).is_err(), "{bad}"); } } - - #[test] - fn the_real_manifest_has_a_valid_version() { - let text = std::fs::read_to_string(crate::root().join("Cargo.toml")).unwrap(); - validate(&read(&text).unwrap()).unwrap(); - } }