New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support partial AppComponentFactory in Robolectric #8004
Conversation
775b658
to
d80410a
Compare
@hoisie Could you help to review this PR? Thanks. |
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
d80410a
to
2ba53a4
Compare
@hoisie Could you help to give a look at this PR? Thanks. |
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Show resolved
Hide resolved
2ba53a4
to
db9104f
Compare
@hoisie What about this PR? I also want to know whether it can be merged into 4.10. |
Yeah it'll definitely be merged before 4.10. Let me run some validation tests for it right now. |
When I ran this against some tests internally at Google I saw a non-trivial amount of failures. I'll take a closer look at a random sample and see what's going on. |
Just as an FYI, there will have to be some kind of way to enable or disable this feature (e.g. a system property, like |
@hoisie Could you help to provide examples for these edge cases? I can improve the current implementation based on these examples. |
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
db9104f
to
7e506e7
Compare
@hoisie I applied above suggestions, PTAL. |
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
7e506e7
to
b431f46
Compare
@hoisie I applied above suggestions, PTAL. |
shadows/framework/src/main/java/org/robolectric/shadows/ShadowLoadedApk.java
Outdated
Show resolved
Hide resolved
@utzcoz doing another round of tests on this, hopefully we can merge it tomorrow and then release 4.10. |
shadows/framework/src/main/java/org/robolectric/shadows/ShadowLoadedApk.java
Outdated
Show resolved
Hide resolved
@hoisie If you can wait, I can fix some issues of this PR tomorrow(Satuarday, East Eighth District TZ). Otherwise you can release 4.10, and we can port it to 4.10.1. |
robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
Outdated
Show resolved
Hide resolved
b431f46
to
0cbd98f
Compare
Support to use AppComponentFactory in Robolectric from SDK 28. This CL only supports BroadcastReceiver with custom AppComponentFactory. In Robolectric, developers use Robolectric#setupService or Robolectric#buildService to initialize Service instance, and these methods are static, so it's difficult to leverage custom AppComponentFactory to initialize Service instance with custom constructor. And I don't find proper usage scenarios to use custom AppComponentFactory to initialize ContentProvider, Application, Activity and ClassLoader. So I leave them as not implemented state. Signed-off-by: utzcoz <utzcoz@outlook.com>
0cbd98f
to
531507e
Compare
@hoisie Updated, PTAL. |
Support to use
AppComponentFactory
in Robolectric from SDK 28. This PR only supportsBroadcastReceiver
with customAppComponentFactory
. In Robolectric, developers useRobolectric#setupService
orRobolectric#buildService
to initializeService
instance, and these methods are static, so it's difficult to leverage customAppComponentFactory
to initializeService
instance with custom constructor. And I don't find proper usage scenarios to use customAppComponentFactory
to initializeContentProvider
,Application
,Activity
andClassLoader
. So I leave them as not implemented state.Fixes: #7581.