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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility> 5 #include <utility>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "mojo/public/cpp/bindings/binding.h" 10 #include "mojo/public/cpp/bindings/binding.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // TODO: commented out until http://crbug.com/533107 is solved. 128 // TODO: commented out until http://crbug.com/533107 is solved.
129 // { 129 // {
130 // ShellConnection::TestApi test_api(shell_connection_); 130 // ShellConnection::TestApi test_api(shell_connection_);
131 // test_api.UnbindConnections(&g_shell_client_request, &g_shell); 131 // test_api.UnbindConnections(&g_shell_client_request, &g_shell);
132 // } 132 // }
133 // We may have supplied a member as the client. Delete |shell_connection_| 133 // We may have supplied a member as the client. Delete |shell_connection_|
134 // while still valid. 134 // while still valid.
135 shell_connection_.reset(); 135 shell_connection_.reset();
136 } 136 }
137 137
138 ApplicationTestBase::ApplicationTestBase() : test_helper_(nullptr) {} 138 ApplicationTestBase::ApplicationTestBase() {}
139 139
140 ApplicationTestBase::~ApplicationTestBase() { 140 ApplicationTestBase::~ApplicationTestBase() {
141 CHECK(!g_shell_client_request.is_pending());
142 CHECK(!g_shell);
143
144 test_helper_.reset();
145
146 if (use_default_run_loop_)
147 Environment::DestroyDefaultRunLoop();
141 } 148 }
142 149
143 ShellClient* ApplicationTestBase::GetShellClient() { 150 ShellClient* ApplicationTestBase::GetShellClient() {
144 return nullptr; 151 return nullptr;
145 } 152 }
146 153
147 void ApplicationTestBase::SetUp() { 154 void ApplicationTestBase::SetUp() {
148 // A run loop is recommended for ShellConnection initialization and 155 // A run loop is recommended for ShellConnection initialization and
149 // communication. 156 // communication.
150 if (ShouldCreateDefaultRunLoop()) 157 // Check this in SetUp() instead of in the constructor because we cannot call
158 // virtual methods in the constructor.
159 if (ShouldCreateDefaultRunLoop()) {
160 use_default_run_loop_ = true;
151 Environment::InstantiateDefaultRunLoop(); 161 Environment::InstantiateDefaultRunLoop();
162 }
152 163
153 CHECK(g_shell_client_request.is_pending()); 164 CHECK(g_shell_client_request.is_pending());
154 CHECK(g_shell); 165 CHECK(g_shell);
155 166
156 // New applications are constructed for each test to avoid persisting state. 167 // New applications are constructed for each test to avoid persisting state.
157 test_helper_.reset(new TestHelper(GetShellClient())); 168 test_helper_.reset(new TestHelper(GetShellClient()));
158 } 169 }
159 170
160 void ApplicationTestBase::TearDown() { 171 void ApplicationTestBase::TearDown() {
161 CHECK(!g_shell_client_request.is_pending());
162 CHECK(!g_shell);
163
164 test_helper_.reset();
165
166 if (ShouldCreateDefaultRunLoop())
167 Environment::DestroyDefaultRunLoop();
168 } 172 }
169 173
170 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { 174 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() {
171 return true; 175 return true;
172 } 176 }
173 177
174 } // namespace test 178 } // namespace test
175 } // namespace mojo 179 } // namespace mojo
OLDNEW
« 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