Commit d9bbaf66 authored by Wez's avatar Wez Committed by Commit Bot

[fuchsia] Use base::fuchsia::OpenDirectory() in test fixtures.

Change-Id: Id5ab1b61d754998c8452c5bfab58dd88f6e9ab46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900906
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713138}
parent 83a14a3c
......@@ -10,6 +10,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/fuchsia/file_utils.h"
#include "base/fuchsia/fuchsia_logging.h"
#include "base/path_service.h"
#include "base/test/bind_test_util.h"
......@@ -78,14 +79,14 @@ class ContentDirectoryTest : public cr_fuchsia::WebEngineBrowserTest {
provider.set_name("testdata");
base::FilePath pkg_path;
base::PathService::Get(base::DIR_ASSETS, &pkg_path);
provider.set_directory(
OpenDirectoryHandle(pkg_path.AppendASCII("fuchsia/engine/test/data")));
provider.set_directory(base::fuchsia::OpenDirectory(
pkg_path.AppendASCII("fuchsia/engine/test/data")));
providers.emplace_back(std::move(provider));
provider = {};
provider.set_name("alternate");
provider.set_directory(
OpenDirectoryHandle(pkg_path.AppendASCII("fuchsia/engine/test/data")));
provider.set_directory(base::fuchsia::OpenDirectory(
pkg_path.AppendASCII("fuchsia/engine/test/data")));
providers.emplace_back(std::move(provider));
ContentDirectoryLoaderFactory::SetContentDirectoriesForTest(
......@@ -98,24 +99,6 @@ class ContentDirectoryTest : public cr_fuchsia::WebEngineBrowserTest {
ContentDirectoryLoaderFactory::SetContentDirectoriesForTest({});
}
fidl::InterfaceHandle<fuchsia::io::Directory> OpenDirectoryHandle(
const base::FilePath& path) {
zx::channel directory_channel;
zx::channel remote_directory_channel;
zx_status_t status =
zx::channel::create(0, &directory_channel, &remote_directory_channel);
ZX_DCHECK(status == ZX_OK, status) << "zx_channel_create";
status = fdio_open(
path.value().c_str(),
fuchsia::io::OPEN_FLAG_DIRECTORY | fuchsia::io::OPEN_RIGHT_READABLE,
remote_directory_channel.release());
ZX_DCHECK(status == ZX_OK, status) << "fdio_open";
return fidl::InterfaceHandle<fuchsia::io::Directory>(
std::move(directory_channel));
}
protected:
// Creates a Frame with |navigation_listener_| attached.
fuchsia::web::FramePtr CreateFrame() {
......
......@@ -108,17 +108,6 @@ class WebEngineIntegrationTest : public testing::Test {
return value ? value->GetString() : std::string();
}
fidl::InterfaceHandle<fuchsia::io::Directory> OpenDirectoryHandle(
const base::FilePath& path) {
fidl::InterfaceHandle<fuchsia::io::Directory> directory_channel;
zx_status_t status = fdio_open(
path.value().c_str(),
fuchsia::io::OPEN_FLAG_DIRECTORY | fuchsia::io::OPEN_RIGHT_READABLE,
directory_channel.NewRequest().TakeChannel().release());
ZX_DCHECK(status == ZX_OK, status) << "fdio_open";
return directory_channel;
}
protected:
const base::test::TaskEnvironment task_environment_;
......@@ -339,8 +328,8 @@ TEST_F(WebEngineIntegrationTest, ContentDirectoryProvider) {
provider.set_name("testdata");
base::FilePath pkg_path;
CHECK(base::PathService::Get(base::DIR_ASSETS, &pkg_path));
provider.set_directory(
OpenDirectoryHandle(pkg_path.AppendASCII("fuchsia/engine/test/data")));
provider.set_directory(base::fuchsia::OpenDirectory(
pkg_path.AppendASCII("fuchsia/engine/test/data")));
create_params.mutable_content_directories()->emplace_back(
std::move(provider));
......
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