Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2607)

Unified Diff: mojo/edk/test/run_all_unittests.cc

Issue 2514093002: Mojo EDK: Clean shutdown for ScopedIPCSupport in tests (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/edk/test/scoped_ipc_support.h » ('j') | mojo/edk/test/scoped_ipc_support.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | mojo/edk/test/scoped_ipc_support.h » ('j') | mojo/edk/test/scoped_ipc_support.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698