Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
10namespace filesystem {
11
12TEST(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
28 EXPECT_TRUE(IsDirectory("qux"));
29
30 EXPECT_EQ(0, chdir(cwd.c_str()));
31
32 std::string abs_path = dir.path() + "/another/one";
34 EXPECT_TRUE(IsDirectory(abs_path));
35}
36
37} // namespace filesystem
#define TEST(S, s, D, expected)
const SkPath & path() const
Definition path.h:117
#define EXPECT_TRUE(handle)
Definition unit_test.h:685
#define CreateDirectory
#define GetCurrentDirectory