mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-28 11:47:21 -06:00
refactor(render): move tests_*.rs to tests/<topic>.rs
This commit is contained in:
@@ -2847,55 +2847,7 @@ thread_local! {
|
||||
static OFFSCREEN_PIXELS: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
use tests::fontchange as tests_fontchange;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod tests_adjust;
|
||||
#[cfg(test)]
|
||||
mod tests_alternate;
|
||||
#[cfg(test)]
|
||||
mod tests_bitmapglyphs;
|
||||
#[cfg(test)]
|
||||
mod tests_blend;
|
||||
#[cfg(test)]
|
||||
mod tests_changed;
|
||||
#[cfg(test)]
|
||||
mod tests_charstroke;
|
||||
#[cfg(test)]
|
||||
mod tests_clip;
|
||||
#[cfg(test)]
|
||||
mod tests_cmykblend;
|
||||
#[cfg(test)]
|
||||
mod tests_colrglyphs;
|
||||
#[cfg(test)]
|
||||
mod tests_container;
|
||||
#[cfg(test)]
|
||||
mod tests_dither;
|
||||
#[cfg(test)]
|
||||
mod tests_fontchange;
|
||||
#[cfg(test)]
|
||||
mod tests_freeform;
|
||||
#[cfg(test)]
|
||||
mod tests_fxzoom;
|
||||
#[cfg(test)]
|
||||
mod tests_isolation;
|
||||
#[cfg(test)]
|
||||
mod tests_knockout;
|
||||
#[cfg(test)]
|
||||
mod tests_layeropts;
|
||||
#[cfg(test)]
|
||||
mod tests_memory;
|
||||
#[cfg(test)]
|
||||
mod tests_objectfx;
|
||||
#[cfg(test)]
|
||||
mod tests_placed_document;
|
||||
#[cfg(test)]
|
||||
mod tests_rasterize;
|
||||
#[cfg(test)]
|
||||
mod tests_setup;
|
||||
#[cfg(test)]
|
||||
mod tests_strokegradient;
|
||||
#[cfg(test)]
|
||||
mod tests_tileedge;
|
||||
#[cfg(test)]
|
||||
mod tests_viewraster;
|
||||
|
||||
@@ -3,6 +3,32 @@ use vectorcraft_color::{Color, Gradient, GradientPaint, Paint};
|
||||
use vectorcraft_doc::{Appearance, Node};
|
||||
use vectorcraft_geom::shapes;
|
||||
|
||||
mod adjust;
|
||||
mod alternate;
|
||||
mod bitmapglyphs;
|
||||
mod blend;
|
||||
mod changed;
|
||||
mod charstroke;
|
||||
mod clip;
|
||||
mod cmykblend;
|
||||
mod colrglyphs;
|
||||
mod container;
|
||||
mod dither;
|
||||
pub(super) mod fontchange;
|
||||
mod freeform;
|
||||
mod fxzoom;
|
||||
mod isolation;
|
||||
mod knockout;
|
||||
mod layeropts;
|
||||
mod memory;
|
||||
mod objectfx;
|
||||
mod placed_document;
|
||||
mod rasterize;
|
||||
mod setup;
|
||||
mod strokegradient;
|
||||
mod tileedge;
|
||||
mod viewraster;
|
||||
|
||||
fn rect_node(d: &mut Document, r: Rect, fill: Paint, stroke: Paint, w: f64) -> Node {
|
||||
let id = d.alloc_id();
|
||||
Node::path(id, shapes::rectangle(r), Appearance::basic(fill, stroke, w))
|
||||
|
||||
@@ -9,7 +9,7 @@ use vectorcraft_doc::text::{CharStyle, TextObject};
|
||||
use vectorcraft_doc::{Appearance, Effect, ImageBlob, ImageObject, Node, NodeKind, Symbol};
|
||||
use vectorcraft_geom::{Point, shapes};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
fn fx(id: &str, params: Value) -> Effect {
|
||||
Effect { id: id.into(), params, visible: true }
|
||||
@@ -2,7 +2,7 @@
|
||||
//! cell behind them on screen when the preference is on. Preferences › Type › Highlight
|
||||
//! Substituted Fonts does the same for text drawn in a substitute for a missing font.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// Highlight Substituted Fonts follows the preference passed in [`RenderOptions`] for every
|
||||
/// document, whatever a document's own setup stored: on, type in a missing font has pink behind
|
||||
@@ -6,7 +6,7 @@ use vectorcraft_doc::{Node, NodeKind};
|
||||
use vectorcraft_geom::Point;
|
||||
use vectorcraft_text::test_fonts::{COLOUR_CHAR, COLOUR_LARGE, colour_bitmap_family, colour_bitmap_font};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// 100 pt [`COLOUR_CHAR`] in the colour bitmap test font (`sbix` or `CBDT`), filled blue, its
|
||||
/// baseline at (20, 120), on a white 160×160 page.
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Blend-mode accuracy: every mode matches the reference formulas ([`blend_rgb`]) within 1/255
|
||||
//! (see [`tolerance`]), whether it is an object's blend mode, a fill's or a group's.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::blend::blend_rgb;
|
||||
use vectorcraft_color::{BlendMode as Blend, Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, Node};
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Drawing again only what an edit changed gives the pixels of drawing it all again.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::Appearance;
|
||||
use vectorcraft_geom::{Point, shapes};
|
||||
@@ -6,7 +6,7 @@ use vectorcraft_doc::text::{CharStyle, TextObject};
|
||||
use vectorcraft_doc::{AppearanceItem, Dash, LineJoin, Node, NodeKind};
|
||||
use vectorcraft_geom::Point;
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use crate::tests_fontchange::fonts_steady;
|
||||
|
||||
const SIZE: u32 = 200;
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Clip groups clip by any clipping path (M3.26): compound holes, even-odd fills, the union of a
|
||||
//! group's members, text outlines; with nothing to clip by the clipped art is hidden.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, CharStyle};
|
||||
use vectorcraft_geom::{PathData, Point, SubPath, shapes};
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Blending in CMYK documents ([`crate::ink`]): blend modes and opacity composite inks.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::blend::MASK_LUM;
|
||||
use vectorcraft_color::{BlendMode as Blend, Color, Gradient, GradientKind, GradientPaint, GradientStop, Paint};
|
||||
use vectorcraft_doc::{Appearance, ColorMode, ImageBlob, ImageObject, Node, OpacityMask};
|
||||
@@ -7,7 +7,7 @@ use vectorcraft_doc::{Node, NodeKind};
|
||||
use vectorcraft_geom::Point;
|
||||
use vectorcraft_text::test_fonts::{COLOUR_CHAR, COLR_SWEEP_CHAR, colr_family, colr_font};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// 100 pt `text` in the COLR test font (v1 or v0), filled magenta, its baseline at (20, 120)
|
||||
/// turned by `turn` about there, on a white 160×160 page.
|
||||
@@ -11,7 +11,7 @@ use vectorcraft_doc::text::{CharStyle, TextObject};
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, FillLayer, ImageBlob, ImageObject, Knockout, Node, NodeKind, StrokeLayer};
|
||||
use vectorcraft_geom::{Point, shapes};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
fn fx(id: &str, params: Value) -> Effect {
|
||||
Effect { id: id.into(), params, visible: true }
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Dithered gradient fills: fine noise instead of bands, the same colours on average, the same
|
||||
//! pixels on every render, and nothing changed without dither or on strokes.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::{Color, Gradient, GradientKind, GradientPaint, GradientStop, Paint};
|
||||
use vectorcraft_doc::{Appearance, Node};
|
||||
use vectorcraft_geom::shapes;
|
||||
@@ -7,7 +7,7 @@ use vectorcraft_doc::text::{CharStyle, TextObject};
|
||||
use vectorcraft_doc::{Node, NodeKind};
|
||||
use vectorcraft_geom::Point;
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// Taken to add fonts, or to look up an installed one by name (`FontDb::face` loads it, which
|
||||
/// changes the fonts too). Renderers lay type out again when the fonts change, so tests of what
|
||||
@@ -28,7 +28,7 @@ pub(crate) fn adding_fonts() -> RwLockWriteGuard<'static, ()> {
|
||||
|
||||
/// The bundled Source Serif 4 renamed `family` (as long as the original name).
|
||||
fn serif_as(family: &str) -> Vec<u8> {
|
||||
let mut data = include_bytes!("../../../assets/fonts/SourceSerif4-Regular.ttf").to_vec();
|
||||
let mut data = include_bytes!("../../../../assets/fonts/SourceSerif4-Regular.ttf").to_vec();
|
||||
let utf16 = |s: &str| s.encode_utf16().flat_map(u16::to_be_bytes).collect::<Vec<u8>>();
|
||||
for (from, to) in [(utf16("Source Serif 4"), utf16(family)), (b"Source Serif 4".to_vec(), family.as_bytes().to_vec())] {
|
||||
assert_eq!(from.len(), to.len());
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Freeform gradients: the rendered colour grid against the colour field.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::freeform::spread_scale;
|
||||
use vectorcraft_color::{Color, Freeform, FreeformPoint, Gradient, GradientKind, GradientPaint, Paint};
|
||||
use vectorcraft_doc::{Appearance, Node};
|
||||
@@ -6,7 +6,7 @@ use vectorcraft_doc::text::{CharStyle, TextObject};
|
||||
use vectorcraft_doc::{Appearance, Effect, Node, NodeKind};
|
||||
use vectorcraft_geom::{Point, shapes};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// Type blurred by `radius` points (Gaussian Blur, or Feather when `feather`) over a rectangle
|
||||
/// that overlays at half opacity; without the type when `radius` is `None`.
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Non-isolated transparency groups: blending inside a group with opacity or a blend mode reaches
|
||||
//! the art below the group unless Isolate Blending is on (checked against the reference formulas).
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::blend::{blend_rgb, composite};
|
||||
use vectorcraft_color::{BlendMode as Blend, Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, Knockout, Node};
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Knockout groups, the knockout shape and the page group (Transparency panel).
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::{BlendMode as Blend, Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, Knockout, Node};
|
||||
use vectorcraft_geom::shapes;
|
||||
@@ -5,7 +5,7 @@ use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, ImageBlob, ImageObject, Node, NodeId, NodeKind};
|
||||
use vectorcraft_geom::shapes;
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// A red square (10..40) and a 30×30 red image at (50, 10), on one layer set up by `layer`.
|
||||
fn doc(layer: impl FnOnce(&mut NodeKind)) -> Document {
|
||||
@@ -6,7 +6,7 @@
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Document, ImageBlob, ImageObject, Node, NodeKind};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use crate::tests_fontchange::fonts_steady;
|
||||
|
||||
/// A `w`×`h` PNG whose pixels depend on `seed` (each test its own image: the store is shared by
|
||||
@@ -11,7 +11,7 @@ use vectorcraft_doc::text::{CharStyle, TextObject};
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, Effect, FillLayer, ImageBlob, ImageObject, Node, NodeKind, StrokeLayer, Symbol};
|
||||
use vectorcraft_geom::{Point, shapes};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
fn fx(id: &str, params: Value) -> Effect {
|
||||
Effect { id: id.into(), params, visible: true }
|
||||
+1
-1
@@ -5,7 +5,7 @@ use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, ImageBlob, LinkInfo, Node, NodeId, NodeKind, PlacedDocument};
|
||||
use vectorcraft_geom::shapes;
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// Every file reads as a 40×20 artboard filled blue; a file whose bytes start with `loop` also
|
||||
/// places itself (the same key) in its middle, and one whose bytes start with `bad` can't be read.
|
||||
@@ -6,7 +6,7 @@ use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, Effect, Node};
|
||||
use vectorcraft_geom::{Anchor, PathData, Point, SubPath, shapes};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
/// A red shape (`path`, over 10..30 pt) with the effects `fx` (id, params), in a document whose
|
||||
/// raster effects resolution is `ppi`.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use vectorcraft_doc::{Document, ImageBlob, ImageObject, Node, NodeKind};
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
fn doc_with_red_image() -> Document {
|
||||
let mut d = Document::new(40.0, 40.0);
|
||||
+1
-1
@@ -5,7 +5,7 @@ use vectorcraft_color::{Gradient, GradientPaint, Paint};
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, Node, StrokeGradientMode, StrokeLayer};
|
||||
use vectorcraft_geom::PathData;
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
|
||||
const SIZE: u32 = 200;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Pattern editing mode: the tile edge in the Tile Edge Color, and Show Swatch Bounds.
|
||||
|
||||
use super::*;
|
||||
use crate::*;
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::pattern::{PatternDef, PatternEdit, TileType};
|
||||
use vectorcraft_doc::{Appearance, Node};
|
||||
Reference in New Issue
Block a user