@SuppressFBWarnings("DM_GC") // Used to trigger strictmode detecting leaked closeables
 @Override
 protected void tearDown() throws Exception {
   try {
     NativeTestServer.shutdownNativeTestServer();
     mTestFramework.mCronetEngine.shutdown();
     assertTrue(mFile.delete());
     // Run GC and finalizers a few times to pick up leaked closeables
     for (int i = 0; i < 10; i++) {
       System.gc();
       System.runFinalization();
     }
     System.gc();
     System.runFinalization();
     super.tearDown();
   } finally {
     StrictMode.setVmPolicy(mOldVmPolicy);
   }
 }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   mOldVmPolicy = StrictMode.getVmPolicy();
   StrictMode.setVmPolicy(
       new StrictMode.VmPolicy.Builder()
           .detectLeakedClosableObjects()
           .penaltyLog()
           .penaltyDeath()
           .build());
   mTestFramework = startCronetTestFramework();
   assertTrue(NativeTestServer.startNativeTestServer(getContext()));
   // Add url interceptors after native application context is initialized.
   MockUrlRequestJobFactory.setUp();
   mFile = new File(getContext().getCacheDir().getPath() + "/tmpfile");
   FileOutputStream fileOutputStream = new FileOutputStream(mFile);
   try {
     fileOutputStream.write(LOREM.getBytes("UTF-8"));
   } finally {
     fileOutputStream.close();
   }
 }
Esempio n. 3
0
 @Override
 protected void tearDown() throws Exception {
   NativeTestServer.shutdownNativeTestServer();
   mTestFramework.mCronetEngine.shutdown();
   super.tearDown();
 }
Esempio n. 4
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   mTestFramework = startCronetTestFramework();
   assertTrue(NativeTestServer.startNativeTestServer(getContext()));
 }
Esempio n. 5
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   mActivity = launchCronetTestApp();
   assertTrue(NativeTestServer.startNativeTestServer(getInstrumentation().getTargetContext()));
 }