Merge "Partial cherry-pick to remove IoUtils#deleteContents usage in FrameworksNetTests" into sc-dev
This commit is contained in:
@@ -64,6 +64,7 @@ android_test {
|
|||||||
static_libs: [
|
static_libs: [
|
||||||
"androidx.test.rules",
|
"androidx.test.rules",
|
||||||
"bouncycastle-repackaged-unbundled",
|
"bouncycastle-repackaged-unbundled",
|
||||||
|
"core-tests-support",
|
||||||
"FrameworksNetCommonTests",
|
"FrameworksNetCommonTests",
|
||||||
"frameworks-base-testutils",
|
"frameworks-base-testutils",
|
||||||
"frameworks-net-integration-testutils",
|
"frameworks-net-integration-testutils",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import com.android.frameworks.tests.net.R;
|
|||||||
|
|
||||||
import libcore.io.IoUtils;
|
import libcore.io.IoUtils;
|
||||||
import libcore.io.Streams;
|
import libcore.io.Streams;
|
||||||
|
import libcore.testing.io.TestIoUtils;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -69,10 +70,7 @@ public class NetworkStatsFactoryTest extends NetworkStatsBaseTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mTestProc = new File(InstrumentationRegistry.getContext().getFilesDir(), "proc");
|
mTestProc = TestIoUtils.createTemporaryDirectory("proc");
|
||||||
if (mTestProc.exists()) {
|
|
||||||
IoUtils.deleteContents(mTestProc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The libandroid_servers which have the native method is not available to
|
// The libandroid_servers which have the native method is not available to
|
||||||
// applications. So in order to have a test support native library, the native code
|
// applications. So in order to have a test support native library, the native code
|
||||||
@@ -85,10 +83,6 @@ public class NetworkStatsFactoryTest extends NetworkStatsBaseTest {
|
|||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
mFactory = null;
|
mFactory = null;
|
||||||
|
|
||||||
if (mTestProc.exists()) {
|
|
||||||
IoUtils.deleteContents(mTestProc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ import com.android.server.net.NetworkStatsService.NetworkStatsSettings.Config;
|
|||||||
import com.android.testutils.HandlerUtils;
|
import com.android.testutils.HandlerUtils;
|
||||||
import com.android.testutils.TestableNetworkStatsProviderBinder;
|
import com.android.testutils.TestableNetworkStatsProviderBinder;
|
||||||
|
|
||||||
import libcore.io.IoUtils;
|
import libcore.testing.io.TestIoUtils;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -239,10 +239,7 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
final Context context = InstrumentationRegistry.getContext();
|
final Context context = InstrumentationRegistry.getContext();
|
||||||
mServiceContext = new MockContext(context);
|
mServiceContext = new MockContext(context);
|
||||||
mStatsDir = context.getFilesDir();
|
mStatsDir = TestIoUtils.createTemporaryDirectory(getClass().getSimpleName());
|
||||||
if (mStatsDir.exists()) {
|
|
||||||
IoUtils.deleteContents(mStatsDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
PowerManager powerManager = (PowerManager) mServiceContext.getSystemService(
|
PowerManager powerManager = (PowerManager) mServiceContext.getSystemService(
|
||||||
Context.POWER_SERVICE);
|
Context.POWER_SERVICE);
|
||||||
@@ -311,8 +308,6 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
IoUtils.deleteContents(mStatsDir);
|
|
||||||
|
|
||||||
mServiceContext = null;
|
mServiceContext = null;
|
||||||
mStatsDir = null;
|
mStatsDir = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user