1

I don't find on the Web a way to do automation test for my accessibility service on Android. The official doc of Android give us only few recommendations and a checklist for testing purpose but there's no solution to test what TTS should say or where the accessibility focus should be.

My question is strongly related with this one: Accessibility test automation on Android

Community
  • 1
  • 1
probitaille
  • 1,899
  • 1
  • 19
  • 37
  • 1
    What TTS speaks and where accessibility focus lands are completely independent of the Android framework. They will depend on the accessibility service(s) installed and are thus not something you can reliably test. – alanv Oct 21 '14 at 22:48
  • 1
    They are not completely independant of the Android framework but I understand your point. The problem is that I work on an accessibility service and that's why I want to test it in Android. – probitaille Oct 22 '14 at 14:19
  • Automatic tests should never be relying on for accessibility. They only can test in the neighborhood of 25% of items that should be checked, – Ryan B Oct 22 '14 at 19:16
  • 1
    Gotcha, so you basically want to write end-to-end tests for your accessibility service? We have some set up for TalkBack that basically run an activity in the same process and set up side-channel communication via a static object shared within the process. Not pretty, unfortunately, but it works. I'll see if I can share source code for that... – alanv Oct 22 '14 at 23:36
  • I found some AccessibilityActivityTestCase in Android source code, but I do not know how I can use them. http://bit.ly/1uK66Ri – probitaille Oct 23 '14 at 13:21
  • Recently researched this and answers are in http://stackoverflow.com/questions/22385953/accessibility-test-automation-on-android/41571389#41571389 – Paul Bruce Jan 10 '17 at 14:39

2 Answers2

0

I found a working solution to test my accessibility service.

What I did is import the Android CTS (Compatibility Test Suite) Accessibility Test code in my project that you can find here: AccessibilityService/cts. You will find some useful classes.

BUT, by default, the UiAutomation need to use an accessibility service to do test. You will get errors if you want to do test on your own service. For this, you need to install the CTS APK depending of your android version.

You will find instructions here: CTS setup

With this method, you will see another accessibility service on your Android from which you will be able to do your tests.

Actually, it's not clean but working.

probitaille
  • 1,899
  • 1
  • 19
  • 37
0

You can use adb shell command to automate this.

// disable
adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService

// enable
adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService
J.Adhikari
  • 125
  • 1
  • 13