feat(TestHint): add 'onPress' property

Allows to bind a click handler to a TestHint.

When a mobile test wants to click an UI element it must be able to
locate it through the accessibility layer. Now the problem with that is
that there is currently no uniform way for finding element on both iOS
and Android. This problem is solved by TestHint component which takes
an id parameter which then can be specified in the corresponding java
TestHint class in jitsi-meet-torture to easily find it. By being able to
add a click handler to a TestHint, it's possible to duplicate original
handler under nested TestHint and then find it easily on the torture
side.
This commit is contained in:
paweldomas 2018-04-18 13:15:01 -05:00 committed by Дамян Минков
parent adec8e6438
commit 6931b8f2fb
3 changed files with 10 additions and 1 deletions

View File

@ -25,6 +25,12 @@ export type TestHintProps = {
*/ */
id: string, id: string,
/**
* The optional "on press" handler which can be used to bind a click handler
* to a {@link TestHint}.
*/
onPress: ?Function,
/** /**
* The test hint's (text) value which is to be consumed by the tests. * The test hint's (text) value which is to be consumed by the tests.
*/ */

View File

@ -37,7 +37,9 @@ class TestHint extends Component<TestHintProps> {
} }
return ( return (
<Text accessibilityLabel = { this.props.id } > <Text
accessibilityLabel = { this.props.id }
onPress = { this.props.onPress } >
{ this.props.value } { this.props.value }
</Text> </Text>
); );

View File

@ -28,6 +28,7 @@ class TestHint extends Component<TestHintProps> {
return ( return (
<Text <Text
accessibilityLabel = { this.props.value } accessibilityLabel = { this.props.value }
onPress = { this.props.onPress }
testID = { this.props.id } /> testID = { this.props.id } />
); );
} }