Cotton code
35 lines · 2.2 KB · SwiftRaw
// A page painted for its picture performs no side effect (architect, 17 Oct// 2026, 292): the fan's painter mounted Camera's page two cards away and the// camera's permission prompt rose over Subscriptions.import CottonKitimport XCTest@testable import CottonUIfinal class PictureModeTests: XCTestCase {    /// GUARD: painting a page asks for no permission and opens no session.    /// RULE: a page painted for its picture runs in picture mode — it draws its face and performs no side effect: no permission asked, no capture session, no timer; Camera's picture is its face (walker291: the camera prompt rose while Subscriptions was open).    func testAPagePaintedForItsPictureAsksNothing() async throws {        let real = ScriptedCapabilityAuthority(statuses: [.camera: .authorized])        let picture = PictureCapabilities(real: real)        for capability in DeviceCapability.allCases {            let answer = await picture.ask(capability)            let standing = await real.status(capability)            XCTAssertEqual(answer, standing, "\(capability) answers where it stands")        }        XCTAssertEqual(real.asked, [], "no prompt was raised for any capability")        // The painter's host is in picture mode inside the window's environment,        // and Camera opens its session only when it is not being painted.        let painter = SourceSweep.withoutComments(            try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/Board/PagePictures.swift", ownedBy: "rough"))            .filter { !$0.isWhitespace }        XCTAssertTrue(painter.contains("page.modifier(PictureMode()).environment(\\.self,environment)"),                      "the painted page is in picture mode, set inside the window's environment so it is not overwritten")        let camera = SourceSweep.withoutComments(            try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Camera/CameraScreen.swift", ownedBy: "rough"))            .filter { !$0.isWhitespace }        XCTAssertTrue(camera.contains(".task{guard!paintsPictureelse{return}awaitmodel.open(capabilities)}"),                      "a camera painted for its picture opens no capture session")    }}