Espresso not working with NineOldAndroids animations?

I am trying to test my activity (HomeActivity), which repeats the animation based on the NineOldAndroids lib with Espresso. I turned off system animation as described here , but this does not help, and I get an error message (see below). The only thing that helps is to remove the animation manually. So, the question is, do I need to manually turn off the animation (using BuildConfig seems to be no problem) or maybe I'm doing something wrong? Thank you in advance!

 java.lang.RuntimeException: Could not launch intent Intent {
 act=android.intent.action.MAIN flg=0x14000000
 cmp=com.package.en/com.package.ui.HomeActivity } within 45 seconds.
 Perhaps the main thread has not gone idle within a reasonable amount
 of time? There could be an animation or something constantly
 repainting the screen. Or the activity is doing network calls on
 creation? See the threaddump logs. For your reference the last time
 the event queue was idle before your activity launch request was
 1392052899081 and and now the last time the queue went idle was:
 1392052899081. If these numbers are the same your activity might be hogging the event 
 queue.
+3
source share
2 answers

I don’t know much about 9olddroids, but for Espresso you have to turn off the animation so that your tests become reliable, which you probably already did.

, , , "" , , . , , :

 public void disableAnimations() {
     this.mAnimationsEnabled = false;
 }

, . , :

 public void setUp () {
    super.setUp();
     YourActivity activity = getActivity();
     activity.disableAnimations();
 }

 public void testXYZ() {
     // your test code
 }

, , 9OldDroids Espresso

+1

:

    @Before
    public void setUp() throws Exception {
        super.setUp();
        injectInstrumentation(InstrumentationRegistry.getInstrumentation());
        Intent intent = getIntent();
        if (intent == null) {
            intent = new Intent();
        }
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        setActivityIntent(intent);
    }

    @SuppressLint("NewApi")
    @Override
    public T getActivity() {
        final T activity = super.getActivity();
        activity.overridePendingTransition(0, 0);
        return activity;
    }
Hide result
+3

All Articles