• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 #ifndef BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_
6 #define BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_
7 
8 #include <jni.h>
9 
10 #include <memory>
11 
12 #include "base/android/scoped_java_ref.h"
13 
14 namespace base {
15 
16 class WaitableEvent;
17 
18 namespace android {
19 
20 class JavaHandlerThread;
21 
22 // Test-only helpers for working with JavaHandlerThread.
23 class JavaHandlerThreadHelpers {
24  public:
25   // Create the Java peer first and test that it works before connecting to the
26   // native object.
27   static std::unique_ptr<JavaHandlerThread> CreateJavaFirst();
28 
29   static void ThrowExceptionAndAbort(WaitableEvent* event);
30 
31   static bool IsExceptionTestException(
32       ScopedJavaLocalRef<jthrowable> exception);
33 
34  private:
35   JavaHandlerThreadHelpers() = default;
36   ~JavaHandlerThreadHelpers() = default;
37 };
38 
39 }  // namespace android
40 }  // namespace base
41 
42 #endif  // BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_
43