| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/service_manager/public/cpp/test/common_initialization.h" |
| 6 |
| 5 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 6 #include "base/test/launcher/unit_test_launcher.h" | 8 #include "base/test/launcher/unit_test_launcher.h" |
| 7 #include "base/test/test_suite.h" | |
| 8 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 10 #include "mojo/edk/embedder/embedder.h" | 11 #include "mojo/edk/embedder/embedder.h" |
| 11 #include "mojo/edk/embedder/scoped_ipc_support.h" | 12 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 12 #include "services/catalog/catalog.h" | 13 #include "services/catalog/catalog.h" |
| 13 #include "services/service_manager/public/cpp/test/service_test_catalog.h" | 14 #include "services/service_manager/public/cpp/test/service_test_catalog.h" |
| 14 | 15 |
| 15 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 16 #include "base/android/jni_android.h" | 17 #include "base/android/jni_android.h" |
| 17 #include "mojo/android/system/mojo_jni_registrar.h" | 18 #include "mojo/android/system/mojo_jni_registrar.h" |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 #if defined(OS_MACOSX) && !defined(OS_IOS) | 21 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 21 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" | 22 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 int main(int argc, char** argv) { | 25 namespace service_manager { |
| 25 base::TestSuite test_suite(argc, argv); | |
| 26 | 26 |
| 27 int InitializeAndLaunchUnitTests( |
| 28 int argc, |
| 29 char** argv, |
| 30 const base::RunTestSuiteCallback& run_test_suite) { |
| 27 catalog::Catalog::SetDefaultCatalogManifest( | 31 catalog::Catalog::SetDefaultCatalogManifest( |
| 28 service_manager::test::CreateTestCatalog()); | 32 service_manager::test::CreateTestCatalog()); |
| 29 | 33 |
| 30 mojo::edk::Init(); | 34 mojo::edk::Init(); |
| 31 | 35 |
| 32 #if defined(OS_MACOSX) && !defined(OS_IOS) | 36 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 33 mojo::edk::SetMachPortProvider( | 37 mojo::edk::SetMachPortProvider( |
| 34 service_manager::MachBroker::GetInstance()->port_provider()); | 38 service_manager::MachBroker::GetInstance()->port_provider()); |
| 35 #endif | 39 #endif |
| 36 | 40 |
| 37 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 38 mojo::android::RegisterSystemJni(base::android::AttachCurrentThread()); | 42 mojo::android::RegisterSystemJni(base::android::AttachCurrentThread()); |
| 39 #endif | 43 #endif |
| 40 | 44 |
| 41 base::Thread ipc_thread("IPC thread"); | 45 base::Thread ipc_thread("IPC thread"); |
| 42 ipc_thread.StartWithOptions( | 46 ipc_thread.StartWithOptions( |
| 43 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 47 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 44 mojo::edk::ScopedIPCSupport ipc_support( | 48 mojo::edk::ScopedIPCSupport ipc_support( |
| 45 ipc_thread.task_runner(), | 49 ipc_thread.task_runner(), |
| 46 mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN); | 50 mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN); |
| 47 | 51 |
| 48 return base::LaunchUnitTests( | 52 return base::LaunchUnitTests(argc, argv, run_test_suite); |
| 49 argc, argv, | |
| 50 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); | |
| 51 } | 53 } |
| 54 |
| 55 } // namespace service_manager |
| OLD | NEW |