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

Side by Side Diff: shell/shell_apptest.cc

Issue 1367863004: Fix ShellHTTPAppTest#QueryHandling test. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 #else 150 #else
151 #define MAYBE_QueryHandling QueryHandling 151 #define MAYBE_QueryHandling QueryHandling
152 #endif // ADDRESS_SANITIZER 152 #endif // ADDRESS_SANITIZER
153 TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) { 153 TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) {
154 PingablePtr pingable1; 154 PingablePtr pingable1;
155 PingablePtr pingable2; 155 PingablePtr pingable2;
156 application_impl()->ConnectToService(GetURL("app?foo"), &pingable1); 156 application_impl()->ConnectToService(GetURL("app?foo"), &pingable1);
157 application_impl()->ConnectToService(GetURL("app?bar"), &pingable2); 157 application_impl()->ConnectToService(GetURL("app?bar"), &pingable2);
158 158
159 int num_responses = 0; 159 int num_responses = 0;
160 auto callback = [this, &num_responses](const String& app_url, 160 auto callbacks_builder = [this, &num_responses](int query_index) {
161 const String& connection_url, 161 return [this, &num_responses, query_index](const String& app_url,
162 const String& message) { 162 const String& connection_url,
163 EXPECT_EQ(GetURL("app"), app_url); 163 const String& message) {
164 EXPECT_EQ("hello", message); 164 EXPECT_EQ(GetURL("app"), app_url);
165 ++num_responses; 165 EXPECT_EQ("hello", message);
166 if (num_responses == 1) { 166 if (query_index == 1) {
167 EXPECT_EQ(GetURL("app?foo"), connection_url); 167 EXPECT_EQ(GetURL("app?foo"), connection_url);
168 } else if (num_responses == 2) { 168 } else if (query_index == 2) {
169 EXPECT_EQ(GetURL("app?bar"), connection_url); 169 EXPECT_EQ(GetURL("app?bar"), connection_url);
170 base::MessageLoop::current()->Quit(); 170 } else {
171 } else { 171 CHECK(false);
172 CHECK(false); 172 }
173 } 173 ++num_responses;
174 if (num_responses == 2)
175 base::MessageLoop::current()->Quit();
176 };
174 }; 177 };
175 pingable1->Ping("hello", callback); 178 pingable1->Ping("hello", callbacks_builder(1));
176 pingable2->Ping("hello", callback); 179 pingable2->Ping("hello", callbacks_builder(2));
177 base::RunLoop().Run(); 180 base::RunLoop().Run();
178 } 181 }
179 182
180 // mojo: URLs can have querystrings too 183 // mojo: URLs can have querystrings too
181 TEST_F(ShellAppTest, MojoURLQueryHandling) { 184 TEST_F(ShellAppTest, MojoURLQueryHandling) {
182 PingablePtr pingable; 185 PingablePtr pingable;
183 application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); 186 application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable);
184 auto callback = [this](const String& app_url, const String& connection_url, 187 auto callback = [this](const String& app_url, const String& connection_url,
185 const String& message) { 188 const String& message) {
186 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); 189 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true));
187 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); 190 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url);
188 EXPECT_EQ("hello", message); 191 EXPECT_EQ("hello", message);
189 base::MessageLoop::current()->Quit(); 192 base::MessageLoop::current()->Quit();
190 }; 193 };
191 pingable->Ping("hello", callback); 194 pingable->Ping("hello", callback);
192 base::RunLoop().Run(); 195 base::RunLoop().Run();
193 } 196 }
194 197
195 } // namespace 198 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698