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

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

Issue 2406273002: [Cronet] Test the libcronet that's shipped, not libcronet_test (Closed)
Patch Set: fix perf test Created 4 years, 2 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
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 20 matching lines...) Expand all
31 super.setUp(); 31 super.setUp();
32 mOldVmPolicy = StrictMode.getVmPolicy(); 32 mOldVmPolicy = StrictMode.getVmPolicy();
33 StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() 33 StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
34 .detectLeakedClosableObjects() 34 .detectLeakedClosableObjects()
35 .penaltyLog() 35 .penaltyLog()
36 .penaltyDeath() 36 .penaltyDeath()
37 .build()); 37 .build());
38 mTestFramework = startCronetTestFramework(); 38 mTestFramework = startCronetTestFramework();
39 assertTrue(NativeTestServer.startNativeTestServer(getContext())); 39 assertTrue(NativeTestServer.startNativeTestServer(getContext()));
40 // Add url interceptors after native application context is initialized. 40 // Add url interceptors after native application context is initialized.
41 MockUrlRequestJobFactory.setUp(); 41 MockUrlRequestJobFactory.setUp(mTestFramework.mCronetEngine);
42 mFile = new File(getContext().getCacheDir().getPath() + "/tmpfile"); 42 mFile = new File(getContext().getCacheDir().getPath() + "/tmpfile");
43 FileOutputStream fileOutputStream = new FileOutputStream(mFile); 43 FileOutputStream fileOutputStream = new FileOutputStream(mFile);
44 try { 44 try {
45 fileOutputStream.write(LOREM.getBytes("UTF-8")); 45 fileOutputStream.write(LOREM.getBytes("UTF-8"));
46 } finally { 46 } finally {
47 fileOutputStream.close(); 47 fileOutputStream.close();
48 } 48 }
49 } 49 }
50 50
51 @SuppressFBWarnings("DM_GC") // Used to trigger strictmode detecting leaked closeables 51 @SuppressFBWarnings("DM_GC") // Used to trigger strictmode detecting leaked closeables
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 UploadDataProviders.create(uploadDataWithPadding, offset, upload Data.length); 226 UploadDataProviders.create(uploadDataWithPadding, offset, upload Data.length);
227 assertEquals(uploadData.length, dataProvider.getLength()); 227 assertEquals(uploadData.length, dataProvider.getLength());
228 builder.setUploadDataProvider(dataProvider, callback.getExecutor()); 228 builder.setUploadDataProvider(dataProvider, callback.getExecutor());
229 UrlRequest urlRequest = builder.build(); 229 UrlRequest urlRequest = builder.build();
230 urlRequest.start(); 230 urlRequest.start();
231 callback.blockForDone(); 231 callback.blockForDone();
232 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); 232 assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
233 assertEquals(LOREM, callback.mResponseAsString); 233 assertEquals(LOREM, callback.mResponseAsString);
234 } 234 }
235 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698