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

Side by Side Diff: shell/shell_apptest.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
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 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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "mojo/converters/base/base_type_converters.h"
13 #include "mojo/data_pipe_utils/data_pipe_utils.h" 14 #include "mojo/data_pipe_utils/data_pipe_utils.h"
14 #include "mojo/public/cpp/application/application_impl.h" 15 #include "mojo/public/cpp/application/application_impl.h"
15 #include "mojo/public/cpp/application/application_test_base.h" 16 #include "mojo/public/cpp/application/application_test_base.h"
16 #include "mojo/public/cpp/application/connect.h" 17 #include "mojo/public/cpp/application/connect.h"
17 #include "mojo/public/cpp/system/macros.h" 18 #include "mojo/public/cpp/system/macros.h"
18 #include "mojo/public/interfaces/application/application_connector.mojom.h" 19 #include "mojo/public/interfaces/application/application_connector.mojom.h"
19 #include "mojo/services/http_server/cpp/http_server_util.h" 20 #include "mojo/services/http_server/cpp/http_server_util.h"
20 #include "mojo/services/http_server/interfaces/http_server.mojom.h" 21 #include "mojo/services/http_server/interfaces/http_server.mojom.h"
21 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h" 22 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h"
22 #include "mojo/services/network/interfaces/net_address.mojom.h" 23 #include "mojo/services/network/interfaces/net_address.mojom.h"
(...skipping 15 matching lines...) Expand all
38 uint16_t port) 39 uint16_t port)
39 : binding_(this, request.Pass()), port_(port) {} 40 : binding_(this, request.Pass()), port_(port) {}
40 ~GetHandler() override {} 41 ~GetHandler() override {}
41 42
42 private: 43 private:
43 // http_server::HttpHandler: 44 // http_server::HttpHandler:
44 void HandleRequest(http_server::HttpRequestPtr request, 45 void HandleRequest(http_server::HttpRequestPtr request,
45 const mojo::Callback<void(http_server::HttpResponsePtr)>& 46 const mojo::Callback<void(http_server::HttpResponsePtr)>&
46 callback) override { 47 callback) override {
47 http_server::HttpResponsePtr response; 48 http_server::HttpResponsePtr response;
48 if (StartsWithASCII(request->relative_url, "/app", true)) { 49 if (base::StartsWith(request->relative_url.To<base::StringPiece>(), "/app",
50 base::CompareCase::SENSITIVE)) {
49 response = http_server::CreateHttpResponse( 51 response = http_server::CreateHttpResponse(
50 200, std::string(shell::test::kPingable.data, 52 200, std::string(shell::test::kPingable.data,
51 shell::test::kPingable.size)); 53 shell::test::kPingable.size));
52 response->content_type = "application/octet-stream"; 54 response->content_type = "application/octet-stream";
53 } else if (request->relative_url == "/redirect") { 55 } else if (request->relative_url == "/redirect") {
54 response = http_server::HttpResponse::New(); 56 response = http_server::HttpResponse::New();
55 response->status_code = 302; 57 response->status_code = 302;
56 response->custom_headers.insert("Location", GetURL(port_, "app")); 58 response->custom_headers.insert("Location", GetURL(port_, "app"));
57 } else { 59 } else {
58 NOTREACHED(); 60 NOTREACHED();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 pingable2->Ping("hello", callbacks_builder(2)); 183 pingable2->Ping("hello", callbacks_builder(2));
182 base::RunLoop().Run(); 184 base::RunLoop().Run();
183 } 185 }
184 186
185 // mojo: URLs can have querystrings too 187 // mojo: URLs can have querystrings too
186 TEST_F(ShellAppTest, MojoURLQueryHandling) { 188 TEST_F(ShellAppTest, MojoURLQueryHandling) {
187 PingablePtr pingable; 189 PingablePtr pingable;
188 application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); 190 application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable);
189 auto callback = [](const String& app_url, const String& connection_url, 191 auto callback = [](const String& app_url, const String& connection_url,
190 const String& message) { 192 const String& message) {
191 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); 193 EXPECT_TRUE(base::EndsWith(app_url.To<base::StringPiece>(),
194 "/pingable_app.mojo",
195 base::CompareCase::SENSITIVE));
192 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); 196 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url);
193 EXPECT_EQ("hello", message); 197 EXPECT_EQ("hello", message);
194 base::MessageLoop::current()->Quit(); 198 base::MessageLoop::current()->Quit();
195 }; 199 };
196 pingable->Ping("hello", callback); 200 pingable->Ping("hello", callback);
197 base::RunLoop().Run(); 201 base::RunLoop().Run();
198 } 202 }
199 203
200 void TestApplicationConnector(mojo::ApplicationConnector* app_connector) { 204 void TestApplicationConnector(mojo::ApplicationConnector* app_connector) {
201 PingablePtr pingable; 205 PingablePtr pingable;
202 ConnectToService(app_connector, "mojo:pingable_app", &pingable); 206 ConnectToService(app_connector, "mojo:pingable_app", &pingable);
203 auto callback = [](const String& app_url, const String& connection_url, 207 auto callback = [](const String& app_url, const String& connection_url,
204 const String& message) { 208 const String& message) {
205 EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); 209 EXPECT_TRUE(base::EndsWith(app_url.To<base::StringPiece>(),
210 "/pingable_app.mojo",
211 base::CompareCase::SENSITIVE));
206 EXPECT_EQ(app_url, connection_url); 212 EXPECT_EQ(app_url, connection_url);
207 EXPECT_EQ("hello", message); 213 EXPECT_EQ("hello", message);
208 base::MessageLoop::current()->Quit(); 214 base::MessageLoop::current()->Quit();
209 }; 215 };
210 pingable->Ping("hello", callback); 216 pingable->Ping("hello", callback);
211 base::RunLoop().Run(); 217 base::RunLoop().Run();
212 } 218 }
213 219
214 TEST_F(ShellAppTest, ApplicationConnector) { 220 TEST_F(ShellAppTest, ApplicationConnector) {
215 mojo::ApplicationConnectorPtr app_connector; 221 mojo::ApplicationConnectorPtr app_connector;
(...skipping 17 matching lines...) Expand all
233 } 239 }
234 240
235 // The first one should still work. 241 // The first one should still work.
236 { 242 {
237 SCOPED_TRACE("app_connector1 again"); 243 SCOPED_TRACE("app_connector1 again");
238 TestApplicationConnector(app_connector1.get()); 244 TestApplicationConnector(app_connector1.get());
239 } 245 }
240 } 246 }
241 247
242 } // namespace 248 } // namespace
OLDNEW
« no previous file with comments | « shell/filename_util.cc ('k') | testing/android/native_test/java/src/org/chromium/native_test/NativeUnitTestActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698