Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Unified Diff: sandbox/src/win_utils_unittest.cc

Issue 10689170: Move the Windows sandbox to sandbox/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on top of tree (properly this time) Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/src/win_utils.cc ('k') | sandbox/src/window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/src/win_utils_unittest.cc
diff --git a/sandbox/src/win_utils_unittest.cc b/sandbox/src/win_utils_unittest.cc
deleted file mode 100644
index 0f445ef9308e7fafc681c6d28c835d642ebd7fef..0000000000000000000000000000000000000000
--- a/sandbox/src/win_utils_unittest.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <windows.h>
-
-#include "base/win/scoped_handle.h"
-#include "sandbox/src/win_utils.h"
-#include "sandbox/tests/common/test_utils.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-TEST(WinUtils, IsReparsePoint) {
- using sandbox::IsReparsePoint;
-
- // Create a temp file because we need write access to it.
- wchar_t temp_directory[MAX_PATH];
- wchar_t my_folder[MAX_PATH];
- ASSERT_NE(::GetTempPath(MAX_PATH, temp_directory), 0u);
- ASSERT_NE(::GetTempFileName(temp_directory, L"test", 0, my_folder), 0u);
-
- // Delete the file and create a directory instead.
- ASSERT_TRUE(::DeleteFile(my_folder));
- ASSERT_TRUE(::CreateDirectory(my_folder, NULL));
-
- bool result = true;
- EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(my_folder, &result));
- EXPECT_FALSE(result);
-
- // We have to fix Bug 32224 to pass this test.
- std::wstring not_found = std::wstring(my_folder) + L"\\foo\\bar";
- // EXPECT_EQ(ERROR_PATH_NOT_FOUND, IsReparsePoint(not_found, &result));
-
- std::wstring new_file = std::wstring(my_folder) + L"\\foo";
- EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(new_file, &result));
- EXPECT_FALSE(result);
-
- // Replace the directory with a reparse point to %temp%.
- HANDLE dir = ::CreateFile(my_folder, FILE_ALL_ACCESS,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
- OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- EXPECT_NE(INVALID_HANDLE_VALUE, dir);
-
- std::wstring temp_dir_nt = std::wstring(L"\\??\\") + temp_directory;
- EXPECT_TRUE(SetReparsePoint(dir, temp_dir_nt.c_str()));
-
- EXPECT_EQ(ERROR_SUCCESS, IsReparsePoint(new_file, &result));
- EXPECT_TRUE(result);
-
- EXPECT_TRUE(DeleteReparsePoint(dir));
- EXPECT_TRUE(::CloseHandle(dir));
- EXPECT_TRUE(::RemoveDirectory(my_folder));
-}
-
-TEST(WinUtils, SameObject) {
- using sandbox::SameObject;
-
- // Create a temp file because we need write access to it.
- wchar_t temp_directory[MAX_PATH];
- wchar_t my_folder[MAX_PATH];
- ASSERT_NE(::GetTempPath(MAX_PATH, temp_directory), 0u);
- ASSERT_NE(::GetTempFileName(temp_directory, L"test", 0, my_folder), 0u);
-
- // Delete the file and create a directory instead.
- ASSERT_TRUE(::DeleteFile(my_folder));
- ASSERT_TRUE(::CreateDirectory(my_folder, NULL));
-
- std::wstring folder(my_folder);
- std::wstring file_name = folder + L"\\foo.txt";
- const ULONG kSharing = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
- base::win::ScopedHandle file(CreateFile(
- file_name.c_str(), GENERIC_WRITE, kSharing, NULL, CREATE_ALWAYS,
- FILE_FLAG_DELETE_ON_CLOSE, NULL));
-
- EXPECT_TRUE(file.IsValid());
- std::wstring file_name_nt1 = std::wstring(L"\\??\\") + file_name;
- std::wstring file_name_nt2 = std::wstring(L"\\??\\") + folder + L"\\FOO.txT";
- EXPECT_TRUE(SameObject(file.Get(), file_name_nt1.c_str()));
- EXPECT_TRUE(SameObject(file.Get(), file_name_nt2.c_str()));
-
- file.Close();
- EXPECT_TRUE(::RemoveDirectory(my_folder));
-}
« no previous file with comments | « sandbox/src/win_utils.cc ('k') | sandbox/src/window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698