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

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

Issue 2506653003: Instrument CronetUrlRequestTest#testThrowOrCancelInOnCanceled flaky test (Closed)
Patch Set: Spelling fix Created 4 years, 1 month 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/test/javatests/src/org/chromium/net/TestUrlRequestCallback.java ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.os.ParcelFileDescriptor; 8 import android.os.ParcelFileDescriptor;
9 import android.os.StrictMode; 9 import android.os.StrictMode;
10 import android.test.suitebuilder.annotation.SmallTest; 10 import android.test.suitebuilder.annotation.SmallTest;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 @Override 193 @Override
194 public void rewind(UploadDataSink uploadDataSink) throws IOException {} 194 public void rewind(UploadDataSink uploadDataSink) throws IOException {}
195 }, callback.getExecutor()); 195 }, callback.getExecutor());
196 UrlRequest urlRequest = builder.build(); 196 UrlRequest urlRequest = builder.build();
197 urlRequest.start(); 197 urlRequest.start();
198 first.block(); 198 first.block();
199 callback.blockForDone(); 199 callback.blockForDone();
200 assertFalse(callback.mOnCanceledCalled); 200 assertFalse(callback.mOnCanceledCalled);
201 assertEquals(UrlRequestException.ERROR_LISTENER_EXCEPTION_THROWN, 201 assertEquals(UrlRequestException.ERROR_LISTENER_EXCEPTION_THROWN,
202 callback.mError.getErrorCode()); 202 callback.mError.getErrorCode());
203 assertEquals("Exception received from UploadDataProvider", callback.mErr or.getMessage()); 203 assertContains("Exception received from UploadDataProvider", callback.mE rror.getMessage());
204 assertEquals(exceptionMessage, callback.mError.getCause().getMessage()); 204 assertContains(exceptionMessage, callback.mError.getCause().getMessage() );
205 } 205 }
206 206
207 @SmallTest 207 @SmallTest
208 @Feature({"Cronet"}) 208 @Feature({"Cronet"})
209 // Tests that creating a ByteBufferUploadProvider using a byte array with an 209 // Tests that creating a ByteBufferUploadProvider using a byte array with an
210 // offset gives a ByteBuffer with position 0. crbug.com/603124. 210 // offset gives a ByteBuffer with position 0. crbug.com/603124.
211 public void testCreateByteBufferUploadWithArrayOffset() throws Exception { 211 public void testCreateByteBufferUploadWithArrayOffset() throws Exception {
212 TestUrlRequestCallback callback = new TestUrlRequestCallback(); 212 TestUrlRequestCallback callback = new TestUrlRequestCallback();
213 // This URL will trigger a rewind(). 213 // This URL will trigger a rewind().
214 UrlRequest.Builder builder = mTestFramework.mCronetEngine.newUrlRequestB uilder( 214 UrlRequest.Builder builder = mTestFramework.mCronetEngine.newUrlRequestB uilder(
215 NativeTestServer.getRedirectToEchoBody(), callback, callback.get Executor()); 215 NativeTestServer.getRedirectToEchoBody(), callback, callback.get Executor());
216 builder.addHeader("Content-Type", "useless/string"); 216 builder.addHeader("Content-Type", "useless/string");
217 byte[] uploadData = LOREM.getBytes("UTF-8"); 217 byte[] uploadData = LOREM.getBytes("UTF-8");
218 int offset = 5; 218 int offset = 5;
219 byte[] uploadDataWithPadding = new byte[uploadData.length + offset]; 219 byte[] uploadDataWithPadding = new byte[uploadData.length + offset];
220 System.arraycopy(uploadData, 0, uploadDataWithPadding, offset, uploadDat a.length); 220 System.arraycopy(uploadData, 0, uploadDataWithPadding, offset, uploadDat a.length);
221 UploadDataProvider dataProvider = 221 UploadDataProvider dataProvider =
222 UploadDataProviders.create(uploadDataWithPadding, offset, upload Data.length); 222 UploadDataProviders.create(uploadDataWithPadding, offset, upload Data.length);
223 assertEquals(uploadData.length, dataProvider.getLength()); 223 assertEquals(uploadData.length, dataProvider.getLength());
224 builder.setUploadDataProvider(dataProvider, callback.getExecutor()); 224 builder.setUploadDataProvider(dataProvider, callback.getExecutor());
225 UrlRequest urlRequest = builder.build(); 225 UrlRequest urlRequest = builder.build();
226 urlRequest.start(); 226 urlRequest.start();
227 callback.blockForDone(); 227 callback.blockForDone();
228 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); 228 assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
229 assertEquals(LOREM, callback.mResponseAsString); 229 assertEquals(LOREM, callback.mResponseAsString);
230 } 230 }
231 } 231 }
OLDNEW
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/TestUrlRequestCallback.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698