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
Fix SandboxClassLoader to obey parent-first contract #2905
Conversation
378f8f9
to
fe9c357
Compare
b5e5fc0
to
697cc52
Compare
Supports PowerMock and experimental Mockito mode which enables mocking final classes/methods. Supports Package.getPackage().
697cc52
to
6b22a72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet, one of the longest running Robolectric issues fixed? :-D
// See https://github.com/robolectric/robolectric/issues/521 | ||
if (name.startsWith("android.R")) { | ||
// android.R and com.android.internal.R classes must be loaded from the framework jar | ||
if (name.matches("(android|com\\.android\\.internal)\\.R(\\$.+)?")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name.startsWith("android.R) || name.startsWith("com.android.internal.R") may be more clear here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're pretty confident there'll never be an android.Riboflavin
or com.android.internal.Roustabout
or something? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think so, although, you can never say never :-D I think this will go away when we check the jar as the source of truth for what to acquire though anyway, so I'm not fussed about this :-)
ReflectionHelpers.setStaticField(androidBuildVersionClass, "SDK_INT", sdkConfig.getApiLevel()); | ||
ReflectionHelpers.setStaticField(androidBuildVersionClass, "RELEASE", sdkConfig.getAndroidVersion()); | ||
|
||
PackageResourceTable systemResourceTable = sdkEnvironment.getSystemResourceTable(getJarResolver()); | ||
PackageResourceTable systemResourceTable = (sdkEnvironment).getSystemResourceTable(getJarResolver()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extraneous parens around (sdkEnvironment) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed!
@@ -107,6 +107,11 @@ public void testVersionConfiguration() { | |||
.isEqualTo("4.4_r1"); | |||
} | |||
|
|||
|
|||
@Test public void assertThatz() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to do this more? I'm guessing that it is checking that things are loaded from the right classloader, but I'm a little confused as its an assert for a primitive rather than an object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the test name. I came across a classloader conflict because org.junit.Assert
loads some hamcrest things.
Dogfood green! :-) |
Yey!! :-)
…On 22 February 2017 at 14:30, Christian Williams ***@***.***> wrote:
Merged #2905 <#2905>.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#2905 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGBaeA6cJm0pTkdmWEgGGYdFKWxIeyWpks5rfLcKgaJpZM4L9_5n>
.
|
Well done. |
@@ -75,8 +75,7 @@ | |||
private final SdkPicker sdkPicker; | |||
private final ConfigMerger configMerger; | |||
|
|||
private TestLifecycle<Application> testLifecycle; | |||
private DependencyResolver dependencyResolver; | |||
private transient DependencyResolver dependencyResolver; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is dependencyResolver transient?
Fixes #2208.
Fixes #2677.