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

Side by Side Diff: mojo/android/javatests/validation_test_util.cc

Issue 1312153003: jni_generator: Pass object parameters as JavaParamRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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
« no previous file with comments | « mojo/android/javatests/mojo_test_case.cc ('k') | mojo/android/system/base_run_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "mojo/android/javatests/validation_test_util.h" 5 #include "mojo/android/javatests/validation_test_util.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/test/test_support_android.h" 10 #include "base/test/test_support_android.h"
11 #include "jni/ValidationTestUtil_jni.h" 11 #include "jni/ValidationTestUtil_jni.h"
12 #include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h" 12 #include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace android { 15 namespace android {
16 16
17 bool RegisterValidationTestUtil(JNIEnv* env) { 17 bool RegisterValidationTestUtil(JNIEnv* env) {
18 return RegisterNativesImpl(env); 18 return RegisterNativesImpl(env);
19 } 19 }
20 20
21 ScopedJavaLocalRef<jobject> ParseData(JNIEnv* env, 21 ScopedJavaLocalRef<jobject> ParseData(
22 jclass jcaller, 22 JNIEnv* env,
23 jstring data_as_string) { 23 const JavaParamRef<jclass>& jcaller,
24 const JavaParamRef<jstring>& data_as_string) {
24 std::string input = 25 std::string input =
25 base::android::ConvertJavaStringToUTF8(env, data_as_string); 26 base::android::ConvertJavaStringToUTF8(env, data_as_string);
26 std::vector<uint8_t> data; 27 std::vector<uint8_t> data;
27 size_t num_handles; 28 size_t num_handles;
28 std::string error_message; 29 std::string error_message;
29 if (!test::ParseValidationTestInput( 30 if (!test::ParseValidationTestInput(
30 input, &data, &num_handles, &error_message)) { 31 input, &data, &num_handles, &error_message)) {
31 ScopedJavaLocalRef<jstring> j_error_message = 32 ScopedJavaLocalRef<jstring> j_error_message =
32 base::android::ConvertUTF8ToJavaString(env, error_message); 33 base::android::ConvertUTF8ToJavaString(env, error_message);
33 return Java_ValidationTestUtil_buildData(env, NULL, 0, 34 return Java_ValidationTestUtil_buildData(env, NULL, 0,
34 j_error_message.obj()); 35 j_error_message.obj());
35 } 36 }
36 void* data_ptr = &data[0]; 37 void* data_ptr = &data[0];
37 if (!data_ptr) { 38 if (!data_ptr) {
38 DCHECK(!data.size()); 39 DCHECK(!data.size());
39 data_ptr = &data; 40 data_ptr = &data;
40 } 41 }
41 jobject byte_buffer = 42 jobject byte_buffer =
42 env->NewDirectByteBuffer(data_ptr, data.size()); 43 env->NewDirectByteBuffer(data_ptr, data.size());
43 return Java_ValidationTestUtil_buildData(env, byte_buffer, num_handles, NULL); 44 return Java_ValidationTestUtil_buildData(env, byte_buffer, num_handles, NULL);
44 } 45 }
45 46
46 } // namespace android 47 } // namespace android
47 } // namespace mojo 48 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/android/javatests/mojo_test_case.cc ('k') | mojo/android/system/base_run_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698