1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/fuchsia/file_utils.h"
7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h"
9 #include "testing/gtest/include/gtest/gtest.h"
14 class OpenDirectoryTest : public testing::Test {
16 void SetUp() override {
17 EXPECT_TRUE(temp_dir.CreateUniqueTempDirUnderPath(
18 base::FilePath(kPersistedDataDirectoryPath)));
21 ScopedTempDir temp_dir;
24 TEST_F(OpenDirectoryTest, Open) {
25 auto dir = OpenDirectory(temp_dir.GetPath());
29 // OpenDirectory() should fail when opening a directory that doesn't exist.
30 TEST_F(OpenDirectoryTest, OpenNonExistent) {
31 auto dir = OpenDirectory(temp_dir.GetPath().AppendASCII("non_existent"));
35 // OpenDirectory() should open only directories.
36 TEST_F(OpenDirectoryTest, OpenFile) {
37 auto file_path = temp_dir.GetPath().AppendASCII("test_file");
38 ASSERT_TRUE(WriteFile(file_path, "foo", 3));
39 auto dir = OpenDirectory(file_path);
43 } // namespace fuchsia