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

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

Issue 1675083002: Rename ApplicationDelegate to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . 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 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 <utility> 5 #include <utility>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "mojo/public/cpp/bindings/binding.h" 9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "mojo/public/cpp/environment/environment.h" 10 #include "mojo/public/cpp/environment/environment.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 int result = RUN_ALL_TESTS(); 107 int result = RUN_ALL_TESTS();
108 108
109 // Shut down our message pipes before exiting. 109 // Shut down our message pipes before exiting.
110 (void)g_application_request.PassMessagePipe(); 110 (void)g_application_request.PassMessagePipe();
111 g_shell.reset(); 111 g_shell.reset();
112 112
113 return (result == 0) ? MOJO_RESULT_OK : MOJO_RESULT_UNKNOWN; 113 return (result == 0) ? MOJO_RESULT_OK : MOJO_RESULT_UNKNOWN;
114 } 114 }
115 115
116 TestHelper::TestHelper(ApplicationDelegate* delegate) 116 TestHelper::TestHelper(ShellClient* client)
117 : application_impl_(new ApplicationImpl( 117 : application_impl_(new ApplicationImpl(
118 delegate == nullptr ? &default_application_delegate_ : delegate, 118 client == nullptr ? &default_shell_client_ : client,
119 std::move(g_application_request))), 119 std::move(g_application_request))),
120 url_(g_url) { 120 url_(g_url) {
121 // Fake application initialization. 121 // Fake application initialization.
122 shell::mojom::Application* application = application_impl_.get(); 122 shell::mojom::Application* application = application_impl_.get();
123 application->Initialize(std::move(g_shell), g_url, g_id); 123 application->Initialize(std::move(g_shell), g_url, g_id);
124 } 124 }
125 125
126 TestHelper::~TestHelper() { 126 TestHelper::~TestHelper() {
127 // TODO: commented out until http://crbug.com/533107 is solved. 127 // TODO: commented out until http://crbug.com/533107 is solved.
128 // { 128 // {
129 // ApplicationImpl::TestApi test_api(application_impl_); 129 // ApplicationImpl::TestApi test_api(application_impl_);
130 // test_api.UnbindConnections(&g_application_request, &g_shell); 130 // test_api.UnbindConnections(&g_application_request, &g_shell);
131 // } 131 // }
132 // We may have supplied a member as the delegate. Delete |application_impl_| 132 // We may have supplied a member as the client. Delete |application_impl_|
133 // while still valid. 133 // while still valid.
134 application_impl_.reset(); 134 application_impl_.reset();
135 } 135 }
136 136
137 ApplicationTestBase::ApplicationTestBase() : test_helper_(nullptr) {} 137 ApplicationTestBase::ApplicationTestBase() : test_helper_(nullptr) {}
138 138
139 ApplicationTestBase::~ApplicationTestBase() { 139 ApplicationTestBase::~ApplicationTestBase() {
140 } 140 }
141 141
142 ApplicationDelegate* ApplicationTestBase::GetApplicationDelegate() { 142 ShellClient* ApplicationTestBase::GetShellClient() {
143 return nullptr; 143 return nullptr;
144 } 144 }
145 145
146 void ApplicationTestBase::SetUp() { 146 void ApplicationTestBase::SetUp() {
147 // A run loop is recommended for ApplicationImpl initialization and 147 // A run loop is recommended for ApplicationImpl initialization and
148 // communication. 148 // communication.
149 if (ShouldCreateDefaultRunLoop()) 149 if (ShouldCreateDefaultRunLoop())
150 Environment::InstantiateDefaultRunLoop(); 150 Environment::InstantiateDefaultRunLoop();
151 151
152 MOJO_CHECK(g_application_request.is_pending()); 152 MOJO_CHECK(g_application_request.is_pending());
153 MOJO_CHECK(g_shell); 153 MOJO_CHECK(g_shell);
154 154
155 // New applications are constructed for each test to avoid persisting state. 155 // New applications are constructed for each test to avoid persisting state.
156 test_helper_.reset(new TestHelper(GetApplicationDelegate())); 156 test_helper_.reset(new TestHelper(GetShellClient()));
157 } 157 }
158 158
159 void ApplicationTestBase::TearDown() { 159 void ApplicationTestBase::TearDown() {
160 MOJO_CHECK(!g_application_request.is_pending()); 160 MOJO_CHECK(!g_application_request.is_pending());
161 MOJO_CHECK(!g_shell); 161 MOJO_CHECK(!g_shell);
162 162
163 test_helper_.reset(); 163 test_helper_.reset();
164 164
165 if (ShouldCreateDefaultRunLoop()) 165 if (ShouldCreateDefaultRunLoop())
166 Environment::DestroyDefaultRunLoop(); 166 Environment::DestroyDefaultRunLoop();
167 } 167 }
168 168
169 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() { 169 bool ApplicationTestBase::ShouldCreateDefaultRunLoop() {
170 return true; 170 return true;
171 } 171 }
172 172
173 } // namespace test 173 } // namespace test
174 } // namespace mojo 174 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/application_runner.cc ('k') | mojo/shell/public/cpp/lib/content_handler_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698