Commit 98ea2a73 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Cleanup ConnectContextProvider()

1. ConnectContextProvider() was returning InterfaceHandle<ContextProvider>
and also taking InterfaceRequest<ContextProvider> argument. The result
wasn't actually used. Removed the request argument.
2. Renamed the function to StartWebEngineForTests() - this name reflects
what this function does.

Change-Id: Iede1b040a13a96860a2946e8addcf15b8dbba35c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1960668Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723649}
parent d2d70002
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h" #include "base/logging.h"
fidl::InterfaceHandle<fuchsia::web::ContextProvider> ConnectContextProvider( fuchsia::web::ContextProviderPtr StartWebEngineForTests(
fidl::InterfaceRequest<fuchsia::web::ContextProvider>
context_provider_request,
fidl::InterfaceRequest<fuchsia::sys::ComponentController> fidl::InterfaceRequest<fuchsia::sys::ComponentController>
component_controller_request, component_controller_request,
const base::CommandLine& command_line) { const base::CommandLine& command_line) {
...@@ -49,7 +47,7 @@ fidl::InterfaceHandle<fuchsia::web::ContextProvider> ConnectContextProvider( ...@@ -49,7 +47,7 @@ fidl::InterfaceHandle<fuchsia::web::ContextProvider> ConnectContextProvider(
sys::ServiceDirectory web_engine_service_dir( sys::ServiceDirectory web_engine_service_dir(
std::move(web_engine_services_dir)); std::move(web_engine_services_dir));
fidl::InterfaceHandle<fuchsia::web::ContextProvider> context_provider; fuchsia::web::ContextProviderPtr context_provider;
web_engine_service_dir.Connect(std::move(context_provider_request)); web_engine_service_dir.Connect(context_provider.NewRequest());
return context_provider; return context_provider;
} }
...@@ -11,9 +11,7 @@ ...@@ -11,9 +11,7 @@
#include "base/command_line.h" #include "base/command_line.h"
fidl::InterfaceHandle<fuchsia::web::ContextProvider> ConnectContextProvider( fuchsia::web::ContextProviderPtr StartWebEngineForTests(
fidl::InterfaceRequest<fuchsia::web::ContextProvider>
context_provider_request,
fidl::InterfaceRequest<fuchsia::sys::ComponentController> fidl::InterfaceRequest<fuchsia::sys::ComponentController>
component_controller_request, component_controller_request,
const base::CommandLine& command_line = const base::CommandLine& command_line =
......
...@@ -37,8 +37,8 @@ class WebEngineDebugIntegrationTest : public testing::Test { ...@@ -37,8 +37,8 @@ class WebEngineDebugIntegrationTest : public testing::Test {
~WebEngineDebugIntegrationTest() override = default; ~WebEngineDebugIntegrationTest() override = default;
void SetUp() override { void SetUp() override {
ConnectContextProvider(web_context_provider_.NewRequest(), web_context_provider_ =
web_context_controller_.NewRequest()); StartWebEngineForTests(web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler( web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); }); [](zx_status_t status) { ADD_FAILURE(); });
...@@ -105,7 +105,7 @@ class WebEngineDebugIntegrationTest : public testing::Test { ...@@ -105,7 +105,7 @@ class WebEngineDebugIntegrationTest : public testing::Test {
std::unique_ptr<sys::ServiceDirectory> debug_dir_; std::unique_ptr<sys::ServiceDirectory> debug_dir_;
fuchsia::web::ContextProviderPtr web_context_provider_; fuchsia::web::ContextProviderPtr web_context_provider_;
fidl::InterfaceHandle<fuchsia::sys::ComponentController> fidl::InterfaceHandle<fuchsia::sys::ComponentController>
web_context_controller_; web_engine_controller_;
fuchsia::web::DebugSyncPtr debug_; fuchsia::web::DebugSyncPtr debug_;
base::OnceClosure on_url_fetch_complete_ack_; base::OnceClosure on_url_fetch_complete_ack_;
......
...@@ -49,6 +49,13 @@ class WebEngineIntegrationTest : public testing::Test { ...@@ -49,6 +49,13 @@ class WebEngineIntegrationTest : public testing::Test {
ASSERT_TRUE(embedded_test_server_.Start()); ASSERT_TRUE(embedded_test_server_.Start());
} }
void StartWebEngine() {
web_context_provider_ =
StartWebEngineForTests(web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); });
}
fuchsia::web::CreateContextParams DefaultContextParams() const { fuchsia::web::CreateContextParams DefaultContextParams() const {
fuchsia::web::CreateContextParams create_params; fuchsia::web::CreateContextParams create_params;
auto directory = base::fuchsia::OpenDirectory( auto directory = base::fuchsia::OpenDirectory(
...@@ -139,10 +146,7 @@ class WebEngineIntegrationTest : public testing::Test { ...@@ -139,10 +146,7 @@ class WebEngineIntegrationTest : public testing::Test {
}; };
TEST_F(WebEngineIntegrationTest, ValidUserAgent) { TEST_F(WebEngineIntegrationTest, ValidUserAgent) {
ConnectContextProvider(web_context_provider_.NewRequest(), StartWebEngine();
web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); });
const std::string kEchoHeaderPath = const std::string kEchoHeaderPath =
std::string("/echoheader?") + net::HttpRequestHeaders::kUserAgent; std::string("/echoheader?") + net::HttpRequestHeaders::kUserAgent;
...@@ -189,10 +193,7 @@ TEST_F(WebEngineIntegrationTest, ValidUserAgent) { ...@@ -189,10 +193,7 @@ TEST_F(WebEngineIntegrationTest, ValidUserAgent) {
} }
TEST_F(WebEngineIntegrationTest, InvalidUserAgent) { TEST_F(WebEngineIntegrationTest, InvalidUserAgent) {
ConnectContextProvider(web_context_provider_.NewRequest(), StartWebEngine();
web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); });
const std::string kEchoHeaderPath = const std::string kEchoHeaderPath =
std::string("/echoheader?") + net::HttpRequestHeaders::kUserAgent; std::string("/echoheader?") + net::HttpRequestHeaders::kUserAgent;
...@@ -225,10 +226,7 @@ TEST_F(WebEngineIntegrationTest, InvalidUserAgent) { ...@@ -225,10 +226,7 @@ TEST_F(WebEngineIntegrationTest, InvalidUserAgent) {
// - DevTools becomes available when the first debuggable Frame is created. // - DevTools becomes available when the first debuggable Frame is created.
// - DevTools closes when the last debuggable Frame is closed. // - DevTools closes when the last debuggable Frame is closed.
TEST_F(WebEngineIntegrationTest, RemoteDebuggingPort) { TEST_F(WebEngineIntegrationTest, RemoteDebuggingPort) {
ConnectContextProvider(web_context_provider_.NewRequest(), StartWebEngine();
web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); });
// Create a Context with remote debugging enabled via an ephemeral port. // Create a Context with remote debugging enabled via an ephemeral port.
fuchsia::web::CreateContextParams create_params; fuchsia::web::CreateContextParams create_params;
...@@ -326,10 +324,7 @@ TEST_F(WebEngineIntegrationTest, RemoteDebuggingPort) { ...@@ -326,10 +324,7 @@ TEST_F(WebEngineIntegrationTest, RemoteDebuggingPort) {
// Check that remote debugging requests for Frames in non-debuggable Contexts // Check that remote debugging requests for Frames in non-debuggable Contexts
// cause an error to be reported. // cause an error to be reported.
TEST_F(WebEngineIntegrationTest, RequestDebuggableFrameInNonDebuggableContext) { TEST_F(WebEngineIntegrationTest, RequestDebuggableFrameInNonDebuggableContext) {
ConnectContextProvider(web_context_provider_.NewRequest(), StartWebEngine();
web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); });
fuchsia::web::CreateContextParams create_params = DefaultContextParams(); fuchsia::web::CreateContextParams create_params = DefaultContextParams();
...@@ -355,10 +350,7 @@ TEST_F(WebEngineIntegrationTest, RequestDebuggableFrameInNonDebuggableContext) { ...@@ -355,10 +350,7 @@ TEST_F(WebEngineIntegrationTest, RequestDebuggableFrameInNonDebuggableContext) {
// Navigates to a resource served under the "testdata" ContentDirectory. // Navigates to a resource served under the "testdata" ContentDirectory.
TEST_F(WebEngineIntegrationTest, ContentDirectoryProvider) { TEST_F(WebEngineIntegrationTest, ContentDirectoryProvider) {
ConnectContextProvider(web_context_provider_.NewRequest(), StartWebEngine();
web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); });
const GURL kUrl("fuchsia-dir://testdata/title1.html"); const GURL kUrl("fuchsia-dir://testdata/title1.html");
constexpr char kTitle[] = "title 1"; constexpr char kTitle[] = "title 1";
...@@ -381,10 +373,7 @@ TEST_F(WebEngineIntegrationTest, ContentDirectoryProvider) { ...@@ -381,10 +373,7 @@ TEST_F(WebEngineIntegrationTest, ContentDirectoryProvider) {
} }
TEST_F(WebEngineIntegrationTest, PlayAudio) { TEST_F(WebEngineIntegrationTest, PlayAudio) {
ConnectContextProvider(web_context_provider_.NewRequest(), StartWebEngine();
web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); });
fuchsia::web::CreateContextParams create_params = fuchsia::web::CreateContextParams create_params =
DefaultContextParamsWithTestData(); DefaultContextParamsWithTestData();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment