File tree Expand file tree Collapse file tree
AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44//
55
66import Testing
7+ import Foundation
78@testable import AndroidSwiftUICore
89
910#if canImport(Observation)
@@ -194,4 +195,23 @@ struct ControlTests {
194195 #expect( node. props [ " text " ] == . string( " Coleman " ) )
195196 }
196197 #endif
198+
199+ @Test ( " DatePicker emits its selection in milliseconds and round-trips a change " )
200+ func datePicker( ) {
201+ let initial = Date ( timeIntervalSince1970: 1_768_435_200 ) // 2026-01-15T00:00:00Z
202+ let changed = Date ( timeIntervalSince1970: 1_772_323_200 ) // 2026-03-01T00:00:00Z
203+ struct Screen : View {
204+ @State var date : Date
205+ var body : some View { DatePicker ( " Birthday " , selection: $date) }
206+ }
207+ let host = ViewHost ( Screen ( date: initial) )
208+ var node = host. evaluate ( )
209+ #expect( node. type == " DatePicker " )
210+ #expect( node. props [ " millis " ] == . double( initial. timeIntervalSince1970 * 1000 ) )
211+ if case . int( let id) ? = node. props [ " onChange " ] {
212+ host. callbacks. invokeDouble ( Int64 ( id) , changed. timeIntervalSince1970 * 1000 )
213+ }
214+ node = host. evaluate ( )
215+ #expect( node. props [ " millis " ] == . double( changed. timeIntervalSince1970 * 1000 ) )
216+ }
197217}
You can’t perform that action at this time.
0 commit comments