Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java

Issue 2102903004: [Cronet] Unregister NetLog observer during shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/cronet/android/cronet_url_request_context_adapter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import static org.chromium.base.CollectionUtil.newHashSet; 7 import static org.chromium.base.CollectionUtil.newHashSet;
8 8
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.ContextWrapper; 10 import android.content.ContextWrapper;
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 cronetEngine.stopNetLog(); 766 cronetEngine.stopNetLog();
767 assertTrue(file.exists()); 767 assertTrue(file.exists());
768 assertTrue(file.length() != 0); 768 assertTrue(file.length() != 0);
769 assertFalse(hasBytesInNetLog(file)); 769 assertFalse(hasBytesInNetLog(file));
770 assertTrue(file.delete()); 770 assertTrue(file.delete());
771 assertTrue(!file.exists()); 771 assertTrue(!file.exists());
772 } 772 }
773 773
774 @SmallTest 774 @SmallTest
775 @Feature({"Cronet"}) 775 @Feature({"Cronet"})
776 @OnlyRunNativeCronet // No netlogs for pure java impl
777 // Tests that if stopNetLog is not explicity called, CronetEngine.shutdown()
778 // will take care of it. crbug.com/623701.
779 public void testNoStopNetLog() throws Exception {
780 Context context = getContext();
781 File directory = new File(PathUtils.getDataDirectory(context));
782 File file = File.createTempFile("cronet", "json", directory);
783 CronetEngine cronetEngine = new CronetUrlRequestContext(
784 new CronetEngine.Builder(context).setLibraryName("cronet_tests") );
785 cronetEngine.startNetLogToFile(file.getPath(), false);
786
787 // Start a request.
788 TestUrlRequestCallback callback = new TestUrlRequestCallback();
789 UrlRequest.Builder urlRequestBuilder =
790 new UrlRequest.Builder(mUrl, callback, callback.getExecutor(), c ronetEngine);
791 urlRequestBuilder.build().start();
792 callback.blockForDone();
793 // Shut down the engine without calling stopNetLog.
794 cronetEngine.shutdown();
795 assertTrue(file.exists());
796 assertTrue(file.length() != 0);
797 assertFalse(hasBytesInNetLog(file));
798 assertTrue(file.delete());
799 assertTrue(!file.exists());
800 }
801
802 @SmallTest
803 @Feature({"Cronet"})
776 @OnlyRunNativeCronet 804 @OnlyRunNativeCronet
777 // Tests that NetLog contains events emitted by all live CronetEngines. 805 // Tests that NetLog contains events emitted by all live CronetEngines.
778 public void testNetLogContainEventsFromAllLiveEngines() throws Exception { 806 public void testNetLogContainEventsFromAllLiveEngines() throws Exception {
779 Context context = getContext(); 807 Context context = getContext();
780 File directory = new File(PathUtils.getDataDirectory(context)); 808 File directory = new File(PathUtils.getDataDirectory(context));
781 File file1 = File.createTempFile("cronet1", "json", directory); 809 File file1 = File.createTempFile("cronet1", "json", directory);
782 File file2 = File.createTempFile("cronet2", "json", directory); 810 File file2 = File.createTempFile("cronet2", "json", directory);
783 CronetEngine cronetEngine1 = new CronetUrlRequestContext( 811 CronetEngine cronetEngine1 = new CronetUrlRequestContext(
784 new CronetEngine.Builder(context).setLibraryName("cronet_tests") ); 812 new CronetEngine.Builder(context).setLibraryName("cronet_tests") );
785 CronetEngine cronetEngine2 = new CronetUrlRequestContext( 813 CronetEngine cronetEngine2 = new CronetUrlRequestContext(
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 } 1324 }
1297 }.start(); 1325 }.start();
1298 otherThreadDone.block(); 1326 otherThreadDone.block();
1299 builder.build().shutdown(); 1327 builder.build().shutdown();
1300 uiThreadDone.open(); 1328 uiThreadDone.open();
1301 } 1329 }
1302 }); 1330 });
1303 assertTrue(uiThreadDone.block(1000)); 1331 assertTrue(uiThreadDone.block(1000));
1304 } 1332 }
1305 } 1333 }
OLDNEW
« no previous file with comments | « components/cronet/android/cronet_url_request_context_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698