package de.nenick.espressomacchiato;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.runner.RunWith;

import de.nenick.espressomacchiato.test.views.BaseActivity;

@RunWith(AndroidJUnit4.class)
public abstract class EspressoTestCase {

    @Rule
    public ActivityTestRule<BaseActivity> activityTestRule = new ActivityTestRule<>(BaseActivity.class);

}

@@ -31,16 +31,98 @@
 hiato;%0A%0A
+import android.app.Activity;%0Aimport android.support.test.InstrumentationRegistry;%0A
 import a
@@ -214,16 +214,76 @@
 JUnit4;%0A
+import android.view.WindowManager;%0A%0Aimport org.junit.Before;
 %0Aimport 
@@ -581,10 +581,1443 @@
 lass);%0A%0A
+    @Before%0A    public void setupEspresso() %7B%0A        avoidLockScreen();%0A    %7D%0A%0A    private void avoidLockScreen() %7B%0A        // sometimes tests failed on emulator because lock screen is shown%0A        // java.lang.RuntimeException: Waited for the root of the view hierarchy to have window focus and not be requesting layout for over 10 seconds. If you specified a non default root matcher, it may be picking a root that never takes focus. Otherwise, something is seriously wrong%22%0A        // http://stackoverflow.com/questions/26139070/testui-jenkins-using-espresso%0A        // http://stackoverflow.com/questions/22737476/false-positives-junit-framework-assertionfailederror-edittext-is-not-found%0A        // http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SHOW_WHEN_LOCKED%0A        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                Activity activity = activityTestRule.getActivity();%0A                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);%0A                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);%0A                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);%0A                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);%0A            %7D%0A        %7D);%0A    %7D%0A
 %7D%0A

remove lock screen from emulator