Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, Robolectric enabled some of its instrumentation on interfaces in order to support hooking up interceptors on default interface methods. This is because there are now some default interface methods that invoke System.logW (e.g. android.compat.Compatibility$BehaviorChangeDelegate) However, the instrumentation step that makes classes public was also applied to interfaces, and this seems to confuse Mockito/ByteBuddy, but only in certain environments. As a fix, restrict the instrumentation to only rewrite interface method bodies, as well as extends 'InstrumentedInterface', so Robolectric does not re-instrument interfaces when the preinstrumented jars are used. A test case will be added after the preinstrumented jar version is bumped. Fixes #6858 PiperOrigin-RevId: 410440888
- Loading branch information
1 parent
326991f
commit e03710c
Showing
21 changed files
with
267 additions
and
101 deletions.
There are no files selected for viewing
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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
...tric/src/test/java/org/robolectric/android/controller/ActivityControllerRecreateTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.robolectric.android.controller; | ||
|
||
import android.app.Activity; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.Robolectric; | ||
|
||
/** | ||
* This test captures an issue where {@link ActivityController#recreate()} would throw an {@link | ||
* UnsupportedOperationException} if an Activity from a previous test was recreated. | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ActivityControllerRecreateTest { | ||
private static final AtomicReference<ActivityController<Activity>> createdActivity = | ||
new AtomicReference<>(); | ||
|
||
@Before | ||
public void setUp() { | ||
createdActivity.compareAndSet(null, Robolectric.buildActivity(Activity.class).create()); | ||
} | ||
|
||
@Test | ||
public void failsTryingToRecreateActivityFromOtherTest1() { | ||
createdActivity.get().recreate(); | ||
} | ||
|
||
@Test | ||
public void failsTryingToRecreateActivityFromOtherTest2() { | ||
createdActivity.get().recreate(); | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.