Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "mojo/android/javatests/validation_test_util.h" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "base/android/jni_string.h" | |
| 9 #include "base/android/scoped_java_ref.h" | |
| 10 #include "base/test/test_support_android.h" | |
| 11 #include "jni/ValidationTestUtil_jni.h" | |
| 12 #include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h" | |
| 13 | |
| 14 namespace mojo { | |
| 15 namespace android { | |
| 16 | |
| 17 bool RegisterValidationTestUtil(JNIEnv* env) { | |
| 18 return RegisterNativesImpl(env); | |
| 19 } | |
| 20 | |
| 21 jobject ParseData(JNIEnv* env, jclass jcaller, jstring data_as_string) { | |
| 22 std::string input = | |
| 23 base::android::ConvertJavaStringToUTF8(env, data_as_string); | |
| 24 std::vector<uint8_t> data; | |
| 25 size_t num_handles; | |
| 26 std::string error_message; | |
| 27 if (!mojo::test::ParseValidationTestInput( | |
|
darin (slow to review)
2014/08/27 15:55:56
nit: "mojo::" prefix isn't necessary since you are
qsr
2014/08/27 16:02:24
Done.
| |
| 28 input, &data, &num_handles, &error_message)) { | |
| 29 ScopedJavaLocalRef<jstring> j_error_message = | |
| 30 base::android::ConvertUTF8ToJavaString(env, error_message); | |
| 31 return Java_ValidationTestUtil_buildData( | |
| 32 env, NULL, 0, j_error_message.obj()).Release(); | |
| 33 } | |
| 34 | |
| 35 jobject byte_buffer = | |
| 36 env->NewDirectByteBuffer(&data[0], data.size()); | |
| 37 return Java_ValidationTestUtil_buildData(env, byte_buffer, num_handles, NULL) | |
| 38 .Release(); | |
| 39 } | |
| 40 | |
| 41 } // namespace android | |
| 42 } // namespace mojo | |
| OLD | NEW |