summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/AsyncUserVisibilityListener.java3
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java31
2 files changed, 10 insertions, 24 deletions
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/AsyncUserVisibilityListener.java b/services/tests/mockingservicestests/src/com/android/server/pm/AsyncUserVisibilityListener.java
index 1a4a7bd4ff72..afcedd6f41bf 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/AsyncUserVisibilityListener.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/AsyncUserVisibilityListener.java
@@ -40,7 +40,8 @@ public final class AsyncUserVisibilityListener implements UserVisibilityListener
private static final String TAG = AsyncUserVisibilityListener.class.getSimpleName();
private static final long WAIT_TIMEOUT_MS = 2_000;
- private static final long WAIT_NO_EVENTS_TIMEOUT_MS = 1_000;
+
+ private static final long WAIT_NO_EVENTS_TIMEOUT_MS = 100;
private static int sNextId;
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java b/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java
index 17ee90927977..6ceb38adf875 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java
@@ -36,16 +36,14 @@ import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assert.assertThrows;
import android.annotation.UserIdInt;
-import android.os.HandlerThread;
+import android.os.Handler;
import android.util.IntArray;
import android.util.Log;
import com.android.internal.util.Preconditions;
import com.android.server.ExtendedMockitoTestCase;
-import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import java.util.Arrays;
@@ -103,10 +101,8 @@ abstract class UserVisibilityMediatorTestCase extends ExtendedMockitoTestCase {
protected static final boolean FG = true;
protected static final boolean BG = false;
- private static final HandlerThread sHandlerThread = new HandlerThread(TAG);
-
- protected final AsyncUserVisibilityListener.Factory mListenerFactory =
- new AsyncUserVisibilityListener.Factory(mExpect, sHandlerThread);
+ private Handler mHandler;
+ protected AsyncUserVisibilityListener.Factory mListenerFactory;
private final boolean mUsersOnSecondaryDisplaysEnabled;
@@ -116,24 +112,13 @@ abstract class UserVisibilityMediatorTestCase extends ExtendedMockitoTestCase {
mUsersOnSecondaryDisplaysEnabled = usersOnSecondaryDisplaysEnabled;
}
- @BeforeClass
- public static final void startHandlerThread() {
- Log.d(TAG, "Starting handler thread " + sHandlerThread);
- sHandlerThread.start();
- }
-
- @AfterClass
- public static final void quitHandlerThread() {
- Log.d(TAG, "Quitting handler thread " + sHandlerThread);
- if (!sHandlerThread.quit()) {
- Log.w(TAG, "sHandlerThread(" + sHandlerThread + ").quit() returned false");
- }
- }
-
@Before
public final void setFixtures() {
- mMediator = new UserVisibilityMediator(mUsersOnSecondaryDisplaysEnabled,
- sHandlerThread.getThreadHandler());
+ mHandler = Handler.getMain();
+ Thread thread = mHandler.getLooper().getThread();
+ Log.i(TAG, "setFixtures(): using thread " + thread + " (from handler " + mHandler + ")");
+ mListenerFactory = new AsyncUserVisibilityListener.Factory(mExpect, thread);
+ mMediator = new UserVisibilityMediator(mUsersOnSecondaryDisplaysEnabled, mHandler);
mDumpableDumperRule.addDumpable(mMediator);
}