OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/test/launcher/unit_test_launcher.h" | 7 #include "base/test/launcher/unit_test_launcher.h" |
| 8 #include "base/test/test_io_thread.h" |
8 #include "base/test/test_suite.h" | 9 #include "base/test/test_suite.h" |
9 #include "mojo/edk/embedder/embedder.h" | 10 #include "mojo/edk/embedder/embedder.h" |
10 #include "mojo/edk/test/multiprocess_test_helper.h" | 11 #include "mojo/edk/test/multiprocess_test_helper.h" |
| 12 #include "mojo/edk/test/scoped_ipc_support.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 int main(int argc, char** argv) { | 15 int main(int argc, char** argv) { |
14 // Silence death test thread warnings on Linux. We can afford to run our death | 16 // Silence death test thread warnings on Linux. We can afford to run our death |
15 // tests a little more slowly (< 10 ms per death test on a Z620). | 17 // tests a little more slowly (< 10 ms per death test on a Z620). |
16 // On android, we need to run in the default mode, as the threadsafe mode | 18 // On android, we need to run in the default mode, as the threadsafe mode |
17 // relies on execve which is not available. | 19 // relies on execve which is not available. |
18 #if !defined(OS_ANDROID) | 20 #if !defined(OS_ANDROID) |
19 testing::GTEST_FLAG(death_test_style) = "threadsafe"; | 21 testing::GTEST_FLAG(death_test_style) = "threadsafe"; |
20 #endif | 22 #endif |
21 base::TestSuite test_suite(argc, argv); | 23 base::TestSuite test_suite(argc, argv); |
22 | 24 |
23 // Must be run before mojo::edk::Init. | 25 // Must be run before mojo::edk::Init. |
24 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 26 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
25 mojo::edk::test::kBrokerHandleSwitch)) { | 27 mojo::edk::test::kBrokerHandleSwitch)) { |
26 mojo::edk::PreInitializeChildProcess(); | 28 mojo::edk::PreInitializeChildProcess(); |
27 } | 29 } |
28 | 30 |
29 // TODO(use_chrome_edk): temporary to force new EDK. | 31 // TODO(use_chrome_edk): temporary to force new EDK. |
30 base::CommandLine::ForCurrentProcess()->AppendSwitch("--use-new-edk"); | 32 base::CommandLine::ForCurrentProcess()->AppendSwitch("--use-new-edk"); |
31 | 33 |
32 mojo::edk::Init(); | 34 mojo::edk::Init(); |
33 | 35 |
| 36 base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart); |
| 37 // Leak this because its destructor calls mojo::edk::ShutdownIPCSupport which |
| 38 // really does nothing in the new EDK but does depend on the current message |
| 39 // loop, which is destructed inside base::LaunchUnitTests. |
| 40 new mojo::edk::test::ScopedIPCSupport(test_io_thread.task_runner()); |
| 41 |
34 return base::LaunchUnitTests( | 42 return base::LaunchUnitTests( |
35 argc, argv, | 43 argc, argv, |
36 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); | 44 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); |
37 } | 45 } |
OLD | NEW |