LoginActivity extends RapidFtrActivity { protected void toggleBaseUrl() { String preferencesUrl = getContext().getSharedPreferences().getString(SERVER_URL_PREF, null); if (preferencesUrl != null && !preferencesUrl.equals("")) { urlView.setText(preferencesUrl); urlView.setVisibility(View.GONE); changeUrlView.setVisibility(View.VISIBLE); } }  @AfterViews void afterCreate(); @Click(R.id.change_url) void onChangeUrlClick(); @Click(R.id.login_button) void onLoginClick(); @Click(R.id.new_user_signup_link) void onSignupClick();  }
@Test public void shouldRestoreServerUrlWhenLoading() { doCallRealMethod().when(loginActivity).toggleBaseUrl(); when(loginActivity.getContext().getSharedPreferences().getString(SERVER_URL_PREF, null)).thenReturn("rapidftr.com:1234"); loginActivity.toggleBaseUrl(); verify(loginActivity.urlView).setText("rapidftr.com:1234"); }