You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestHint.android.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { Text } from 'react-native';
  4. import { connect } from '../../redux';
  5. import type { TestHintProps } from './AbstractTestHint';
  6. import { _mapStateToProps } from './AbstractTestHint';
  7. /**
  8. * The Android version of <code>TestHint</code>. It will put the identifier,
  9. * as the 'accessibilityLabel'.
  10. *
  11. * FIXME The 'testID' attribute (which is used on iOS) does not work with
  12. * the react-native as expected, because is mapped to component's tag instead of
  13. * any attribute visible to the UI automation. Because of that it can not be
  14. * used to find the element.
  15. * On the other hand it's not possible to use 'accessibilityLabel' on the iOS
  16. * for the id purpose, because it will merge the value with any text content or
  17. * 'accessibilityLabel' values of it's children. So as a workaround a TestHint
  18. * class was introduced in 'jitsi-meet-torture' which will accept generic 'id'
  19. * attribute and then do the search 'under the hood' either by the accessibility
  20. * label or the id, depending on the participant's platform. On the client side
  21. * the TestHint class is to be the abstraction layer which masks the problem by
  22. * exposing id and value properties.
  23. */
  24. class TestHint extends Component<TestHintProps> {
  25. /**
  26. * Renders the test hint on Android.
  27. *
  28. * @returns {ReactElement}
  29. */
  30. render() {
  31. if (!this.props._testModeEnabled) {
  32. return null;
  33. }
  34. return (
  35. <Text
  36. accessibilityLabel = { this.props.id }
  37. onPress = { this.props.onPress } >
  38. { this.props.value }
  39. </Text>
  40. );
  41. }
  42. }
  43. export default connect(_mapStateToProps)(TestHint);