Loading services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -33,8 +33,7 @@ import org.junit.Test; * bit FrameworksServicesTests:com.android.server.am.ActivityRecordTests * bit FrameworksServicesTests:com.android.server.am.ActivityRecordTests */ */ @MediumTest @MediumTest // TODO(b/36916522): Currently failing in CI. @Presubmit // @Presubmit @RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class) public class ActivityRecordTests extends ActivityTestsBase { public class ActivityRecordTests extends ActivityTestsBase { private final ComponentName testActivityComponent = private final ComponentName testActivityComponent = Loading services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java +10 −8 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.res.Configuration; import android.content.res.Configuration; import android.graphics.Rect; import android.graphics.Rect; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Looper; import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry; import com.android.server.AttributeCache; import com.android.server.AttributeCache; Loading @@ -34,6 +34,7 @@ import com.android.server.wm.StackWindowController; import com.android.server.wm.WindowManagerService; import com.android.server.wm.WindowManagerService; import com.android.server.wm.WindowTestUtils; import com.android.server.wm.WindowTestUtils; import org.junit.After; import org.junit.Before; import org.junit.Before; import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations; Loading @@ -42,8 +43,7 @@ import org.mockito.MockitoAnnotations; */ */ public class ActivityTestsBase { public class ActivityTestsBase { private final Context mContext = InstrumentationRegistry.getContext(); private final Context mContext = InstrumentationRegistry.getContext(); private static boolean sLooperPrepared; private HandlerThread mHandlerThread; private Handler mHandler; // Grabbing an instance of {@link WindowManagerService} creates it if not present so this must // Grabbing an instance of {@link WindowManagerService} creates it if not present so this must // be called at before any tests. // be called at before any tests. Loading @@ -52,11 +52,13 @@ public class ActivityTestsBase { @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this); mHandlerThread = new HandlerThread("ActivityTestsBaseThread"); if (!sLooperPrepared) { mHandlerThread.start(); sLooperPrepared = true; Looper.prepare(); } } @After public void tearDown() { mHandlerThread.quitSafely(); } } protected ActivityManagerService createActivityManagerService() { protected ActivityManagerService createActivityManagerService() { Loading Loading @@ -126,7 +128,7 @@ public class ActivityTestsBase { @Override @Override protected ActivityStackSupervisor createStackSupervisor() { protected ActivityStackSupervisor createStackSupervisor() { return new TestActivityStackSupervisor(this, new Handler().getLooper()); return new TestActivityStackSupervisor(this, mHandlerThread.getLooper()); } } } } Loading Loading
services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java +1 −2 Original line number Original line Diff line number Diff line Loading @@ -33,8 +33,7 @@ import org.junit.Test; * bit FrameworksServicesTests:com.android.server.am.ActivityRecordTests * bit FrameworksServicesTests:com.android.server.am.ActivityRecordTests */ */ @MediumTest @MediumTest // TODO(b/36916522): Currently failing in CI. @Presubmit // @Presubmit @RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class) public class ActivityRecordTests extends ActivityTestsBase { public class ActivityRecordTests extends ActivityTestsBase { private final ComponentName testActivityComponent = private final ComponentName testActivityComponent = Loading
services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java +10 −8 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; import android.content.res.Configuration; import android.content.res.Configuration; import android.graphics.Rect; import android.graphics.Rect; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Looper; import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry; import com.android.server.AttributeCache; import com.android.server.AttributeCache; Loading @@ -34,6 +34,7 @@ import com.android.server.wm.StackWindowController; import com.android.server.wm.WindowManagerService; import com.android.server.wm.WindowManagerService; import com.android.server.wm.WindowTestUtils; import com.android.server.wm.WindowTestUtils; import org.junit.After; import org.junit.Before; import org.junit.Before; import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations; Loading @@ -42,8 +43,7 @@ import org.mockito.MockitoAnnotations; */ */ public class ActivityTestsBase { public class ActivityTestsBase { private final Context mContext = InstrumentationRegistry.getContext(); private final Context mContext = InstrumentationRegistry.getContext(); private static boolean sLooperPrepared; private HandlerThread mHandlerThread; private Handler mHandler; // Grabbing an instance of {@link WindowManagerService} creates it if not present so this must // Grabbing an instance of {@link WindowManagerService} creates it if not present so this must // be called at before any tests. // be called at before any tests. Loading @@ -52,11 +52,13 @@ public class ActivityTestsBase { @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this); mHandlerThread = new HandlerThread("ActivityTestsBaseThread"); if (!sLooperPrepared) { mHandlerThread.start(); sLooperPrepared = true; Looper.prepare(); } } @After public void tearDown() { mHandlerThread.quitSafely(); } } protected ActivityManagerService createActivityManagerService() { protected ActivityManagerService createActivityManagerService() { Loading Loading @@ -126,7 +128,7 @@ public class ActivityTestsBase { @Override @Override protected ActivityStackSupervisor createStackSupervisor() { protected ActivityStackSupervisor createStackSupervisor() { return new TestActivityStackSupervisor(this, new Handler().getLooper()); return new TestActivityStackSupervisor(this, mHandlerThread.getLooper()); } } } } Loading