| OLD | NEW |
| 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 Loading... |
| 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() {} | 138 ApplicationTestBase::ApplicationTestBase() : test_helper_(nullptr) {} |
| 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(); | |
| 148 } | 141 } |
| 149 | 142 |
| 150 ShellClient* ApplicationTestBase::GetShellClient() { | 143 ShellClient* ApplicationTestBase::GetShellClient() { |
| 151 return nullptr; | 144 return nullptr; |
| 152 } | 145 } |
| 153 | 146 |
| 154 void ApplicationTestBase::SetUp() { | 147 void ApplicationTestBase::SetUp() { |
| 155 // A run loop is recommended for ShellConnection initialization and | 148 // A run loop is recommended for ShellConnection initialization and |
| 156 // communication. | 149 // communication. |
| 157 // Check this in SetUp() instead of in the constructor because we cannot call | 150 if (ShouldCreateDefaultRunLoop()) |
| 158 // virtual methods in the constructor. | |
| 159 if (ShouldCreateDefaultRunLoop()) { | |
| 160 use_default_run_loop_ = true; | |
| 161 Environment::InstantiateDefaultRunLoop(); | 151 Environment::InstantiateDefaultRunLoop(); |
| 162 } | |
| 163 | 152 |
| 164 CHECK(g_shell_client_request.is_pending()); | 153 CHECK(g_shell_client_request.is_pending()); |
| 165 CHECK(g_shell); | 154 CHECK(g_shell); |
| 166 | 155 |
| 167 // New applications are constructed for each test to avoid persisting state. | 156 // New applications are constructed for each test to avoid persisting state. |
| 168 test_helper_.reset(new TestHelper(GetShellClient())); | 157 test_helper_.reset(new TestHelper(GetShellClient())); |
| 169 } | 158 } |
| 170 | 159 |
| 171 void ApplicationTestBase::TearDown() { | 160 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(); |
| 172 } | 168 } |
| 173 | 169 |
| 174 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { | 170 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { |
| 175 return true; | 171 return true; |
| 176 } | 172 } |
| 177 | 173 |
| 178 } // namespace test | 174 } // namespace test |
| 179 } // namespace mojo | 175 } // namespace mojo |
| OLD | NEW |