facebook-android-sdk
facebook-android-sdk copied to clipboard
Feature Request: Expose public constructors for Facebook Login Request/Result
Checklist before submitting a feature request
- [X] I've updated to the latest released version of the SDK
- [X] I've searched for existing Github issues
- [X] I've read the Code of Conduct
Goals
We're running UI tests in which we mock the request/result of facebook login using Espresso intents so we can test success/error scenarios
Previously the request result classes had public constructors which allowed us to easily do this, but in the conversion to kotlin, it looks like they've been made internal.
Is there a reason these were made internal as part of the conversion? It would be great if they could be made public again. 🙏🏽
Expected results
We expect to be able to stub the request/result classes of login to allow us to meaningfully test our UI code, without using real facebook SDK login request/results objects.
Code samples & details
// Example of what we were able to do prior to 13.2.0, but doesn't work in recent SDK versions (>= 13.2.0)
fun givenFacebookLoginReturnsSuccess() {
intending(hasComponent(FacebookActivity::class.java.name))
.respondWith(ActivityResult(RESULT_OK, createFacebookSuccessResultIntent()))
}
fun givenFacebookLoginReturnsError() {
intending(hasComponent(FacebookActivity::class.java.name))
.respondWith(ActivityResult(RESULT_OK, createFacebookErrorResultIntent()))
}
fun createFacebookSuccessResultIntent(): Intent = Intent().apply {
putExtra("com.facebook.LoginFragment:Result", successResult)
}
fun createFacebookErrorResultIntent(): Intent = Intent().apply {
putExtra("com.facebook.LoginFragment:Result", errorResult)
}
private val successResult = Result(
request,
SUCCESS,
token,
null,
null
)
private val errorResult = Result(
request,
ERROR,
token,
null,
null
)
Should point out that this is blocking us from upgrading from 12.3.0