Add a common test library.
This is the most common test library for Connectivity tests. It is meant to be usable in framework tests, network stack tests, CTS, GTS. To achieve that, it can only depend on framework classes. Bug: none Test: NetworkMonitorTest Test: NsdManagerTest Test: ConnectivityServiceTest Test: OffloadControllerTest Test: NetworkStatsObserversTest Test: NetworkStatsServiceTest (all the touched classes) Change-Id: Ic47cbe7ba0e407145fa6bc49bb2adb3c5937dbc4
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package android.net.nsd;
|
||||
|
||||
import static com.android.internal.util.TestUtils.waitForIdleHandler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
@@ -40,6 +38,7 @@ import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.util.AsyncChannel;
|
||||
import com.android.testutils.HandlerUtilsKt;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -74,7 +73,7 @@ public class NsdManagerTest {
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
mServiceHandler.waitForIdle(mTimeoutMs);
|
||||
HandlerUtilsKt.waitForIdle(mServiceHandler, mTimeoutMs);
|
||||
mServiceHandler.chan.disconnect();
|
||||
mServiceHandler.stop();
|
||||
if (mManager != null) {
|
||||
@@ -334,7 +333,7 @@ public class NsdManagerTest {
|
||||
}
|
||||
|
||||
int verifyRequest(int expectedMessageType) {
|
||||
mServiceHandler.waitForIdle(mTimeoutMs);
|
||||
HandlerUtilsKt.waitForIdle(mServiceHandler, mTimeoutMs);
|
||||
verify(mServiceHandler, timeout(mTimeoutMs)).handleMessage(any());
|
||||
reset(mServiceHandler);
|
||||
Message received = mServiceHandler.getLastMessage();
|
||||
@@ -366,10 +365,6 @@ public class NsdManagerTest {
|
||||
lastMessage.copyFrom(msg);
|
||||
}
|
||||
|
||||
void waitForIdle(long timeoutMs) {
|
||||
waitForIdleHandler(this, timeoutMs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
setLastMessage(msg);
|
||||
|
||||
Reference in New Issue
Block a user