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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java

Issue 2055083002: [Cronet] Fix CronetFixedModeOutputStream to not write more bytes than specified (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
index 3dddc7397f85d78d7a221cbebae90383be18e211..81eb364bb1f16e1235d0e560e051621cf8d782e8 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
@@ -275,14 +275,22 @@ public class CronetFixedModeOutputStreamTest extends CronetTestBase {
@SmallTest
@Feature({"Cronet"})
@OnlyRunCronetHttpURLConnection
- public void testLargeDataMoreThanNativeBufferSize()
- throws Exception {
+ public void testJavaBufferSizeLargerThanNativeBufferSize() throws Exception {
// Set an internal buffer of size larger than the buffer size used
// in network stack internally.
// Normal stream uses 16384, QUIC uses 14520, and SPDY uses 16384.
- CronetFixedModeOutputStream.setDefaultBufferLengthForTesting(17384);
- testFixedLengthStreamingModeLargeDataWriteOneByte();
- testFixedLengthStreamingModeLargeData();
+ // Try two different buffer lengths. 17384 will make the last write
+ // smaller than the native buffer length; 18384 will make the last write
+ // bigger than the native buffer length
+ // (largeData.length % 17384 = 9448, largeData.length % 18384 = 16752).
+ int[] bufferLengths = new int[] {17384, 18384};
+ for (int length : bufferLengths) {
+ CronetFixedModeOutputStream.setDefaultBufferLengthForTesting(length);
+ // Run the following three tests with this custom buffer size.
+ testFixedLengthStreamingModeLargeDataWriteOneByte();
+ testFixedLengthStreamingModeLargeData();
+ testOneMassiveWrite();
+ }
}
@SmallTest

Powered by Google App Engine
This is Rietveld 408576698