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

Side by Side Diff: mojo/runner/shell_apptest.cc

Issue 1402533003: Don't use base::MessageLoop::{Quit,QuitClosure} in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Test that we can load apps over http. 117 // Test that we can load apps over http.
118 TEST_F(ShellHTTPAppTest, Http) { 118 TEST_F(ShellHTTPAppTest, Http) {
119 InterfacePtr<Pingable> pingable; 119 InterfacePtr<Pingable> pingable;
120 application_impl()->ConnectToService(GetURL("app"), &pingable); 120 application_impl()->ConnectToService(GetURL("app"), &pingable);
121 pingable->Ping("hello", 121 pingable->Ping("hello",
122 [this](const String& app_url, const String& connection_url, 122 [this](const String& app_url, const String& connection_url,
123 const String& message) { 123 const String& message) {
124 EXPECT_EQ(GetURL("app"), app_url); 124 EXPECT_EQ(GetURL("app"), app_url);
125 EXPECT_EQ(GetURL("app"), connection_url); 125 EXPECT_EQ(GetURL("app"), connection_url);
126 EXPECT_EQ("hello", message); 126 EXPECT_EQ("hello", message);
127 base::MessageLoop::current()->Quit(); 127 base::MessageLoop::current()->QuitWhenIdle();
128 }); 128 });
129 base::RunLoop().Run(); 129 base::RunLoop().Run();
130 } 130 }
131 131
132 // Test that redirects work. 132 // Test that redirects work.
133 // TODO(aa): Test that apps receive the correct URL parameters. 133 // TODO(aa): Test that apps receive the correct URL parameters.
134 TEST_F(ShellHTTPAppTest, Redirect) { 134 TEST_F(ShellHTTPAppTest, Redirect) {
135 InterfacePtr<Pingable> pingable; 135 InterfacePtr<Pingable> pingable;
136 application_impl()->ConnectToService(GetURL("redirect"), &pingable); 136 application_impl()->ConnectToService(GetURL("redirect"), &pingable);
137 pingable->Ping("hello", 137 pingable->Ping("hello",
138 [this](const String& app_url, const String& connection_url, 138 [this](const String& app_url, const String& connection_url,
139 const String& message) { 139 const String& message) {
140 EXPECT_EQ(GetURL("app"), app_url); 140 EXPECT_EQ(GetURL("app"), app_url);
141 EXPECT_EQ(GetURL("app"), connection_url); 141 EXPECT_EQ(GetURL("app"), connection_url);
142 EXPECT_EQ("hello", message); 142 EXPECT_EQ("hello", message);
143 base::MessageLoop::current()->Quit(); 143 base::MessageLoop::current()->QuitWhenIdle();
144 }); 144 });
145 base::RunLoop().Run(); 145 base::RunLoop().Run();
146 } 146 }
147 147
148 // Test that querystring is not considered when resolving http applications. 148 // Test that querystring is not considered when resolving http applications.
149 // TODO(aa|qsr): Fix this test on Linux ASAN http://crbug.com/463662 149 // TODO(aa|qsr): Fix this test on Linux ASAN http://crbug.com/463662
150 #if defined(ADDRESS_SANITIZER) 150 #if defined(ADDRESS_SANITIZER)
151 #define MAYBE_QueryHandling DISABLED_QueryHandling 151 #define MAYBE_QueryHandling DISABLED_QueryHandling
152 #else 152 #else
153 #define MAYBE_QueryHandling QueryHandling 153 #define MAYBE_QueryHandling QueryHandling
154 #endif // ADDRESS_SANITIZER 154 #endif // ADDRESS_SANITIZER
155 TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) { 155 TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) {
156 InterfacePtr<Pingable> pingable1; 156 InterfacePtr<Pingable> pingable1;
157 InterfacePtr<Pingable> pingable2; 157 InterfacePtr<Pingable> pingable2;
158 application_impl()->ConnectToService(GetURL("app?foo"), &pingable1); 158 application_impl()->ConnectToService(GetURL("app?foo"), &pingable1);
159 application_impl()->ConnectToService(GetURL("app?bar"), &pingable2); 159 application_impl()->ConnectToService(GetURL("app?bar"), &pingable2);
160 160
161 int num_responses = 0; 161 int num_responses = 0;
162 auto callback = [this, &num_responses](const String& app_url, 162 auto callback = [this, &num_responses](const String& app_url,
163 const String& connection_url, 163 const String& connection_url,
164 const String& message) { 164 const String& message) {
165 EXPECT_EQ(GetURL("app"), app_url); 165 EXPECT_EQ(GetURL("app"), app_url);
166 EXPECT_EQ("hello", message); 166 EXPECT_EQ("hello", message);
167 ++num_responses; 167 ++num_responses;
168 if (num_responses == 1) { 168 if (num_responses == 1) {
169 EXPECT_EQ(GetURL("app?foo"), connection_url); 169 EXPECT_EQ(GetURL("app?foo"), connection_url);
170 } else if (num_responses == 2) { 170 } else if (num_responses == 2) {
171 EXPECT_EQ(GetURL("app?bar"), connection_url); 171 EXPECT_EQ(GetURL("app?bar"), connection_url);
172 base::MessageLoop::current()->Quit(); 172 base::MessageLoop::current()->QuitWhenIdle();
173 } else { 173 } else {
174 CHECK(false); 174 CHECK(false);
175 } 175 }
176 }; 176 };
177 pingable1->Ping("hello", callback); 177 pingable1->Ping("hello", callback);
178 pingable2->Ping("hello", callback); 178 pingable2->Ping("hello", callback);
179 base::RunLoop().Run(); 179 base::RunLoop().Run();
180 } 180 }
181 181
182 // mojo: URLs can have querystrings too 182 // mojo: URLs can have querystrings too
183 TEST_F(ShellAppTest, MojoURLQueryHandling) { 183 TEST_F(ShellAppTest, MojoURLQueryHandling) {
184 InterfacePtr<Pingable> pingable; 184 InterfacePtr<Pingable> pingable;
185 application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); 185 application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable);
186 auto callback = [this](const String& app_url, const String& connection_url, 186 auto callback = [this](const String& app_url, const String& connection_url,
187 const String& message) { 187 const String& message) {
188 EXPECT_TRUE(base::EndsWith(app_url, "/pingable_app.mojo", 188 EXPECT_TRUE(base::EndsWith(app_url, "/pingable_app.mojo",
189 base::CompareCase::SENSITIVE)); 189 base::CompareCase::SENSITIVE));
190 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); 190 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url);
191 EXPECT_EQ("hello", message); 191 EXPECT_EQ("hello", message);
192 base::MessageLoop::current()->Quit(); 192 base::MessageLoop::current()->QuitWhenIdle();
193 }; 193 };
194 pingable->Ping("hello", callback); 194 pingable->Ping("hello", callback);
195 base::RunLoop().Run(); 195 base::RunLoop().Run();
196 } 196 }
197 197
198 } // namespace 198 } // namespace
199 } // namespace mojo 199 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/native_runner_unittest.cc ('k') | mojo/services/test_service/test_service_application.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698