//! Cotton Photos on a phone that started its own database and never signed//! in: what the shell is answered for its deck, Plus and a held print. Every//! picture is synthetic.use serde_json::{json, Value};usecrate::methods::dispatch;usecrate::handle::{CottonHandle, OpenConfig, OpenMode};fn photos_manifest() -> Value { serde_json::from_str(include_str!("../../../../apps/cotton/App/Flavours/photos/flavour.json")).expect("Photos' manifest")}fn phone(dir: &tempfile::TempDir) -> CottonHandle {let handle = CottonHandle::open(OpenConfig { mode: OpenMode::Phone { container_path: dir.path().to_string_lossy().to_string(), previous_container_path: None }, app_version: None, time_zone: Some("Asia/Kolkata".to_string()), device_secret: Some(crate::fixture::paired_secret()), vault_secret: None, flavor: cotton_core::flavor::Flavor::Real, manifest: Some(photos_manifest()), }) .expect("an open core"); dispatch(&handle, "workspace.startLocal", &json!({ "deviceName": "An invented phone" })).expect("started on the phone"); handle}fn ask(handle: &CottonHandle, method: &str, request: Value) -> Value { dispatch(handle, method, &request).unwrap_or_else(|error| panic!("{method} {request}: {error:?}"))}/// RULE (Cotton Photos on Android, 15 Nov 2026: Android first): Photos' Plus is its three doors as the shell opens them — Choose photos the system photo picker (photos and videos, many), Take a photo the camera, From Files the files picker by media type; a picture kept from any of them (`capture.media`) stands on Recent as a lab print whose tap opens the viewer and whose acts are Share, Favourite, Group and Delete; Share answers the file to hand to the share sheet; the viewer's words (its Close, its position, what an absent picture says) come with the deck; Albums is empty on a new phone and says why. Everything works signed out.#[test]fn a_picked_picture_stands_as_a_print_with_its_acts() {let dir = tempfile::tempdir().expect("a temp container");let handle = phone(&dir);let fan = ask(&handle, "shell.fan", json!({ "timezone": "Asia/Kolkata" })); assert_eq!(fan["opens"], json!({"tier": "views", "tool": "photos", "view": "all"}), "{fan}");let plus = ask(&handle, "shell.plus", json!({ "table": "media" })); assert_eq!(plus["does"], "doors", "{plus}");let doors = plus["doors"].as_array().expect("doors");let ids: Vec<&str> = doors.iter().filter_map(|door| door["id"].as_str()).collect(); assert_eq!(ids, ["library", "camera", "files"], "{plus}"); assert_eq!(doors[0]["accepts"]["pick"], json!({"source": "library", "kinds": ["photo", "video"], "many": true})); assert_eq!(doors[1]["accepts"]["pick"]["source"], "camera"); assert_eq!(doors[2]["accepts"]["files"]["mimes"], json!(["image/*", "video/*"]));let picked = dir.path().join("picked.png"); std::fs::write(&picked, b"png").expect("a synthetic file");let kept = ask(&handle, "capture.media", json!({ "path": picked.to_string_lossy(), "mime": "image/png", "filename": "picked.png", "kind": "photo" }));let id = kept["recordId"].as_str().expect("the kept photo").to_string();let deck = ask(&handle, "shell.deck", json!({ "table": "media", "view": "photos/all", "cursor": 0, "limit": 50, "timezone": "Asia/Kolkata" }));let card = deck["cards"].as_array().expect("cards").iter().find(|card| card["id"] == json!(id)).expect("the print on Recent").clone(); assert_eq!(card["face"], "photo.print", "{card}"); assert_eq!(card["slots"]["photo"], kept["key"], "{card}"); assert_eq!(card["tap"]["card"], "open.viewer", "{card}");// A photo can be sent, sealed to one of the person's people (R5). assert_eq!(card["acts"], json!(["share", "favourite", "group", "send", "delete"]), "{card}"); assert_eq!(deck["plus"], plus, "the deck's Plus is shell.plus's");let media: Value = serde_json::from_str(include_str!("../../../cotton-core/kits/personal/tables/media.json")).expect("the media table"); assert_eq!(deck["viewer"], media["viewer"]["words"], "the viewer's words come with the deck its prints open from");let shared = ask(&handle, "media.share", json!({ "key": kept["key"] })); assert_eq!(shared["platform_action"], "share_file", "{shared}");let albums = ask(&handle, "shell.deck", json!({ "table": "album", "view": "photos/albums", "cursor": 0, "limit": 50, "timezone": "Asia/Kolkata" })); assert_eq!(albums["cards"], json!([]), "{albums}"); assert!(albums["empty"]["title"].as_str().is_some_and(|title| !title.is_empty()), "{albums}"); assert_eq!(albums["worn"], "album.carousel", "{albums}");}