Index: mojo/edk/test/run_all_unittests.cc |
diff --git a/mojo/edk/test/run_all_unittests.cc b/mojo/edk/test/run_all_unittests.cc |
index 05aed913a4868f2fa2ae443e1c9098a44ab23ade..c081e7ffd9bb02d9970b450c960647b4624ac470 100644 |
--- a/mojo/edk/test/run_all_unittests.cc |
+++ b/mojo/edk/test/run_all_unittests.cc |
@@ -4,8 +4,11 @@ |
#include <signal.h> |
+#include <memory> |
+ |
#include "base/bind.h" |
#include "base/command_line.h" |
+#include "base/message_loop/message_loop.h" |
#include "base/test/launcher/unit_test_launcher.h" |
#include "base/test/multiprocess_test.h" |
#include "base/test/test_io_thread.h" |
@@ -43,12 +46,18 @@ int main(int argc, char** argv) { |
mojo::test::TestSupport::Init(new mojo::edk::test::TestSupportImpl()); |
base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart); |
- // Leak this because its destructor calls mojo::edk::ShutdownIPCSupport which |
- // really does nothing in the new EDK but does depend on the current message |
- // loop, which is destructed inside base::LaunchUnitTests. |
- new mojo::edk::test::ScopedIPCSupport(test_io_thread.task_runner()); |
- return base::LaunchUnitTests( |
+ std::unique_ptr<mojo::edk::test::ScopedIPCSupport> ipc_support( |
+ new mojo::edk::test::ScopedIPCSupport(test_io_thread.task_runner())); |
+ |
+ int result = base::LaunchUnitTests( |
argc, argv, |
base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); |
+ |
+ // NOTE: ScopedIPCSupport's destructor requires a MessageLoop to be running. |
+ // We create one here solely for that purpose. |
+ base::MessageLoop shutdown_loop; |
+ ipc_support.reset(); |
+ |
+ return result; |
} |