Revert of Refactor the avatar button/icon class (patchset #14 id:320001 of https...
[chromium-blink-merge.git] / components / cronet / android / test / mock_url_request_job_factory.cc
blob4a3030fb7a9669741d5f4915a40836b020442a6f
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
3 // found in the LICENSE file.
5 #include "mock_url_request_job_factory.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "jni/MockUrlRequestJobFactory_jni.h"
10 #include "net/test/url_request/url_request_failed_job.h"
11 #include "net/test/url_request/url_request_mock_data_job.h"
13 namespace cronet {
15 void AddUrlInterceptors(JNIEnv* env, jclass jcaller) {
16 net::URLRequestMockDataJob::AddUrlHandler();
17 net::URLRequestFailedJob::AddUrlHandler();
20 jstring GetMockUrlWithFailure(JNIEnv* jenv,
21 jclass jcaller,
22 jint jphase,
23 jint jnet_error) {
24 GURL url(net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase(
25 static_cast<net::URLRequestFailedJob::FailurePhase>(jphase),
26 static_cast<int>(jnet_error)));
27 return base::android::ConvertUTF8ToJavaString(jenv, url.spec()).Release();
30 jstring GetMockUrlForData(JNIEnv* jenv,
31 jclass jcaller,
32 jstring jdata,
33 jint jdata_repeat_count) {
34 std::string data(base::android::ConvertJavaStringToUTF8(jenv, jdata));
35 GURL url(net::URLRequestMockDataJob::GetMockHttpUrl(data,
36 jdata_repeat_count));
37 return base::android::ConvertUTF8ToJavaString(jenv, url.spec()).Release();
40 bool RegisterMockUrlRequestJobFactory(JNIEnv* env) {
41 return RegisterNativesImpl(env);
44 } // namespace cronet