Forked from romainpiel/AccessTokenCreator.java
Last active
February 19, 2020 03:16
-
-
Save kenilt/df29ff41943ed1ca0ba8ae4f85e5ed0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.facebook | |
object AccessTokenCreator { | |
fun createToken(grantedPermissions: Collection<String?>?): AccessToken? { | |
return AccessToken("token", "appId", "userId", grantedPermissions, | |
ArrayList<String>(), null, AccessTokenSource.WEB_VIEW, null, null, null) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.facebook.login | |
import com.facebook.AccessTokenCreator.createToken | |
import com.facebook.login.LoginClient.Request | |
import com.facebook.login.LoginClient.Result | |
internal object LoginClientCreator { | |
fun createRequest(): Request { | |
val permissions: HashSet<String> = hashSetOf("user_actions.music", "user_friends", "user_likes", "email") | |
return Request(LoginBehavior.NATIVE_WITH_FALLBACK, permissions, DefaultAudience.EVERYONE, "authType", "appId", "authId") | |
} | |
fun createResult(): Result? { | |
val request: Request = createRequest() | |
return Result(request, Result.Code.SUCCESS, createToken(request.permissions), null, null) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun signupWithFacebook() { | |
val resultData = Intent() | |
resultData.putExtra("com.facebook.LoginFragment:Result", LoginClientCreator.createResult()) | |
intending(hasComponent(FacebookActivity::class.java.name)) | |
.respondWith(Instrumentation.ActivityResult(Activity.RESULT_OK, resultData)) | |
activityTestRule..launchActivity(Intent()) | |
// click signup fb button | |
onView(withId(R.id.signup_with_facebook_button)).perform(click()) | |
// wait a bit while UI return the mock intent | |
Thread.sleep(1000) | |
// check UI is showing the user as logged in | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment