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

Unified Diff: mojo/shell/public/cpp/lib/application_test_base.cc

Issue 1765243002: Remove Mojo bindings environment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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 | « mojo/shell/public/cpp/BUILD.gn ('k') | net/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/public/cpp/lib/application_test_base.cc
diff --git a/mojo/shell/public/cpp/lib/application_test_base.cc b/mojo/shell/public/cpp/lib/application_test_base.cc
index e2e582648b948358aba104aadb679c9aaf186d46..dcd7dc33e6352db4d771adca82e8b62c3681be37 100644
--- a/mojo/shell/public/cpp/lib/application_test_base.cc
+++ b/mojo/shell/public/cpp/lib/application_test_base.cc
@@ -6,9 +6,9 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/environment/environment.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "mojo/shell/public/cpp/application_test_base.h"
#include "mojo/shell/public/cpp/shell_connection.h"
@@ -70,7 +70,7 @@ class ShellGrabber : public shell::mojom::ShellClient {
MojoResult RunAllTests(MojoHandle shell_client_request_handle) {
{
// This loop is used for init, and then destroyed before running tests.
- Environment::InstantiateDefaultRunLoop();
+ base::MessageLoop message_loop;
// Grab the shell handle.
ShellGrabber grabber(
@@ -97,8 +97,6 @@ MojoResult RunAllTests(MojoHandle shell_client_request_handle) {
argv[argc] = nullptr;
testing::InitGoogleTest(&argc, const_cast<char**>(&(argv[0])));
-
- Environment::DestroyDefaultRunLoop();
}
int result = RUN_ALL_TESTS();
@@ -140,8 +138,12 @@ ShellClient* ApplicationTestBase::GetShellClient() {
void ApplicationTestBase::SetUp() {
// A run loop is recommended for ShellConnection initialization and
// communication.
- if (ShouldCreateDefaultRunLoop())
- Environment::InstantiateDefaultRunLoop();
+ if (ShouldCreateDefaultRunLoop()) {
+ CHECK(!base::MessageLoop::current());
+ // Not leaked: accessible from |base::MessageLoop::current()|.
+ base::MessageLoop* message_loop = new base::MessageLoop();
+ CHECK_EQ(message_loop, base::MessageLoop::current());
+ }
CHECK(g_shell_client_request.is_pending());
CHECK(g_connector);
@@ -156,8 +158,11 @@ void ApplicationTestBase::TearDown() {
test_helper_.reset();
- if (ShouldCreateDefaultRunLoop())
- Environment::DestroyDefaultRunLoop();
+ if (ShouldCreateDefaultRunLoop()) {
+ CHECK(base::MessageLoop::current());
+ delete base::MessageLoop::current();
+ CHECK(!base::MessageLoop::current());
+ }
}
bool ApplicationTestBase::ShouldCreateDefaultRunLoop() {
« no previous file with comments | « mojo/shell/public/cpp/BUILD.gn ('k') | net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698