java_handler_thread_helpers.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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
  3. // found in the LICENSE file.
  4. #ifndef BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_
  5. #define BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_
  6. #include <jni.h>
  7. #include <memory>
  8. #include "base/android/scoped_java_ref.h"
  9. namespace base {
  10. class WaitableEvent;
  11. namespace android {
  12. class JavaHandlerThread;
  13. // Test-only helpers for working with JavaHandlerThread.
  14. class JavaHandlerThreadHelpers {
  15. public:
  16. // Create the Java peer first and test that it works before connecting to the
  17. // native object.
  18. static std::unique_ptr<JavaHandlerThread> CreateJavaFirst();
  19. static void ThrowExceptionAndAbort(WaitableEvent* event);
  20. static bool IsExceptionTestException(
  21. ScopedJavaLocalRef<jthrowable> exception);
  22. private:
  23. JavaHandlerThreadHelpers() = default;
  24. ~JavaHandlerThreadHelpers() = default;
  25. };
  26. } // namespace android
  27. } // namespace base
  28. #endif // BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_