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

Side by Side Diff: base/file_util_unittest.cc

Issue 3031041: Fix incorect tests against INVALID_FILE_HANDLE, as pointed out by cpu on chrome-team. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Rebase for checkin. Created 10 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/file_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <winioctl.h> 9 #include <winioctl.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 FilePath to_sub_a = base_b.Append(FPL("to_sub_a")); 568 FilePath to_sub_a = base_b.Append(FPL("to_sub_a"));
569 ASSERT_TRUE(file_util::CreateDirectory(to_sub_a)); 569 ASSERT_TRUE(file_util::CreateDirectory(to_sub_a));
570 ScopedHandle reparse_to_sub_a( 570 ScopedHandle reparse_to_sub_a(
571 ::CreateFile(to_sub_a.value().c_str(), 571 ::CreateFile(to_sub_a.value().c_str(),
572 FILE_ALL_ACCESS, 572 FILE_ALL_ACCESS,
573 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 573 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
574 NULL, 574 NULL,
575 OPEN_EXISTING, 575 OPEN_EXISTING,
576 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. 576 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
577 NULL)); 577 NULL));
578 ASSERT_NE(INVALID_HANDLE_VALUE, reparse_to_sub_a.Get()); 578 ASSERT_TRUE(reparse_to_sub_a.IsValid());
579 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_a, sub_a)); 579 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_a, sub_a));
580 580
581 FilePath to_base_b = base_b.Append(FPL("to_base_b")); 581 FilePath to_base_b = base_b.Append(FPL("to_base_b"));
582 ASSERT_TRUE(file_util::CreateDirectory(to_base_b)); 582 ASSERT_TRUE(file_util::CreateDirectory(to_base_b));
583 ScopedHandle reparse_to_base_b( 583 ScopedHandle reparse_to_base_b(
584 ::CreateFile(to_base_b.value().c_str(), 584 ::CreateFile(to_base_b.value().c_str(),
585 FILE_ALL_ACCESS, 585 FILE_ALL_ACCESS,
586 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 586 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
587 NULL, 587 NULL,
588 OPEN_EXISTING, 588 OPEN_EXISTING,
589 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. 589 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
590 NULL)); 590 NULL));
591 ASSERT_NE(INVALID_HANDLE_VALUE, reparse_to_base_b.Get()); 591 ASSERT_TRUE(reparse_to_base_b.IsValid());
592 ASSERT_TRUE(SetReparsePoint(reparse_to_base_b, base_b)); 592 ASSERT_TRUE(SetReparsePoint(reparse_to_base_b, base_b));
593 593
594 FilePath to_sub_long = base_b.Append(FPL("to_sub_long")); 594 FilePath to_sub_long = base_b.Append(FPL("to_sub_long"));
595 ASSERT_TRUE(file_util::CreateDirectory(to_sub_long)); 595 ASSERT_TRUE(file_util::CreateDirectory(to_sub_long));
596 ScopedHandle reparse_to_sub_long( 596 ScopedHandle reparse_to_sub_long(
597 ::CreateFile(to_sub_long.value().c_str(), 597 ::CreateFile(to_sub_long.value().c_str(),
598 FILE_ALL_ACCESS, 598 FILE_ALL_ACCESS,
599 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 599 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
600 NULL, 600 NULL,
601 OPEN_EXISTING, 601 OPEN_EXISTING,
602 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. 602 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
603 NULL)); 603 NULL));
604 ASSERT_NE(INVALID_HANDLE_VALUE, reparse_to_sub_long.Get()); 604 ASSERT_TRUE(reparse_to_sub_long.IsValid());
605 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_long, sub_long)); 605 ASSERT_TRUE(SetReparsePoint(reparse_to_sub_long, sub_long));
606 606
607 // Normalize a junction free path: base_a\sub_a\file.txt . 607 // Normalize a junction free path: base_a\sub_a\file.txt .
608 FilePath normalized_path; 608 FilePath normalized_path;
609 ASSERT_TRUE(file_util::NormalizeFilePath(file_txt, &normalized_path)); 609 ASSERT_TRUE(file_util::NormalizeFilePath(file_txt, &normalized_path));
610 ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str()); 610 ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str());
611 611
612 // Check that the path base_b\to_sub_a\file.txt can be normalized to exclude 612 // Check that the path base_b\to_sub_a\file.txt can be normalized to exclude
613 // the junction to_sub_a. 613 // the junction to_sub_a.
614 ASSERT_TRUE(file_util::NormalizeFilePath(to_sub_a.Append(FPL("file.txt")), 614 ASSERT_TRUE(file_util::NormalizeFilePath(to_sub_a.Append(FPL("file.txt")),
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); 1856 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir));
1857 1857
1858 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); 1858 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt")));
1859 std::string bar("baz"); 1859 std::string bar("baz");
1860 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); 1860 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length()));
1861 1861
1862 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); 1862 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir));
1863 } 1863 }
1864 1864
1865 } // namespace 1865 } // namespace
OLDNEW
« no previous file with comments | « no previous file | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698