BaseOAuthFragment extends Fragment { protected boolean processPageFinished(String url, boolean authComplete) { if (url.contains("?code=") && !authComplete) { Uri uri = Uri.parse(url); String authCode = uri.getQueryParameter("code"); Log.v(TAG, "auth code: " + authCode); getTokenAsyncTask(authCode).execute(); authComplete = true; } else if (url.contains("error=access_denied")){ Log.v(TAG, "ACCESS_DENIED_HERE"); Toast.makeText(getActivity(), getString(R.string.auth_failed), Toast.LENGTH_SHORT).show(); new Handler().postDelayed(new Runnable() { @Override public void run() { getActivity().finish(); } }, 500); authComplete = true; } return authComplete; }  @Override View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState); WebViewClient getWebViewClient(); TokenGet getTokenAsyncTask(String authCode); @Override void onStart(); void superOnStart(); void startLogin(); String buildLoginUrl(); void finishAuthorization(); abstract String getLoginUrl(); abstract String getScope(); abstract String getTokenUrl(); abstract String getClientId(); abstract String getClientSecret(); abstract String getRedirectUri(); abstract String getGrantType(); abstract void saveAuthToken(String authToken, long expire, String refreshToken, String userId); public WebView loginWebView; }
@Test public void test_processPageFinished_nothing() { boolean finished = fragment.processPageFinished("https: assertFalse(finished); }
@Test public void test_processPageFinished_alreadyDone() { boolean finished = fragment.processPageFinished("https: assertTrue(finished); }
@Test public void test_processPageFinished_error() { boolean finished = fragment.processPageFinished("https: assertTrue(finished); }