//! Android Vector Drawable (XML) export through the commands: one-off exports with their //! warnings, export settings with a compatibility mode (stored, saved, edited), export layers, //! and bad values refused. use base64::Engine as _; use figcraft_doc::*; use serde_json::{Value, json}; use crate::Session; use crate::params::id_of; /// A session with a 48 × 24 frame holding two overlapping rectangles at 50% opacity. fn session() -> (Session, NodeId) { let mut s = Session::new(); let r = s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 48, "height": 24, "name": "Badge"})).unwrap(); let f = id_of(&r["id"]).unwrap(); for x in [0, 12] { s.execute("shape.rectangle", &json!({"x": x, "y": 0, "width": 24, "height": 24, "parent": f})).unwrap(); } s.execute("node.set", &json!({"ids": [f], "props": {"opacity": 0.5}})).unwrap(); s.set_selection(vec![f]); (s, f) } fn xml(r: &Value) -> String { let bytes = base64::engine::general_purpose::STANDARD.decode(r["data"].as_str().unwrap()).unwrap(); String::from_utf8(bytes).unwrap() } #[test] fn a_one_off_export_returns_the_drawable_and_its_warnings() { let (mut s, f) = session(); let r = s.execute("file.export", &json!({"ids": [f], "format": "xml"})).unwrap(); assert_eq!(r["format"], "xml"); let x = xml(&r); assert!(x.starts_with("