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

Side by Side Diff: base/file_util_unittest.cc

Issue 9004052: GetPlatformFileInfo was always never returning directory (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/platform_file_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // Delete the reparse points, and see that NormalizeFilePath() fails 574 // Delete the reparse points, and see that NormalizeFilePath() fails
575 // to traverse them. 575 // to traverse them.
576 ASSERT_TRUE(DeleteReparsePoint(reparse_to_sub_a)); 576 ASSERT_TRUE(DeleteReparsePoint(reparse_to_sub_a));
577 ASSERT_TRUE(DeleteReparsePoint(reparse_to_base_b)); 577 ASSERT_TRUE(DeleteReparsePoint(reparse_to_base_b));
578 ASSERT_TRUE(DeleteReparsePoint(reparse_to_sub_long)); 578 ASSERT_TRUE(DeleteReparsePoint(reparse_to_sub_long));
579 579
580 ASSERT_FALSE(file_util::NormalizeFilePath(to_sub_a.Append(FPL("file.txt")), 580 ASSERT_FALSE(file_util::NormalizeFilePath(to_sub_a.Append(FPL("file.txt")),
581 &normalized_path)); 581 &normalized_path));
582 } 582 }
583 583
584 TEST_F(FileUtilTest, GetPlatformFileInfoForDirectory) {
585 FilePath empty_dir = temp_dir_.path().Append(FPL("gpfi_test"));
586 ASSERT_TRUE(file_util::CreateDirectory(empty_dir));
587 base::win::ScopedHandle dir(
588 ::CreateFile(empty_dir.value().c_str(),
589 FILE_ALL_ACCESS,
590 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
591 NULL,
592 OPEN_EXISTING,
593 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
594 NULL));
595 ASSERT_TRUE(dir.IsValid());
596 base::PlatformFileInfo info;
597 EXPECT_TRUE(base::GetPlatformFileInfo(dir.Get(), &info));
598 EXPECT_TRUE(info.is_directory);
599 EXPECT_FALSE(info.is_symbolic_link);
600 EXPECT_EQ(0, info.size);
601 }
602
584 #endif // defined(OS_WIN) 603 #endif // defined(OS_WIN)
585 604
586 #if defined(OS_POSIX) 605 #if defined(OS_POSIX)
587 606
588 TEST_F(FileUtilTest, CreateAndReadSymlinks) { 607 TEST_F(FileUtilTest, CreateAndReadSymlinks) {
589 FilePath link_from = temp_dir_.path().Append(FPL("from_file")); 608 FilePath link_from = temp_dir_.path().Append(FPL("from_file"));
590 FilePath link_to = temp_dir_.path().Append(FPL("to_file")); 609 FilePath link_to = temp_dir_.path().Append(FPL("to_file"));
591 CreateTextFile(link_to, bogus_content); 610 CreateTextFile(link_to, bogus_content);
592 611
593 ASSERT_TRUE(file_util::CreateSymbolicLink(link_to, link_from)) 612 ASSERT_TRUE(file_util::CreateSymbolicLink(link_to, link_from))
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 } 1624 }
1606 1625
1607 TEST_F(FileUtilTest, DetectDirectoryTest) { 1626 TEST_F(FileUtilTest, DetectDirectoryTest) {
1608 // Check a directory 1627 // Check a directory
1609 FilePath test_root = 1628 FilePath test_root =
1610 temp_dir_.path().Append(FILE_PATH_LITERAL("detect_directory_test")); 1629 temp_dir_.path().Append(FILE_PATH_LITERAL("detect_directory_test"));
1611 EXPECT_FALSE(file_util::PathExists(test_root)); 1630 EXPECT_FALSE(file_util::PathExists(test_root));
1612 EXPECT_TRUE(file_util::CreateDirectory(test_root)); 1631 EXPECT_TRUE(file_util::CreateDirectory(test_root));
1613 EXPECT_TRUE(file_util::PathExists(test_root)); 1632 EXPECT_TRUE(file_util::PathExists(test_root));
1614 EXPECT_TRUE(file_util::DirectoryExists(test_root)); 1633 EXPECT_TRUE(file_util::DirectoryExists(test_root));
1615
1616 // Check a file 1634 // Check a file
1617 FilePath test_path = 1635 FilePath test_path =
1618 test_root.Append(FILE_PATH_LITERAL("foobar.txt")); 1636 test_root.Append(FILE_PATH_LITERAL("foobar.txt"));
1619 EXPECT_FALSE(file_util::PathExists(test_path)); 1637 EXPECT_FALSE(file_util::PathExists(test_path));
1620 CreateTextFile(test_path, L"test file"); 1638 CreateTextFile(test_path, L"test file");
1621 EXPECT_TRUE(file_util::PathExists(test_path)); 1639 EXPECT_TRUE(file_util::PathExists(test_path));
1622 EXPECT_FALSE(file_util::DirectoryExists(test_path)); 1640 EXPECT_FALSE(file_util::DirectoryExists(test_path));
1623 EXPECT_TRUE(file_util::Delete(test_path, false)); 1641 EXPECT_TRUE(file_util::Delete(test_path, false));
1624 1642
1625 EXPECT_TRUE(file_util::Delete(test_root, true)); 1643 EXPECT_TRUE(file_util::Delete(test_root, true));
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 file_util::VerifyPathControlledByUser( 2217 file_util::VerifyPathControlledByUser(
2200 base_dir_, text_file_, uid_, ok_gids_)); 2218 base_dir_, text_file_, uid_, ok_gids_));
2201 EXPECT_TRUE( 2219 EXPECT_TRUE(
2202 file_util::VerifyPathControlledByUser( 2220 file_util::VerifyPathControlledByUser(
2203 sub_dir_, text_file_, uid_, ok_gids_)); 2221 sub_dir_, text_file_, uid_, ok_gids_));
2204 } 2222 }
2205 2223
2206 #endif // defined(OS_POSIX) 2224 #endif // defined(OS_POSIX)
2207 2225
2208 } // namespace 2226 } // namespace
OLDNEW
« no previous file with comments | « no previous file | base/platform_file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698