OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "sandbox/src/win_utils.h" | 7 #include "sandbox/src/win_utils.h" |
8 #include "sandbox/tests/common/test_utils.h" | 8 #include "sandbox/tests/common/test_utils.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 TEST(WinUtils, IsReparsePoint) { | 11 TEST(WinUtils, IsReparsePoint) { |
12 using sandbox::IsReparsePoint; | 12 using sandbox::IsReparsePoint; |
13 | 13 |
14 // Create a temp file because we need write access to it. | 14 // Create a temp file because we need write access to it. |
15 wchar_t temp_directory[MAX_PATH]; | 15 wchar_t temp_directory[MAX_PATH]; |
16 wchar_t my_folder[MAX_PATH]; | 16 wchar_t my_folder[MAX_PATH]; |
17 ASSERT_NE(::GetTempPath(MAX_PATH, temp_directory), 0); | 17 ASSERT_NE(::GetTempPath(MAX_PATH, temp_directory), 0u); |
18 ASSERT_NE(::GetTempFileName(temp_directory, L"test", 0, my_folder), 0); | 18 ASSERT_NE(::GetTempFileName(temp_directory, L"test", 0, my_folder), 0u); |
19 | 19 |
20 // Delete the file and create a directory instead. | 20 // Delete the file and create a directory instead. |
21 ASSERT_TRUE(::DeleteFile(my_folder)); | 21 ASSERT_TRUE(::DeleteFile(my_folder)); |
22 ASSERT_TRUE(::CreateDirectory(my_folder, NULL)); | 22 ASSERT_TRUE(::CreateDirectory(my_folder, NULL)); |
23 | 23 |
24 bool result = true; | 24 bool result = true; |
25 EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(my_folder, &result)); | 25 EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(my_folder, &result)); |
26 EXPECT_FALSE(result); | 26 EXPECT_FALSE(result); |
27 | 27 |
28 // We have to fix Bug 32224 to pass this test. | 28 // We have to fix Bug 32224 to pass this test. |
(...skipping 13 matching lines...) Expand all Loading... |
42 std::wstring temp_dir_nt = std::wstring(L"\\??\\") + temp_directory; | 42 std::wstring temp_dir_nt = std::wstring(L"\\??\\") + temp_directory; |
43 EXPECT_TRUE(SetReparsePoint(dir, temp_dir_nt.c_str())); | 43 EXPECT_TRUE(SetReparsePoint(dir, temp_dir_nt.c_str())); |
44 | 44 |
45 EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(new_file, &result)); | 45 EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(new_file, &result)); |
46 EXPECT_TRUE(result); | 46 EXPECT_TRUE(result); |
47 | 47 |
48 EXPECT_TRUE(DeleteReparsePoint(dir)); | 48 EXPECT_TRUE(DeleteReparsePoint(dir)); |
49 EXPECT_TRUE(::CloseHandle(dir)); | 49 EXPECT_TRUE(::CloseHandle(dir)); |
50 EXPECT_TRUE(::RemoveDirectory(my_folder)); | 50 EXPECT_TRUE(::RemoveDirectory(my_folder)); |
51 } | 51 } |
OLD | NEW |