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

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

Issue 1709173002: mojo: Delay ApplicationTestBase shell disconnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 4 years, 10 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/application_test_base.h ('k') | mojo/tools/data/apptests » ('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 f9a726dbf2c752e033d1e331ba1d9d8d0ac06338..a6d253df908cbc5335d103d7db8e39347168774f 100644
--- a/mojo/shell/public/cpp/lib/application_test_base.cc
+++ b/mojo/shell/public/cpp/lib/application_test_base.cc
@@ -135,9 +135,16 @@ TestHelper::~TestHelper() {
shell_connection_.reset();
}
-ApplicationTestBase::ApplicationTestBase() : test_helper_(nullptr) {}
+ApplicationTestBase::ApplicationTestBase() {}
ApplicationTestBase::~ApplicationTestBase() {
+ CHECK(!g_shell_client_request.is_pending());
+ CHECK(!g_shell);
+
+ test_helper_.reset();
+
+ if (use_default_run_loop_)
+ Environment::DestroyDefaultRunLoop();
}
ShellClient* ApplicationTestBase::GetShellClient() {
@@ -147,8 +154,12 @@ ShellClient* ApplicationTestBase::GetShellClient() {
void ApplicationTestBase::SetUp() {
// A run loop is recommended for ShellConnection initialization and
// communication.
- if (ShouldCreateDefaultRunLoop())
+ // Check this in SetUp() instead of in the constructor because we cannot call
+ // virtual methods in the constructor.
+ if (ShouldCreateDefaultRunLoop()) {
+ use_default_run_loop_ = true;
Environment::InstantiateDefaultRunLoop();
+ }
CHECK(g_shell_client_request.is_pending());
CHECK(g_shell);
@@ -158,13 +169,6 @@ void ApplicationTestBase::SetUp() {
}
void ApplicationTestBase::TearDown() {
- CHECK(!g_shell_client_request.is_pending());
- CHECK(!g_shell);
-
- test_helper_.reset();
-
- if (ShouldCreateDefaultRunLoop())
- Environment::DestroyDefaultRunLoop();
}
bool ApplicationTestBase::ShouldCreateDefaultRunLoop() {
« no previous file with comments | « mojo/shell/public/cpp/application_test_base.h ('k') | mojo/tools/data/apptests » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698