diff options
author | rockot <rockot@chromium.org> | 2015-11-12 17:33:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-13 01:34:47 +0000 |
commit | 85dce086001825a2faa4e75755a669f5e08a1cad (patch) | |
tree | 722de1d974f799b3d1ee1ca4c81bb8b0fa75a95d /mojo/runner | |
parent | 415b73b1a400a994a86e6f29709aa0271e895dd5 (diff) | |
download | chromium_src-85dce086001825a2faa4e75755a669f5e08a1cad.zip chromium_src-85dce086001825a2faa4e75755a669f5e08a1cad.tar.gz chromium_src-85dce086001825a2faa4e75755a669f5e08a1cad.tar.bz2 |
Move third_party/mojo/src/mojo/public to mojo/public
BUG=None
NOPRESUBMIT=true
Review URL: https://codereview.chromium.org/1410053006
Cr-Commit-Position: refs/heads/master@{#359461}
Diffstat (limited to 'mojo/runner')
-rw-r--r-- | mojo/runner/BUILD.gn | 2 | ||||
-rw-r--r-- | mojo/runner/android/android_handler.cc | 2 | ||||
-rw-r--r-- | mojo/runner/child/BUILD.gn | 2 | ||||
-rw-r--r-- | mojo/runner/child/runner_connection.cc | 2 | ||||
-rw-r--r-- | mojo/runner/context.cc | 2 | ||||
-rw-r--r-- | mojo/runner/host/BUILD.gn | 2 | ||||
-rw-r--r-- | mojo/runner/host/child_process.cc | 4 | ||||
-rw-r--r-- | mojo/runner/host/child_process_host.cc | 4 | ||||
-rw-r--r-- | mojo/runner/host/native_application_support.cc | 8 | ||||
-rw-r--r-- | mojo/runner/host/native_application_support.h | 2 | ||||
-rw-r--r-- | mojo/runner/shell_apptest.cc | 199 | ||||
-rw-r--r-- | mojo/runner/shell_test_base.h | 4 | ||||
-rw-r--r-- | mojo/runner/shell_test_base_unittest.cc | 4 | ||||
-rw-r--r-- | mojo/runner/test/BUILD.gn | 28 | ||||
-rw-r--r-- | mojo/runner/test/pingable_app.cc | 8 |
15 files changed, 250 insertions, 23 deletions
diff --git a/mojo/runner/BUILD.gn b/mojo/runner/BUILD.gn index 5334789..159af7d 100644 --- a/mojo/runner/BUILD.gn +++ b/mojo/runner/BUILD.gn @@ -4,8 +4,8 @@ import("//mojo/generate_mojo_shell_assets_list.gni") import("//mojo/public/mojo_application.gni") +import("//mojo/public/tools/bindings/mojom.gni") import("//testing/test.gni") -import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") group("runner") { testonly = true diff --git a/mojo/runner/android/android_handler.cc b/mojo/runner/android/android_handler.cc index 9cc4a81..98313e3 100644 --- a/mojo/runner/android/android_handler.cc +++ b/mojo/runner/android/android_handler.cc @@ -12,10 +12,10 @@ #include "jni/AndroidHandler_jni.h" #include "mojo/application/public/cpp/application_impl.h" #include "mojo/common/data_pipe_utils.h" +#include "mojo/public/c/system/main.h" #include "mojo/runner/android/run_android_application_function.h" #include "mojo/runner/host/native_application_support.h" #include "mojo/util/filename_util.h" -#include "third_party/mojo/src/mojo/public/c/system/main.h" #include "url/gurl.h" using base::android::AttachCurrentThread; diff --git a/mojo/runner/child/BUILD.gn b/mojo/runner/child/BUILD.gn index fe89ecb..edf5f97 100644 --- a/mojo/runner/child/BUILD.gn +++ b/mojo/runner/child/BUILD.gn @@ -3,7 +3,7 @@ # found in the LICENSE file. import("//mojo/public/mojo_application.gni") -import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") +import("//mojo/public/tools/bindings/mojom.gni") group("child") { testonly = true diff --git a/mojo/runner/child/runner_connection.cc b/mojo/runner/child/runner_connection.cc index 015df41..c7758c4 100644 --- a/mojo/runner/child/runner_connection.cc +++ b/mojo/runner/child/runner_connection.cc @@ -13,11 +13,11 @@ #include "base/threading/thread.h" #include "base/threading/thread_checker.h" #include "mojo/message_pump/message_pump_mojo.h" +#include "mojo/public/cpp/bindings/binding.h" #include "mojo/runner/child/child_controller.mojom.h" #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" namespace mojo { namespace runner { diff --git a/mojo/runner/context.cc b/mojo/runner/context.cc index 850cb5a..a21323b 100644 --- a/mojo/runner/context.cc +++ b/mojo/runner/context.cc @@ -28,6 +28,7 @@ #include "mojo/application/public/cpp/application_delegate.h" #include "mojo/application/public/cpp/application_impl.h" #include "mojo/package_manager/package_manager_impl.h" +#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/runner/host/in_process_native_runner.h" #include "mojo/runner/host/out_of_process_native_runner.h" #include "mojo/runner/register_local_aliases.h" @@ -43,7 +44,6 @@ #include "mojo/shell/switches.h" #include "mojo/util/filename_util.h" #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" #include "url/gurl.h" namespace mojo { diff --git a/mojo/runner/host/BUILD.gn b/mojo/runner/host/BUILD.gn index 4227baa..f1890f8 100644 --- a/mojo/runner/host/BUILD.gn +++ b/mojo/runner/host/BUILD.gn @@ -4,8 +4,8 @@ import("//mojo/generate_mojo_shell_assets_list.gni") import("//mojo/public/mojo_application.gni") +import("//mojo/public/tools/bindings/mojom.gni") import("//testing/test.gni") -import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") group("host") { testonly = true diff --git a/mojo/runner/host/child_process.cc b/mojo/runner/host/child_process.cc index fac23ec..8d2ab95 100644 --- a/mojo/runner/host/child_process.cc +++ b/mojo/runner/host/child_process.cc @@ -22,6 +22,8 @@ #include "base/threading/thread.h" #include "base/threading/thread_checker.h" #include "mojo/message_pump/message_pump_mojo.h" +#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/system/core.h" #include "mojo/runner/child/child_controller.mojom.h" #include "mojo/runner/host/native_application_support.h" #include "mojo/runner/host/switches.h" @@ -30,8 +32,6 @@ #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" #include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h" #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" -#include "third_party/mojo/src/mojo/public/cpp/system/core.h" #if defined(OS_LINUX) && !defined(OS_ANDROID) #include "base/rand_util.h" diff --git a/mojo/runner/host/child_process_host.cc b/mojo/runner/host/child_process_host.cc index 8cc2b01..6074b5b 100644 --- a/mojo/runner/host/child_process_host.cc +++ b/mojo/runner/host/child_process_host.cc @@ -14,10 +14,10 @@ #include "base/process/launch.h" #include "base/task_runner.h" #include "base/thread_task_runner_handle.h" +#include "mojo/public/cpp/bindings/interface_ptr_info.h" +#include "mojo/public/cpp/system/core.h" #include "mojo/runner/host/switches.h" #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr_info.h" -#include "third_party/mojo/src/mojo/public/cpp/system/core.h" #if defined(OS_LINUX) && !defined(OS_ANDROID) #include "sandbox/linux/services/namespace_sandbox.h" diff --git a/mojo/runner/host/native_application_support.cc b/mojo/runner/host/native_application_support.cc index eae4e98..5b53744 100644 --- a/mojo/runner/host/native_application_support.cc +++ b/mojo/runner/host/native_application_support.cc @@ -9,10 +9,10 @@ #include "base/files/file_util.h" #include "base/logging.h" #include "mojo/platform_handle/platform_handle_private_thunks.h" -#include "third_party/mojo/src/mojo/public/platform/native/gles2_impl_chromium_extension_thunks.h" -#include "third_party/mojo/src/mojo/public/platform/native/gles2_impl_thunks.h" -#include "third_party/mojo/src/mojo/public/platform/native/gles2_thunks.h" -#include "third_party/mojo/src/mojo/public/platform/native/system_thunks.h" +#include "mojo/public/platform/native/gles2_impl_chromium_extension_thunks.h" +#include "mojo/public/platform/native/gles2_impl_thunks.h" +#include "mojo/public/platform/native/gles2_thunks.h" +#include "mojo/public/platform/native/system_thunks.h" namespace mojo { namespace runner { diff --git a/mojo/runner/host/native_application_support.h b/mojo/runner/host/native_application_support.h index 209cc18..dca22de 100644 --- a/mojo/runner/host/native_application_support.h +++ b/mojo/runner/host/native_application_support.h @@ -6,7 +6,7 @@ #define MOJO_RUNNER_HOST_NATIVE_APPLICATION_SUPPORT_H_ #include "base/native_library.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" +#include "mojo/public/cpp/bindings/interface_request.h" namespace base { class FilePath; diff --git a/mojo/runner/shell_apptest.cc b/mojo/runner/shell_apptest.cc new file mode 100644 index 0000000..f0eb95c --- /dev/null +++ b/mojo/runner/shell_apptest.cc @@ -0,0 +1,199 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/base_paths.h" +#include "base/bind.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/path_service.h" +#include "base/run_loop.h" +#include "base/strings/string_util.h" +#include "base/strings/stringprintf.h" +#include "mojo/application/public/cpp/application_impl.h" +#include "mojo/application/public/cpp/application_test_base.h" +#include "mojo/common/data_pipe_utils.h" +#include "mojo/public/cpp/system/macros.h" +#include "mojo/runner/kPingable.h" +#include "mojo/runner/test/pingable.mojom.h" +#include "mojo/services/http_server/public/cpp/http_server_util.h" +#include "mojo/services/http_server/public/interfaces/http_server.mojom.h" +#include "mojo/services/http_server/public/interfaces/http_server_factory.mojom.h" +#include "mojo/services/network/public/interfaces/net_address.mojom.h" + +namespace mojo { +namespace { + +std::string GetURL(uint16_t port, const std::string& path) { + return base::StringPrintf("http://127.0.0.1:%u/%s", + static_cast<unsigned>(port), path.c_str()); +} + +class GetHandler : public http_server::HttpHandler { + public: + GetHandler(InterfaceRequest<http_server::HttpHandler> request, uint16_t port) + : binding_(this, request.Pass()), port_(port) { + } + ~GetHandler() override {} + + private: + // http_server::HttpHandler: + void HandleRequest( + http_server::HttpRequestPtr request, + const Callback<void(http_server::HttpResponsePtr)>& callback) override { + http_server::HttpResponsePtr response; + if (base::StartsWith(request->relative_url, "/app", + base::CompareCase::SENSITIVE)) { + response = http_server::CreateHttpResponse( + 200, std::string(kPingable.data, kPingable.size)); + response->content_type = "application/octet-stream"; + } else if (request->relative_url == "/redirect") { + response = http_server::HttpResponse::New(); + response->status_code = 302; + response->custom_headers.insert("Location", GetURL(port_, "app")); + } else { + NOTREACHED(); + } + + callback.Run(response.Pass()); + } + + Binding<http_server::HttpHandler> binding_; + uint16_t port_; + + MOJO_DISALLOW_COPY_AND_ASSIGN(GetHandler); +}; + +typedef test::ApplicationTestBase ShellAppTest; + +class ShellHTTPAppTest : public test::ApplicationTestBase { + public: + ShellHTTPAppTest() : ApplicationTestBase() {} + ~ShellHTTPAppTest() override {} + + protected: + // ApplicationTestBase: + void SetUp() override { + ApplicationTestBase::SetUp(); + + application_impl()->ConnectToService("mojo:http_server", + &http_server_factory_); + + NetAddressPtr local_address(NetAddress::New()); + local_address->family = NET_ADDRESS_FAMILY_IPV4; + local_address->ipv4 = NetAddressIPv4::New(); + local_address->ipv4->addr.resize(4); + local_address->ipv4->addr[0] = 127; + local_address->ipv4->addr[1] = 0; + local_address->ipv4->addr[2] = 0; + local_address->ipv4->addr[3] = 1; + local_address->ipv4->port = 0; + http_server_factory_->CreateHttpServer(GetProxy(&http_server_), + local_address.Pass()); + + http_server_->GetPort([this](uint16_t p) { port_ = p; }); + EXPECT_TRUE(http_server_.WaitForIncomingResponse()); + + InterfacePtr<http_server::HttpHandler> http_handler; + handler_.reset(new GetHandler(GetProxy(&http_handler).Pass(), port_)); + http_server_->SetHandler(".*", http_handler.Pass(), + [](bool result) { EXPECT_TRUE(result); }); + EXPECT_TRUE(http_server_.WaitForIncomingResponse()); + } + + std::string GetURL(const std::string& path) { + return ::mojo::GetURL(port_, path); + } + + http_server::HttpServerFactoryPtr http_server_factory_; + http_server::HttpServerPtr http_server_; + scoped_ptr<GetHandler> handler_; + uint16_t port_; + + private: + MOJO_DISALLOW_COPY_AND_ASSIGN(ShellHTTPAppTest); +}; + +// Test that we can load apps over http. +TEST_F(ShellHTTPAppTest, Http) { + InterfacePtr<Pingable> pingable; + application_impl()->ConnectToService(GetURL("app"), &pingable); + pingable->Ping("hello", + [this](const String& app_url, const String& connection_url, + const String& message) { + EXPECT_EQ(GetURL("app"), app_url); + EXPECT_EQ(GetURL("app"), connection_url); + EXPECT_EQ("hello", message); + base::MessageLoop::current()->QuitWhenIdle(); + }); + base::RunLoop().Run(); +} + +// Test that redirects work. +// TODO(aa): Test that apps receive the correct URL parameters. +TEST_F(ShellHTTPAppTest, Redirect) { + InterfacePtr<Pingable> pingable; + application_impl()->ConnectToService(GetURL("redirect"), &pingable); + pingable->Ping("hello", + [this](const String& app_url, const String& connection_url, + const String& message) { + EXPECT_EQ(GetURL("app"), app_url); + EXPECT_EQ(GetURL("app"), connection_url); + EXPECT_EQ("hello", message); + base::MessageLoop::current()->QuitWhenIdle(); + }); + base::RunLoop().Run(); +} + +// Test that querystring is not considered when resolving http applications. +// TODO(aa|qsr): Fix this test on Linux ASAN http://crbug.com/463662 +#if defined(ADDRESS_SANITIZER) +#define MAYBE_QueryHandling DISABLED_QueryHandling +#else +#define MAYBE_QueryHandling QueryHandling +#endif // ADDRESS_SANITIZER +TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) { + InterfacePtr<Pingable> pingable1; + InterfacePtr<Pingable> pingable2; + application_impl()->ConnectToService(GetURL("app?foo"), &pingable1); + application_impl()->ConnectToService(GetURL("app?bar"), &pingable2); + + int num_responses = 0; + auto callback = [this, &num_responses](const String& app_url, + const String& connection_url, + const String& message) { + EXPECT_EQ(GetURL("app"), app_url); + EXPECT_EQ("hello", message); + ++num_responses; + if (num_responses == 1) { + EXPECT_EQ(GetURL("app?foo"), connection_url); + } else if (num_responses == 2) { + EXPECT_EQ(GetURL("app?bar"), connection_url); + base::MessageLoop::current()->QuitWhenIdle(); + } else { + CHECK(false); + } + }; + pingable1->Ping("hello", callback); + pingable2->Ping("hello", callback); + base::RunLoop().Run(); +} + +// mojo: URLs can have querystrings too +TEST_F(ShellAppTest, MojoURLQueryHandling) { + InterfacePtr<Pingable> pingable; + application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); + auto callback = [this](const String& app_url, const String& connection_url, + const String& message) { + EXPECT_TRUE(base::EndsWith(app_url, "/pingable_app.mojo", + base::CompareCase::SENSITIVE)); + EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); + EXPECT_EQ("hello", message); + base::MessageLoop::current()->QuitWhenIdle(); + }; + pingable->Ping("hello", callback); + base::RunLoop().Run(); +} + +} // namespace +} // namespace mojo diff --git a/mojo/runner/shell_test_base.h b/mojo/runner/shell_test_base.h index 861b023..73343a8 100644 --- a/mojo/runner/shell_test_base.h +++ b/mojo/runner/shell_test_base.h @@ -9,10 +9,10 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" +#include "mojo/public/cpp/bindings/interface_ptr_info.h" +#include "mojo/public/cpp/system/core.h" #include "mojo/runner/context.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr_info.h" -#include "third_party/mojo/src/mojo/public/cpp/system/core.h" class GURL; diff --git a/mojo/runner/shell_test_base_unittest.cc b/mojo/runner/shell_test_base_unittest.cc index 3d2cca1..998d55b 100644 --- a/mojo/runner/shell_test_base_unittest.cc +++ b/mojo/runner/shell_test_base_unittest.cc @@ -9,11 +9,11 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" +#include "mojo/public/cpp/bindings/interface_ptr.h" +#include "mojo/public/cpp/system/core.h" #include "mojo/services/test_service/test_request_tracker.mojom.h" #include "mojo/services/test_service/test_service.mojom.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h" -#include "third_party/mojo/src/mojo/public/cpp/system/core.h" #include "url/gurl.h" using mojo::test::ServiceReport; diff --git a/mojo/runner/test/BUILD.gn b/mojo/runner/test/BUILD.gn new file mode 100644 index 0000000..bd94a9d --- /dev/null +++ b/mojo/runner/test/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//mojo/public/mojo_application.gni") +import("//mojo/public/tools/bindings/mojom.gni") + +mojom("bindings") { + sources = [ + "pingable.mojom", + ] +} + +mojo_native_application("pingable_app") { + output_name = "pingable_app" + + testonly = true + + sources = [ + "pingable_app.cc", + ] + + deps = [ + ":bindings", + "//mojo/application/public/cpp", + "//mojo/public/cpp/bindings:callback", + ] +} diff --git a/mojo/runner/test/pingable_app.cc b/mojo/runner/test/pingable_app.cc index f700044..2930a51 100644 --- a/mojo/runner/test/pingable_app.cc +++ b/mojo/runner/test/pingable_app.cc @@ -6,11 +6,11 @@ #include "mojo/application/public/cpp/application_impl.h" #include "mojo/application/public/cpp/application_runner.h" #include "mojo/application/public/cpp/interface_factory.h" +#include "mojo/public/c/system/main.h" +#include "mojo/public/cpp/bindings/callback.h" +#include "mojo/public/cpp/bindings/interface_request.h" +#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/runner/test/pingable.mojom.h" -#include "third_party/mojo/src/mojo/public/c/system/main.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" namespace mojo { |