OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/test/launcher/unit_test_launcher.h" | 6 #include "base/test/launcher/unit_test_launcher.h" |
7 #include "base/test/test_suite.h" | 7 #include "base/test/test_suite.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "mojo/edk/embedder/embedder.h" | 9 #include "mojo/edk/embedder/embedder.h" |
10 | 10 |
| 11 #if defined(OS_ANDROID) |
| 12 #include "base/android/base_jni_registrar.h" |
| 13 #include "base/android/jni_android.h" |
| 14 #include "blimp/client/public/android/blimp_jni_registrar.h" |
| 15 #include "net/android/net_jni_registrar.h" |
| 16 #include "ui/gfx/android/gfx_jni_registrar.h" |
| 17 #endif |
| 18 |
| 19 namespace { |
| 20 |
| 21 class BlimpTestSuite : public base::TestSuite { |
| 22 public: |
| 23 BlimpTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
| 24 |
| 25 protected: |
| 26 void Initialize() override { |
| 27 base::TestSuite::Initialize(); |
| 28 |
| 29 #if defined(OS_ANDROID) |
| 30 if (!RegisterJni(base::android::AttachCurrentThread())) { |
| 31 LOG(FATAL) << "Jni Registration failed"; |
| 32 } |
| 33 #endif |
| 34 } |
| 35 |
| 36 private: |
| 37 #if defined(OS_ANDROID) |
| 38 bool RegisterJni(JNIEnv* env) { |
| 39 if (!base::android::RegisterJni(env)) { |
| 40 return false; |
| 41 } |
| 42 |
| 43 if (!net::android::RegisterJni(env)) { |
| 44 return false; |
| 45 } |
| 46 |
| 47 if (!gfx::android::RegisterJni(env)) { |
| 48 return false; |
| 49 } |
| 50 |
| 51 if (!blimp::client::RegisterBlimpJni(env)) { |
| 52 return false; |
| 53 } |
| 54 |
| 55 return true; |
| 56 } |
| 57 #endif |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(BlimpTestSuite); |
| 60 }; |
| 61 |
| 62 } // namespace |
| 63 |
11 int main(int argc, char** argv) { | 64 int main(int argc, char** argv) { |
12 mojo::edk::Init(); | 65 mojo::edk::Init(); |
13 base::TestSuite test_suite(argc, argv); | 66 BlimpTestSuite test_suite(argc, argv); |
14 return base::LaunchUnitTests( | 67 return base::LaunchUnitTests( |
15 argc, argv, | 68 argc, argv, |
16 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); | 69 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); |
17 } | 70 } |
OLD | NEW |