Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
file_win_unittests.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 "flutter/fml/file.h"
6
7#include <Fileapi.h>
8
9#include "flutter/fml/platform/win/wstring_conversion.h"
10#include "gtest/gtest.h"
11
12namespace fml {
13namespace testing {
14
15TEST(FileWin, OpenDirectoryShare) {
17 auto temp_path = Utf8ToWideString({temp_dir.path()});
18 fml::UniqueFD handle(
19 CreateFile(temp_path.c_str(), GENERIC_WRITE,
20 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING,
21 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, nullptr));
22 ASSERT_TRUE(handle.is_valid());
23
24 // Check that fml::OpenDirectory(FilePermission::kRead) works with a
25 // directory that has also been opened for writing.
26 auto dir = fml::OpenDirectory(temp_dir.path().c_str(), false,
28 ASSERT_TRUE(dir.is_valid());
29}
30
31} // namespace testing
32} // namespace fml
#define TEST(S, s, D, expected)
const std::string & path() const
Definition file.h:146
std::wstring Utf8ToWideString(const std::string_view str)
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition file_posix.cc:97
#define CreateFile