@Test
  public void testReorderAccounts() {
    accountDb.add(
        "first", "7777777777777777", OtpType.HOTP, null, null, AccountDb.GOOGLE_ISSUER_NAME);
    accountDb.add("second", "6666666666666666", OtpType.TOTP, null, null, null);
    accountDb.add("third", "5555555555555555", OtpType.TOTP, null, null, "Yahoo");

    activityTestRule.launchActivity(null);

    EmptySpaceClickableDragSortListView userList =
        activityTestRule.getActivity().findViewById(R.id.user_list);
    View firstView = userList.getChildAt(0);
    View thirdView = userList.getChildAt(2);
    View firstDragHandle = firstView.findViewById(R.id.user_row_drag_handle);
    View thirdDragHandle = thirdView.findViewById(R.id.user_row_drag_handle);
    int dragHandleWidth = firstDragHandle.getWidth();
    int dragHandleHeight = firstDragHandle.getHeight();
    int[] firstDragHandleLocation = new int[2];
    int[] thirdDragHandleLocation = new int[2];
    firstDragHandle.getLocationOnScreen(firstDragHandleLocation);
    thirdDragHandle.getLocationOnScreen(thirdDragHandleLocation);
    float fromX = firstDragHandleLocation[0] + (dragHandleWidth / 2.0f);
    float fromY = firstDragHandleLocation[1] + (dragHandleHeight / 2.0f);
    float toX = thirdDragHandleLocation[0] + (dragHandleWidth / 2.0f);
    float toY = thirdDragHandleLocation[1] + (dragHandleHeight / 2.0f);

    onView(equalTo(firstView))
        .perform(longClick())
        .perform(
            new GeneralSwipeAction(
                Swipe.SLOW,
                (view) -> {
                  return new float[] {fromX, fromY};
                },
                (view) -> {
                  return new float[] {toX, toY};
                },
                Press.FINGER));

    ListAdapter listAdapter = userList.getAdapter();
    PinInfo firstPinInfo = (PinInfo) listAdapter.getItem(0);
    PinInfo secondPinInfo = (PinInfo) listAdapter.getItem(1);
    PinInfo thirdPinInfo = (PinInfo) listAdapter.getItem(2);
    assertThat(firstPinInfo.getIndex().getName()).isEqualTo("second");
    assertThat(secondPinInfo.getIndex().getName()).isEqualTo("third");
    assertThat(thirdPinInfo.getIndex().getName()).isEqualTo("first");
  }
Unit tests for {@link AuthenticatorActivity} (part/shard 1).
javatests/com/google/android/apps/authenticator/AuthenticatorActivityTest.java