@Test
  public void testClickEmptySpaceOnListUnselectItem() throws InterruptedException {
    accountDb.add(
        "first", "7777777777777777", OtpType.HOTP, null, null, AccountDb.GOOGLE_ISSUER_NAME);

    AuthenticatorActivity activity = activityTestRule.launchActivity(null);

    EmptySpaceClickableDragSortListView userList = activity.findViewById(R.id.user_list);

    assertThat(activity.actionMode).isNull();
    onView(equalTo(userList.getChildAt(0))).perform(longClick());
    assertThat(activity.actionMode).isNotNull();

    Point size = new Point();
    activity.getWindowManager().getDefaultDisplay().getSize(size);
    int height = size.y;
    int width = size.x;

    Instrumentation instr = InstrumentationRegistry.getInstrumentation();
    long downTime = SystemClock.uptimeMillis();
    long eventTime = SystemClock.uptimeMillis();

    instr.sendPointerSync(
        MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, height / 2, width / 2, 0));
    instr.sendPointerSync(
        MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, height / 2, width / 2, 0));

    // We need to delay to wait for the contextual action bar is completely removed.
    Thread.sleep(CLICK_DELAY_INTERVAL);
    assertThat(activity.actionMode).isNull();
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java