| OLD | NEW |
| 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 android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.ContextWrapper; | 8 import android.content.ContextWrapper; |
| 9 import android.os.ConditionVariable; | 9 import android.os.ConditionVariable; |
| 10 import android.os.Handler; | 10 import android.os.Handler; |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 testFramework.mCronetEngine.shutdown(); | 538 testFramework.mCronetEngine.shutdown(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 @SmallTest | 541 @SmallTest |
| 542 @Feature({"Cronet"}) | 542 @Feature({"Cronet"}) |
| 543 @OnlyRunNativeCronet // No netlogs for pure java impl | 543 @OnlyRunNativeCronet // No netlogs for pure java impl |
| 544 public void testNetLog() throws Exception { | 544 public void testNetLog() throws Exception { |
| 545 Context context = getContext(); | 545 Context context = getContext(); |
| 546 File directory = new File(PathUtils.getDataDirectory()); | 546 File directory = new File(PathUtils.getDataDirectory()); |
| 547 File file = File.createTempFile("cronet", "json", directory); | 547 File file = File.createTempFile("cronet", "json", directory); |
| 548 CronetEngine cronetEngine = | 548 CronetEngine cronetEngine = new CronetEngine.Builder(context).build(); |
| 549 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | |
| 550 // Start NetLog immediately after the request context is created to make | 549 // Start NetLog immediately after the request context is created to make |
| 551 // sure that the call won't crash the app even when the native request | 550 // sure that the call won't crash the app even when the native request |
| 552 // context is not fully initialized. See crbug.com/470196. | 551 // context is not fully initialized. See crbug.com/470196. |
| 553 cronetEngine.startNetLogToFile(file.getPath(), false); | 552 cronetEngine.startNetLogToFile(file.getPath(), false); |
| 554 | 553 |
| 555 // Start a request. | 554 // Start a request. |
| 556 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 555 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 557 UrlRequest.Builder urlRequestBuilder = | 556 UrlRequest.Builder urlRequestBuilder = |
| 558 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); | 557 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); |
| 559 urlRequestBuilder.build().start(); | 558 urlRequestBuilder.build().start(); |
| 560 callback.blockForDone(); | 559 callback.blockForDone(); |
| 561 cronetEngine.stopNetLog(); | 560 cronetEngine.stopNetLog(); |
| 562 assertTrue(file.exists()); | 561 assertTrue(file.exists()); |
| 563 assertTrue(file.length() != 0); | 562 assertTrue(file.length() != 0); |
| 564 assertFalse(hasBytesInNetLog(file)); | 563 assertFalse(hasBytesInNetLog(file)); |
| 565 assertTrue(file.delete()); | 564 assertTrue(file.delete()); |
| 566 assertTrue(!file.exists()); | 565 assertTrue(!file.exists()); |
| 567 } | 566 } |
| 568 | 567 |
| 569 @SmallTest | 568 @SmallTest |
| 570 @Feature({"Cronet"}) | 569 @Feature({"Cronet"}) |
| 571 @OnlyRunNativeCronet // No netlogs for pure java impl | 570 @OnlyRunNativeCronet // No netlogs for pure java impl |
| 572 public void testBoundedFileNetLog() throws Exception { | 571 public void testBoundedFileNetLog() throws Exception { |
| 573 Context context = getContext(); | 572 Context context = getContext(); |
| 574 File directory = new File(PathUtils.getDataDirectory()); | 573 File directory = new File(PathUtils.getDataDirectory()); |
| 575 File netLogDir = new File(directory, "NetLog"); | 574 File netLogDir = new File(directory, "NetLog"); |
| 576 assertFalse(netLogDir.exists()); | 575 assertFalse(netLogDir.exists()); |
| 577 assertTrue(netLogDir.mkdir()); | 576 assertTrue(netLogDir.mkdir()); |
| 578 File eventFile = new File(netLogDir, "event_file_0.json"); | 577 File eventFile = new File(netLogDir, "event_file_0.json"); |
| 579 CronetUrlRequestContext cronetEngine = | 578 ExperimentalCronetEngine cronetEngine = |
| 580 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | 579 new ExperimentalCronetEngine.Builder(context).build(); |
| 581 // Start NetLog immediately after the request context is created to make | 580 // Start NetLog immediately after the request context is created to make |
| 582 // sure that the call won't crash the app even when the native request | 581 // sure that the call won't crash the app even when the native request |
| 583 // context is not fully initialized. See crbug.com/470196. | 582 // context is not fully initialized. See crbug.com/470196. |
| 584 cronetEngine.startNetLogToDisk(netLogDir.getPath(), false, MAX_FILE_SIZE
); | 583 cronetEngine.startNetLogToDisk(netLogDir.getPath(), false, MAX_FILE_SIZE
); |
| 585 | 584 |
| 586 // Start a request. | 585 // Start a request. |
| 587 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 586 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 588 UrlRequest.Builder urlRequestBuilder = | 587 UrlRequest.Builder urlRequestBuilder = |
| 589 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); | 588 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); |
| 590 urlRequestBuilder.build().start(); | 589 urlRequestBuilder.build().start(); |
| 591 callback.blockForDone(); | 590 callback.blockForDone(); |
| 592 cronetEngine.stopNetLog(); | 591 cronetEngine.stopNetLog(); |
| 593 assertTrue(eventFile.exists()); | 592 assertTrue(eventFile.exists()); |
| 594 assertTrue(eventFile.length() != 0); | 593 assertTrue(eventFile.length() != 0); |
| 595 assertFalse(hasBytesInNetLog(eventFile)); | 594 assertFalse(hasBytesInNetLog(eventFile)); |
| 596 FileUtils.recursivelyDeleteFile(netLogDir); | 595 FileUtils.recursivelyDeleteFile(netLogDir); |
| 597 assertFalse(netLogDir.exists()); | 596 assertFalse(netLogDir.exists()); |
| 598 } | 597 } |
| 599 | 598 |
| 600 @SmallTest | 599 @SmallTest |
| 601 @Feature({"Cronet"}) | 600 @Feature({"Cronet"}) |
| 602 @OnlyRunNativeCronet // No netlogs for pure java impl | 601 @OnlyRunNativeCronet // No netlogs for pure java impl |
| 603 // Tests that if stopNetLog is not explicity called, CronetEngine.shutdown() | 602 // Tests that if stopNetLog is not explicity called, CronetEngine.shutdown() |
| 604 // will take care of it. crbug.com/623701. | 603 // will take care of it. crbug.com/623701. |
| 605 public void testNoStopNetLog() throws Exception { | 604 public void testNoStopNetLog() throws Exception { |
| 606 Context context = getContext(); | 605 Context context = getContext(); |
| 607 File directory = new File(PathUtils.getDataDirectory()); | 606 File directory = new File(PathUtils.getDataDirectory()); |
| 608 File file = File.createTempFile("cronet", "json", directory); | 607 File file = File.createTempFile("cronet", "json", directory); |
| 609 CronetUrlRequestContext cronetEngine = | 608 CronetEngine cronetEngine = new CronetEngine.Builder(context).build(); |
| 610 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | |
| 611 cronetEngine.startNetLogToFile(file.getPath(), false); | 609 cronetEngine.startNetLogToFile(file.getPath(), false); |
| 612 | 610 |
| 613 // Start a request. | 611 // Start a request. |
| 614 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 612 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 615 UrlRequest.Builder urlRequestBuilder = | 613 UrlRequest.Builder urlRequestBuilder = |
| 616 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); | 614 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); |
| 617 urlRequestBuilder.build().start(); | 615 urlRequestBuilder.build().start(); |
| 618 callback.blockForDone(); | 616 callback.blockForDone(); |
| 619 // Shut down the engine without calling stopNetLog. | 617 // Shut down the engine without calling stopNetLog. |
| 620 cronetEngine.shutdown(); | 618 cronetEngine.shutdown(); |
| 621 assertTrue(file.exists()); | 619 assertTrue(file.exists()); |
| 622 assertTrue(file.length() != 0); | 620 assertTrue(file.length() != 0); |
| 623 assertFalse(hasBytesInNetLog(file)); | 621 assertFalse(hasBytesInNetLog(file)); |
| 624 assertTrue(file.delete()); | 622 assertTrue(file.delete()); |
| 625 assertTrue(!file.exists()); | 623 assertTrue(!file.exists()); |
| 626 } | 624 } |
| 627 | 625 |
| 628 @SmallTest | 626 @SmallTest |
| 629 @Feature({"Cronet"}) | 627 @Feature({"Cronet"}) |
| 630 @OnlyRunNativeCronet // No netlogs for pure java impl | 628 @OnlyRunNativeCronet // No netlogs for pure java impl |
| 631 // Tests that if stopNetLog is not explicity called, CronetEngine.shutdown() | 629 // Tests that if stopNetLog is not explicity called, CronetEngine.shutdown() |
| 632 // will take care of it. crbug.com/623701. | 630 // will take care of it. crbug.com/623701. |
| 633 public void testNoStopBoundedFileNetLog() throws Exception { | 631 public void testNoStopBoundedFileNetLog() throws Exception { |
| 634 Context context = getContext(); | 632 Context context = getContext(); |
| 635 File directory = new File(PathUtils.getDataDirectory()); | 633 File directory = new File(PathUtils.getDataDirectory()); |
| 636 File netLogDir = new File(directory, "NetLog"); | 634 File netLogDir = new File(directory, "NetLog"); |
| 637 assertFalse(netLogDir.exists()); | 635 assertFalse(netLogDir.exists()); |
| 638 assertTrue(netLogDir.mkdir()); | 636 assertTrue(netLogDir.mkdir()); |
| 639 File eventFile = new File(netLogDir, "event_file_0.json"); | 637 File eventFile = new File(netLogDir, "event_file_0.json"); |
| 640 CronetUrlRequestContext cronetEngine = | 638 ExperimentalCronetEngine cronetEngine = |
| 641 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | 639 new ExperimentalCronetEngine.Builder(context).build(); |
| 642 cronetEngine.startNetLogToDisk(netLogDir.getPath(), false, MAX_FILE_SIZE
); | 640 cronetEngine.startNetLogToDisk(netLogDir.getPath(), false, MAX_FILE_SIZE
); |
| 643 | 641 |
| 644 // Start a request. | 642 // Start a request. |
| 645 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 643 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 646 UrlRequest.Builder urlRequestBuilder = | 644 UrlRequest.Builder urlRequestBuilder = |
| 647 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); | 645 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); |
| 648 urlRequestBuilder.build().start(); | 646 urlRequestBuilder.build().start(); |
| 649 callback.blockForDone(); | 647 callback.blockForDone(); |
| 650 // Shut down the engine without calling stopNetLog. | 648 // Shut down the engine without calling stopNetLog. |
| 651 cronetEngine.shutdown(); | 649 cronetEngine.shutdown(); |
| 652 assertTrue(eventFile.exists()); | 650 assertTrue(eventFile.exists()); |
| 653 assertTrue(eventFile.length() != 0); | 651 assertTrue(eventFile.length() != 0); |
| 654 | 652 |
| 655 FileUtils.recursivelyDeleteFile(netLogDir); | 653 FileUtils.recursivelyDeleteFile(netLogDir); |
| 656 assertFalse(netLogDir.exists()); | 654 assertFalse(netLogDir.exists()); |
| 657 } | 655 } |
| 658 | 656 |
| 659 @SmallTest | 657 @SmallTest |
| 660 @Feature({"Cronet"}) | 658 @Feature({"Cronet"}) |
| 661 @OnlyRunNativeCronet | 659 @OnlyRunNativeCronet |
| 662 // Tests that NetLog contains events emitted by all live CronetEngines. | 660 // Tests that NetLog contains events emitted by all live CronetEngines. |
| 663 public void testNetLogContainEventsFromAllLiveEngines() throws Exception { | 661 public void testNetLogContainEventsFromAllLiveEngines() throws Exception { |
| 664 Context context = getContext(); | 662 Context context = getContext(); |
| 665 File directory = new File(PathUtils.getDataDirectory()); | 663 File directory = new File(PathUtils.getDataDirectory()); |
| 666 File file1 = File.createTempFile("cronet1", "json", directory); | 664 File file1 = File.createTempFile("cronet1", "json", directory); |
| 667 File file2 = File.createTempFile("cronet2", "json", directory); | 665 File file2 = File.createTempFile("cronet2", "json", directory); |
| 668 CronetEngine cronetEngine1 = | 666 CronetEngine cronetEngine1 = new CronetEngine.Builder(context).build(); |
| 669 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | 667 CronetEngine cronetEngine2 = new CronetEngine.Builder(context).build(); |
| 670 CronetEngine cronetEngine2 = | |
| 671 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | |
| 672 | 668 |
| 673 cronetEngine1.startNetLogToFile(file1.getPath(), false); | 669 cronetEngine1.startNetLogToFile(file1.getPath(), false); |
| 674 cronetEngine2.startNetLogToFile(file2.getPath(), false); | 670 cronetEngine2.startNetLogToFile(file2.getPath(), false); |
| 675 | 671 |
| 676 // Warm CronetEngine and make sure both CronetUrlRequestContexts are | 672 // Warm CronetEngine and make sure both CronetUrlRequestContexts are |
| 677 // initialized before testing the logs. | 673 // initialized before testing the logs. |
| 678 makeRequestAndCheckStatus(cronetEngine1, mUrl, 200); | 674 makeRequestAndCheckStatus(cronetEngine1, mUrl, 200); |
| 679 makeRequestAndCheckStatus(cronetEngine2, mUrl, 200); | 675 makeRequestAndCheckStatus(cronetEngine2, mUrl, 200); |
| 680 | 676 |
| 681 // Use cronetEngine1 to make a request to mUrl404. | 677 // Use cronetEngine1 to make a request to mUrl404. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 707 File directory = new File(PathUtils.getDataDirectory()); | 703 File directory = new File(PathUtils.getDataDirectory()); |
| 708 File netLogDir1 = new File(directory, "NetLog1"); | 704 File netLogDir1 = new File(directory, "NetLog1"); |
| 709 assertFalse(netLogDir1.exists()); | 705 assertFalse(netLogDir1.exists()); |
| 710 assertTrue(netLogDir1.mkdir()); | 706 assertTrue(netLogDir1.mkdir()); |
| 711 File netLogDir2 = new File(directory, "NetLog2"); | 707 File netLogDir2 = new File(directory, "NetLog2"); |
| 712 assertFalse(netLogDir2.exists()); | 708 assertFalse(netLogDir2.exists()); |
| 713 assertTrue(netLogDir2.mkdir()); | 709 assertTrue(netLogDir2.mkdir()); |
| 714 File eventFile1 = new File(netLogDir1, "event_file_0.json"); | 710 File eventFile1 = new File(netLogDir1, "event_file_0.json"); |
| 715 File eventFile2 = new File(netLogDir2, "event_file_0.json"); | 711 File eventFile2 = new File(netLogDir2, "event_file_0.json"); |
| 716 | 712 |
| 717 CronetUrlRequestContext cronetEngine1 = | 713 ExperimentalCronetEngine cronetEngine1 = |
| 718 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | 714 new ExperimentalCronetEngine.Builder(context).build(); |
| 719 CronetUrlRequestContext cronetEngine2 = | 715 ExperimentalCronetEngine cronetEngine2 = |
| 720 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | 716 new ExperimentalCronetEngine.Builder(context).build(); |
| 721 | 717 |
| 722 cronetEngine1.startNetLogToDisk(netLogDir1.getPath(), false, MAX_FILE_SI
ZE); | 718 cronetEngine1.startNetLogToDisk(netLogDir1.getPath(), false, MAX_FILE_SI
ZE); |
| 723 cronetEngine2.startNetLogToDisk(netLogDir2.getPath(), false, MAX_FILE_SI
ZE); | 719 cronetEngine2.startNetLogToDisk(netLogDir2.getPath(), false, MAX_FILE_SI
ZE); |
| 724 | 720 |
| 725 // Warm CronetEngine and make sure both CronetUrlRequestContexts are | 721 // Warm CronetEngine and make sure both CronetUrlRequestContexts are |
| 726 // initialized before testing the logs. | 722 // initialized before testing the logs. |
| 727 makeRequestAndCheckStatus(cronetEngine1, mUrl, 200); | 723 makeRequestAndCheckStatus(cronetEngine1, mUrl, 200); |
| 728 makeRequestAndCheckStatus(cronetEngine2, mUrl, 200); | 724 makeRequestAndCheckStatus(cronetEngine2, mUrl, 200); |
| 729 | 725 |
| 730 // Use cronetEngine1 to make a request to mUrl404. | 726 // Use cronetEngine1 to make a request to mUrl404. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 assertFalse(netLogDir.exists()); | 1016 assertFalse(netLogDir.exists()); |
| 1021 } | 1017 } |
| 1022 | 1018 |
| 1023 @SmallTest | 1019 @SmallTest |
| 1024 @Feature({"Cronet"}) | 1020 @Feature({"Cronet"}) |
| 1025 @OnlyRunNativeCronet | 1021 @OnlyRunNativeCronet |
| 1026 public void testNetLogWithBytes() throws Exception { | 1022 public void testNetLogWithBytes() throws Exception { |
| 1027 Context context = getContext(); | 1023 Context context = getContext(); |
| 1028 File directory = new File(PathUtils.getDataDirectory()); | 1024 File directory = new File(PathUtils.getDataDirectory()); |
| 1029 File file = File.createTempFile("cronet", "json", directory); | 1025 File file = File.createTempFile("cronet", "json", directory); |
| 1030 CronetEngine cronetEngine = | 1026 CronetEngine cronetEngine = new CronetEngine.Builder(context).build(); |
| 1031 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | |
| 1032 // Start NetLog with logAll as true. | 1027 // Start NetLog with logAll as true. |
| 1033 cronetEngine.startNetLogToFile(file.getPath(), true); | 1028 cronetEngine.startNetLogToFile(file.getPath(), true); |
| 1034 // Start a request. | 1029 // Start a request. |
| 1035 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 1030 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 1036 UrlRequest.Builder urlRequestBuilder = | 1031 UrlRequest.Builder urlRequestBuilder = |
| 1037 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); | 1032 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); |
| 1038 urlRequestBuilder.build().start(); | 1033 urlRequestBuilder.build().start(); |
| 1039 callback.blockForDone(); | 1034 callback.blockForDone(); |
| 1040 cronetEngine.stopNetLog(); | 1035 cronetEngine.stopNetLog(); |
| 1041 assertTrue(file.exists()); | 1036 assertTrue(file.exists()); |
| 1042 assertTrue(file.length() != 0); | 1037 assertTrue(file.length() != 0); |
| 1043 assertTrue(hasBytesInNetLog(file)); | 1038 assertTrue(hasBytesInNetLog(file)); |
| 1044 assertTrue(file.delete()); | 1039 assertTrue(file.delete()); |
| 1045 assertTrue(!file.exists()); | 1040 assertTrue(!file.exists()); |
| 1046 } | 1041 } |
| 1047 | 1042 |
| 1048 @SmallTest | 1043 @SmallTest |
| 1049 @Feature({"Cronet"}) | 1044 @Feature({"Cronet"}) |
| 1050 @OnlyRunNativeCronet | 1045 @OnlyRunNativeCronet |
| 1051 public void testBoundedFileNetLogWithBytes() throws Exception { | 1046 public void testBoundedFileNetLogWithBytes() throws Exception { |
| 1052 Context context = getContext(); | 1047 Context context = getContext(); |
| 1053 File directory = new File(PathUtils.getDataDirectory()); | 1048 File directory = new File(PathUtils.getDataDirectory()); |
| 1054 File netLogDir = new File(directory, "NetLog"); | 1049 File netLogDir = new File(directory, "NetLog"); |
| 1055 assertFalse(netLogDir.exists()); | 1050 assertFalse(netLogDir.exists()); |
| 1056 assertTrue(netLogDir.mkdir()); | 1051 assertTrue(netLogDir.mkdir()); |
| 1057 File eventFile = new File(netLogDir, "event_file_0.json"); | 1052 File eventFile = new File(netLogDir, "event_file_0.json"); |
| 1058 CronetUrlRequestContext cronetEngine = | 1053 ExperimentalCronetEngine cronetEngine = |
| 1059 new CronetUrlRequestContext(new CronetEngineBuilderImpl(context)
); | 1054 new ExperimentalCronetEngine.Builder(context).build(); |
| 1060 // Start NetLog with logAll as true. | 1055 // Start NetLog with logAll as true. |
| 1061 cronetEngine.startNetLogToDisk(netLogDir.getPath(), true, MAX_FILE_SIZE)
; | 1056 cronetEngine.startNetLogToDisk(netLogDir.getPath(), true, MAX_FILE_SIZE)
; |
| 1062 // Start a request. | 1057 // Start a request. |
| 1063 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 1058 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 1064 UrlRequest.Builder urlRequestBuilder = | 1059 UrlRequest.Builder urlRequestBuilder = |
| 1065 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); | 1060 cronetEngine.newUrlRequestBuilder(mUrl, callback, callback.getEx
ecutor()); |
| 1066 urlRequestBuilder.build().start(); | 1061 urlRequestBuilder.build().start(); |
| 1067 callback.blockForDone(); | 1062 callback.blockForDone(); |
| 1068 cronetEngine.stopNetLog(); | 1063 cronetEngine.stopNetLog(); |
| 1069 | 1064 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 assertEquals(200, thread1.mCallback.mResponseInfo.getHttpStatusCode()); | 1330 assertEquals(200, thread1.mCallback.mResponseInfo.getHttpStatusCode()); |
| 1336 assertEquals(404, thread2.mCallback.mResponseInfo.getHttpStatusCode()); | 1331 assertEquals(404, thread2.mCallback.mResponseInfo.getHttpStatusCode()); |
| 1337 } | 1332 } |
| 1338 | 1333 |
| 1339 @SmallTest | 1334 @SmallTest |
| 1340 @Feature({"Cronet"}) | 1335 @Feature({"Cronet"}) |
| 1341 public void testInitDifferentEngines() throws Exception { | 1336 public void testInitDifferentEngines() throws Exception { |
| 1342 // Test that concurrently instantiating Cronet context's upon various | 1337 // Test that concurrently instantiating Cronet context's upon various |
| 1343 // different versions of the same Android Context does not cause crashes | 1338 // different versions of the same Android Context does not cause crashes |
| 1344 // like crbug.com/453845 | 1339 // like crbug.com/453845 |
| 1345 final CronetTestFramework testFramework = startCronetTestFramework(); | 1340 CronetEngine firstEngine = new CronetEngine.Builder(getContext()).build(
); |
| 1346 CronetEngine firstEngine = | 1341 CronetEngine secondEngine = |
| 1347 new CronetUrlRequestContext(CronetTestUtil.getCronetEngineBuilde
rImpl( | 1342 new CronetEngine.Builder(getContext().getApplicationContext()).b
uild(); |
| 1348 testFramework.createCronetEngineBuilder(getContext()))); | |
| 1349 CronetEngine secondEngine = new CronetUrlRequestContext( | |
| 1350 CronetTestUtil.getCronetEngineBuilderImpl(testFramework.createCr
onetEngineBuilder( | |
| 1351 getContext().getApplicationContext()))); | |
| 1352 CronetEngine thirdEngine = | 1343 CronetEngine thirdEngine = |
| 1353 new CronetUrlRequestContext(CronetTestUtil.getCronetEngineBuilde
rImpl( | 1344 new CronetEngine.Builder(new ContextWrapper(getContext())).build
(); |
| 1354 testFramework.createCronetEngineBuilder(new ContextWrapp
er(getContext())))); | |
| 1355 firstEngine.shutdown(); | 1345 firstEngine.shutdown(); |
| 1356 secondEngine.shutdown(); | 1346 secondEngine.shutdown(); |
| 1357 thirdEngine.shutdown(); | 1347 thirdEngine.shutdown(); |
| 1358 } | 1348 } |
| 1359 | 1349 |
| 1360 @SmallTest | 1350 @SmallTest |
| 1361 @Feature({"Cronet"}) | 1351 @Feature({"Cronet"}) |
| 1362 public void testGetGlobalMetricsDeltas() throws Exception { | 1352 public void testGetGlobalMetricsDeltas() throws Exception { |
| 1363 final CronetTestFramework testFramework = startCronetTestFramework(); | 1353 final CronetTestFramework testFramework = startCronetTestFramework(); |
| 1364 | 1354 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 1466 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 1477 URL requestUrl = | 1467 URL requestUrl = |
| 1478 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl
.getFile()); | 1468 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl
.getFile()); |
| 1479 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr
lRequestBuilder( | 1469 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr
lRequestBuilder( |
| 1480 requestUrl.toString(), callback, callback.getExecutor()); | 1470 requestUrl.toString(), callback, callback.getExecutor()); |
| 1481 urlRequestBuilder.build().start(); | 1471 urlRequestBuilder.build().start(); |
| 1482 callback.blockForDone(); | 1472 callback.blockForDone(); |
| 1483 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); | 1473 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); |
| 1484 } | 1474 } |
| 1485 } | 1475 } |
| OLD | NEW |