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 @@ -146,4 +146,38 @@ struct ModifierTests {
146146 let limit = node. modifiers. first { $0. kind == " lineLimit " }
147147 #expect( limit? . args [ " count " ] == . int( 2 ) )
148148 }
149+
150+ @Test ( " onTapGesture registers a callback and emits its id " )
151+ func onTapGesture( ) {
152+ var tapped = false
153+ let host = ViewHost ( Text ( " x " ) . onTapGesture { tapped = true } )
154+ let node = host. evaluate ( )
155+ let tap = node. modifiers. first { $0. kind == " onTapGesture " }
156+ guard case . int( let id) ? = tap? . args [ " action " ] else {
157+ Issue . record ( " missing action id " ) ; return
158+ }
159+ host. callbacks. invokeVoid ( Int64 ( id) )
160+ #expect( tapped)
161+ }
162+
163+ @Test ( " onAppear and onDisappear emit distinct callback kinds " )
164+ func appearDisappear( ) {
165+ let node = ViewHost ( Text ( " x " ) . onAppear { } . onDisappear { } ) . evaluate ( )
166+ #expect( node. modifiers. contains { $0. kind == " onAppear " } )
167+ #expect( node. modifiers. contains { $0. kind == " onDisappear " } )
168+ }
169+
170+ @Test ( " onChange emits a token describing the observed value " )
171+ func onChange( ) {
172+ let node = ViewHost ( Text ( " x " ) . onChange ( of: 42 ) { } ) . evaluate ( )
173+ let change = node. modifiers. first { $0. kind == " onChange " }
174+ #expect( change? . args [ " token " ] == . string( " 42 " ) )
175+ }
176+
177+ @Test ( " disabled emits its flag " )
178+ func disabled( ) {
179+ let node = ViewHost ( Text ( " x " ) . disabled ( true ) ) . evaluate ( )
180+ let flag = node. modifiers. first { $0. kind == " disabled " }
181+ #expect( flag? . args [ " value " ] == . bool( true ) )
182+ }
149183}
You can’t perform that action at this time.
0 commit comments