Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
tonic
filesystem
tests
scoped_temp_dir_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/scoped_temp_dir.h"
6
#include "filesystem/directory.h"
7
#include "
filesystem/path.h
"
8
#include "gtest/gtest.h"
9
10
namespace
filesystem
{
11
12
TEST
(ScopedTempDir, Creation) {
13
ScopedTempDir dir;
14
15
EXPECT_TRUE
(IsDirectory(dir.
path
()));
16
}
17
18
TEST
(ScopedTempDir, Deletion) {
19
std::string path;
20
{
21
ScopedTempDir dir;
22
path = dir.
path
();
23
}
24
25
EXPECT_FALSE(IsDirectory(path));
26
}
27
28
TEST
(ScopedTempDir, NewTempFile) {
29
ScopedTempDir dir;
30
std::string path;
31
EXPECT_TRUE
(dir.NewTempFile(&path));
32
EXPECT_FALSE(path.empty());
33
}
34
35
TEST
(ScopedTempDir, CustomParent) {
36
ScopedTempDir root_dir;
37
std::string parent = root_dir.path() +
"/a/b/c"
;
38
std::string path;
39
{
40
ScopedTempDir dir(parent);
41
path = dir.
path
();
42
EXPECT_TRUE
(IsDirectory(path));
43
EXPECT_EQ(path.substr(0, parent.size()), parent);
44
EXPECT_NE(
"temp_dir_XXXXXX"
,
GetBaseName
(path));
45
46
// Regression test - don't create temp_dir_XXXXXX dir next to the temp one.
47
EXPECT_FALSE(
48
files::IsDirectory(
GetDirectoryName
(path) +
"/temp_dir_XXXXXX"
));
49
}
50
51
// Verify that the tmp directory itself was deleted, but not the parent.
52
EXPECT_FALSE(IsDirectory(path));
53
EXPECT_TRUE
(IsDirectory(parent));
54
}
55
56
}
// namespace filesystem
TEST
#define TEST(S, s, D, expected)
Definition
FitsInTest.cpp:15
flutter::CanvasPath::path
const SkPath & path() const
Definition
path.h:117
filesystem
Definition
file.cc:29
filesystem::GetBaseName
std::string GetBaseName(const std::string &path)
Definition
path_posix.cc:169
filesystem::GetDirectoryName
std::string GetDirectoryName(const std::string &path)
Definition
path_posix.cc:160
path.h
EXPECT_TRUE
#define EXPECT_TRUE(handle)
Definition
unit_test.h:685
Generated on Fri Apr 26 2024 06:18:17 for Flutter Engine by
1.9.8