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.os.ConditionVariable; | 7 import android.os.ConditionVariable; |
8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 import android.util.Pair; | 9 import android.util.Pair; |
10 | 10 |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 // but request will be destroyed from network thread. | 1351 // but request will be destroyed from network thread. |
1352 requestDestroyed.block(); | 1352 requestDestroyed.block(); |
1353 | 1353 |
1354 assertFalse(listener.isDone()); | 1354 assertFalse(listener.isDone()); |
1355 assertTrue(urlRequest.isDone()); | 1355 assertTrue(urlRequest.isDone()); |
1356 } | 1356 } |
1357 | 1357 |
1358 @SmallTest | 1358 @SmallTest |
1359 @Feature({"Cronet"}) | 1359 @Feature({"Cronet"}) |
1360 public void testUploadExecutorShutdown() throws Exception { | 1360 public void testUploadExecutorShutdown() throws Exception { |
1361 class HangingUploadDataProvider implements UploadDataProvider { | 1361 class HangingUploadDataProvider extends UploadDataProvider { |
1362 UploadDataSink mUploadDataSink; | 1362 UploadDataSink mUploadDataSink; |
1363 ByteBuffer mByteBuffer; | 1363 ByteBuffer mByteBuffer; |
1364 ConditionVariable mReadCalled = new ConditionVariable(false); | 1364 ConditionVariable mReadCalled = new ConditionVariable(false); |
1365 | 1365 |
1366 @Override | 1366 @Override |
1367 public long getLength() { | 1367 public long getLength() { |
1368 return 69; | 1368 return 69; |
1369 } | 1369 } |
1370 | 1370 |
1371 @Override | 1371 @Override |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 int end) { | 1412 int end) { |
1413 // Use a duplicate to avoid modifying byteBuffer. | 1413 // Use a duplicate to avoid modifying byteBuffer. |
1414 ByteBuffer duplicate = byteBuffer.duplicate(); | 1414 ByteBuffer duplicate = byteBuffer.duplicate(); |
1415 duplicate.position(start); | 1415 duplicate.position(start); |
1416 duplicate.limit(end); | 1416 duplicate.limit(end); |
1417 byte[] contents = new byte[duplicate.remaining()]; | 1417 byte[] contents = new byte[duplicate.remaining()]; |
1418 duplicate.get(contents); | 1418 duplicate.get(contents); |
1419 return new String(contents); | 1419 return new String(contents); |
1420 } | 1420 } |
1421 } | 1421 } |
OLD | NEW |