test_file_util_android.cc 890 B

1234567891011121314151617181920212223242526
  1. // Copyright 2013 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. #include "base/test/test_file_util.h"
  5. #include "base/android/jni_android.h"
  6. #include "base/android/jni_string.h"
  7. #include "base/files/file_path.h"
  8. #include "base/test/base_unittests_jni_headers/ContentUriTestUtils_jni.h"
  9. using base::android::ScopedJavaLocalRef;
  10. namespace base {
  11. FilePath InsertImageIntoMediaStore(const FilePath& path) {
  12. JNIEnv* env = base::android::AttachCurrentThread();
  13. ScopedJavaLocalRef<jstring> j_path =
  14. base::android::ConvertUTF8ToJavaString(env, path.value());
  15. ScopedJavaLocalRef<jstring> j_uri =
  16. Java_ContentUriTestUtils_insertImageIntoMediaStore(env, j_path);
  17. std::string uri = base::android::ConvertJavaStringToUTF8(j_uri);
  18. return FilePath(uri);
  19. }
  20. } // namespace base