GoogleAccountsManager { @NonNull public String getLastSelectedAccountIfValid() { Account[] googleAccounts = credential.getAllAccounts(); String account = (String) preferences.get(GeneralKeys.KEY_SELECTED_GOOGLE_ACCOUNT); if (googleAccounts != null && googleAccounts.length > 0) { for (Account googleAccount : googleAccounts) { if (googleAccount.name.equals(account)) { return account; } } preferences.reset(GeneralKeys.KEY_SELECTED_GOOGLE_ACCOUNT); } return ""; } @Inject  GoogleAccountsManager(@NonNull Context context);  GoogleAccountsManager(@NonNull GoogleAccountCredential credential,
                                 @NonNull GeneralSharedPreferences preferences,
                                 @NonNull Intent intentChooseAccount,
                                 @NonNull ThemeUtils themeUtils
    ); static void showSettingsDialog(Activity activity); boolean isAccountSelected(); @NonNull String getLastSelectedAccountIfValid(); void selectAccount(String accountName); DriveHelper getDriveHelper(); SheetsHelper getSheetsHelper(); String getToken(); Intent getAccountChooserIntent();  }
@Test public void getGoogleAccountNameIfAccountNameIsSavedTest() { stubSavedAccount(EXPECTED_ACCOUNT); assertEquals(EXPECTED_ACCOUNT, googleAccountsManager.getLastSelectedAccountIfValid()); }
@Test public void returnNullWhenAccountIsDeleted() { stubSavedAccount(EXPECTED_ACCOUNT); assertEquals(EXPECTED_ACCOUNT, googleAccountsManager.getLastSelectedAccountIfValid()); removeAccounts(); assertEquals(googleAccountsManager.getLastSelectedAccountIfValid(), ""); assertNull(savedAccount); }
@Test public void returnBlankWhenAccountNameIsNotSaved() { stubSavedAccount("some_other_email"); stubAccount(EXPECTED_ACCOUNT); assertEquals("", googleAccountsManager.getLastSelectedAccountIfValid()); assertNull(currentAccount); }