2

Looks like some virtual devices on Google cloud test servers can't execute tests properly because of the Immersive mode confirmation popup (shown here: https://developer.android.com/training/system-ui/immersive.html) - is there a way to automatically close that popup with Espresso? Basically my code works in a local emulator, but not on Google cloud servers. This is what's failing:

View v = activity.getWindow().getDecorView();
v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
stef
  • 161
  • 1
  • 10

3 Answers3

1

I have solved the problem using a similar version of @paul-t. Once the emulator has been started run the next command:

adb shell settings put secure immersive_mode_confirmations confirmed

After that you can execute your Espresso tests.

Inspiration: http://sviatoslavdev.blogspot.com/2018/02/adb-setings-secure.html

jmartinalonso
  • 2,324
  • 1
  • 19
  • 22
0

You can run these ADB commands right after the emulator has started:

adb shell settings put secure immersive_mode_confirmations your.package.com
adb reboot (required)

immersive_mode_confirmations is a comma separated list of packages that no longer need confirmation for immersive mode

Paul T
  • 9
  • 2
0

I found a working solution. It's similar to Paul's answer but is by setting the permission programmatically before your tests run instead of using the ADB. There is a LinkedIn Open Source library that does everything for you, from getting WRITE_SECURE_SETTINGS permissions to changing the need for immersive confirmation dialog dynamically. After setting up the library, use the following line before your test starts:

TestButler.setImmersiveModeConfirmation(false);

For more details and setup instructions go here.

Benny
  • 1,650
  • 17
  • 20