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

Side by Side Diff: mojo/application/public/cpp/lib/application_test_base.cc

Issue 1266643003: ApplicationImpl cleanup, part 1: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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 "mojo/application/public/cpp/application_test_base.h" 5 #include "mojo/application/public/cpp/application_test_base.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #include "mojo/application/public/cpp/application_impl.h" 10 #include "mojo/application/public/cpp/application_impl.h"
10 #include "mojo/application/public/interfaces/application.mojom.h" 11 #include "mojo/application/public/interfaces/application.mojom.h"
11 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
12 #include "mojo/public/cpp/environment/environment.h" 13 #include "mojo/public/cpp/environment/environment.h"
13 #include "mojo/public/cpp/system/message_pipe.h" 14 #include "mojo/public/cpp/system/message_pipe.h"
14 15
15 namespace mojo { 16 namespace mojo {
16 namespace test { 17 namespace test {
17 18
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 void ApplicationTestBase::SetUp() { 120 void ApplicationTestBase::SetUp() {
120 // A run loop is recommended for ApplicationImpl initialization and 121 // A run loop is recommended for ApplicationImpl initialization and
121 // communication. 122 // communication.
122 if (ShouldCreateDefaultRunLoop()) 123 if (ShouldCreateDefaultRunLoop())
123 Environment::InstantiateDefaultRunLoop(); 124 Environment::InstantiateDefaultRunLoop();
124 125
125 MOJO_CHECK(g_application_request.is_pending()); 126 MOJO_CHECK(g_application_request.is_pending());
126 MOJO_CHECK(g_shell); 127 MOJO_CHECK(g_shell);
127 128
128 // New applications are constructed for each test to avoid persisting state. 129 // New applications are constructed for each test to avoid persisting state.
129 application_impl_ = new ApplicationImpl(GetApplicationDelegate(), 130 application_impl_ =
130 g_application_request.Pass()); 131 new ApplicationImpl(GetApplicationDelegate(),
132 g_application_request.Pass(),
133 base::MessageLoop::QuitWhenIdleClosure());
131 134
132 // Fake application initialization. 135 // Fake application initialization.
133 application_impl_->Initialize(g_shell.Pass(), g_url); 136 application_impl_->Initialize(g_shell.Pass(), g_url);
134 } 137 }
135 138
136 void ApplicationTestBase::TearDown() { 139 void ApplicationTestBase::TearDown() {
137 MOJO_CHECK(!g_application_request.is_pending()); 140 MOJO_CHECK(!g_application_request.is_pending());
138 MOJO_CHECK(!g_shell); 141 MOJO_CHECK(!g_shell);
139 142
140 application_impl_->UnbindConnections(&g_application_request, &g_shell); 143 application_impl_->UnbindConnections(&g_application_request, &g_shell);
141 delete application_impl_; 144 delete application_impl_;
142 if (ShouldCreateDefaultRunLoop()) 145 if (ShouldCreateDefaultRunLoop())
143 Environment::DestroyDefaultRunLoop(); 146 Environment::DestroyDefaultRunLoop();
144 } 147 }
145 148
146 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { 149 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() {
147 return true; 150 return true;
148 } 151 }
149 152
150 153
151 } // namespace test 154 } // namespace test
152 } // namespace mojo 155 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698