summaryrefslogtreecommitdiffstats
path: root/mojo/shell/public
diff options
context:
space:
mode:
authorxhwang <xhwang@chromium.org>2016-02-23 11:56:27 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-23 19:57:19 +0000
commit74cb68fa1c313c885c6022eea11ef6855d9ca0da (patch)
tree514d69db1804b232382783634634d58de176999b /mojo/shell/public
parent40bc0fdba7eba321ff53c48bad04d21e6f7d5450 (diff)
downloadchromium_src-74cb68fa1c313c885c6022eea11ef6855d9ca0da.zip
chromium_src-74cb68fa1c313c885c6022eea11ef6855d9ca0da.tar.gz
chromium_src-74cb68fa1c313c885c6022eea11ef6855d9ca0da.tar.bz2
mojo: Delay ApplicationTestBase shell disconnection.
BUG=587523 TEST=Reenable tests. Review URL: https://codereview.chromium.org/1709173002 Cr-Commit-Position: refs/heads/master@{#377068}
Diffstat (limited to 'mojo/shell/public')
-rw-r--r--mojo/shell/public/cpp/application_test_base.h1
-rw-r--r--mojo/shell/public/cpp/lib/application_test_base.cc22
2 files changed, 14 insertions, 9 deletions
diff --git a/mojo/shell/public/cpp/application_test_base.h b/mojo/shell/public/cpp/application_test_base.h
index f8ff6ad..65f86e3 100644
--- a/mojo/shell/public/cpp/application_test_base.h
+++ b/mojo/shell/public/cpp/application_test_base.h
@@ -75,6 +75,7 @@ class ApplicationTestBase : public testing::Test {
private:
scoped_ptr<TestHelper> test_helper_;
+ bool use_default_run_loop_ = false;
MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationTestBase);
};
diff --git a/mojo/shell/public/cpp/lib/application_test_base.cc b/mojo/shell/public/cpp/lib/application_test_base.cc
index f9a726d..a6d253d 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() {