Merge "Stop the created handler threads" into main

This commit is contained in:
Chiachang Wang
2023-08-17 09:40:05 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 0 deletions

View File

@@ -367,6 +367,10 @@ public class AutomaticOnOffKeepaliveTrackerTest {
@After
public void teardown() throws Exception {
TestKeepaliveInfo.closeAllSockets();
if (mHandlerThread != null) {
mHandlerThread.quitSafely();
mHandlerThread.join();
}
}
private final class AOOTestHandler extends Handler {

View File

@@ -67,6 +67,7 @@ import com.android.testutils.DevSdkIgnoreRule;
import com.android.testutils.DevSdkIgnoreRunner;
import com.android.testutils.HandlerUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -240,6 +241,14 @@ public class KeepaliveStatsTrackerTest {
HandlerUtils.waitForIdle(mTestHandler, TIMEOUT_MS);
}
@After
public void tearDown() throws Exception {
if (mHandlerThread != null) {
mHandlerThread.quitSafely();
mHandlerThread.join();
}
}
private void setElapsedRealtime(long time) {
doReturn(time).when(mDependencies).getElapsedRealtime();
}