Flutter Engine
directory_unittest.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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.
4 
5 #include "filesystem/directory.h"
6 #include "filesystem/path.h"
7 #include "filesystem/scoped_temp_dir.h"
8 #include "gtest/gtest.h"
9 
10 namespace filesystem {
11 
12 TEST(Directory, CreateDirectory) {
13  std::string cwd = GetCurrentDirectory();
14 
15  ScopedTempDir dir;
16  EXPECT_TRUE(IsDirectory(dir.path()));
17  EXPECT_EQ(0, chdir(dir.path().c_str()));
18 
19  EXPECT_TRUE(CreateDirectory("foo/bar"));
20  EXPECT_TRUE(IsDirectory("foo"));
21  EXPECT_TRUE(IsDirectory("foo/bar"));
22  EXPECT_FALSE(IsDirectory("foo/bar/baz"));
23 
24  EXPECT_TRUE(CreateDirectory("foo/bar/baz"));
25  EXPECT_TRUE(IsDirectory("foo/bar/baz"));
26 
27  EXPECT_TRUE(CreateDirectory("qux"));
28  EXPECT_TRUE(IsDirectory("qux"));
29 
30  EXPECT_EQ(0, chdir(cwd.c_str()));
31 
32  std::string abs_path = dir.path() + "/another/one";
33  EXPECT_TRUE(CreateDirectory(abs_path));
34  EXPECT_TRUE(IsDirectory(abs_path));
35 }
36 
37 } // namespace filesystem
TEST(Directory, CreateDirectory)
bool IsDirectory(const fml::UniqueFD &directory)
Definition: file_posix.cc:124
static fml::UniqueFD CreateDirectory(const fml::UniqueFD &base_directory, const std::vector< std::string > &components, FilePermission permission, size_t index)
Definition: file.cc:12