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

Side by Side Diff: base/files/file_util_unittest.cc

Issue 1867833003: Prefer System Flash over non-local component updated Flash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <fstream> 9 #include <fstream>
10 #include <set> 10 #include <set>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "base/android/content_uri_utils.h" 47 #include "base/android/content_uri_utils.h"
48 #endif 48 #endif
49 49
50 // This macro helps avoid wrapped lines in the test structs. 50 // This macro helps avoid wrapped lines in the test structs.
51 #define FPL(x) FILE_PATH_LITERAL(x) 51 #define FPL(x) FILE_PATH_LITERAL(x)
52 52
53 namespace base { 53 namespace base {
54 54
55 namespace { 55 namespace {
56 56
57 struct UnaryBooleanTestData {
58 const FilePath::CharType* input;
59 bool expected;
60 };
61
57 // To test that NormalizeFilePath() deals with NTFS reparse points correctly, 62 // To test that NormalizeFilePath() deals with NTFS reparse points correctly,
58 // we need functions to create and delete reparse points. 63 // we need functions to create and delete reparse points.
59 #if defined(OS_WIN) 64 #if defined(OS_WIN)
60 typedef struct _REPARSE_DATA_BUFFER { 65 typedef struct _REPARSE_DATA_BUFFER {
61 ULONG ReparseTag; 66 ULONG ReparseTag;
62 USHORT ReparseDataLength; 67 USHORT ReparseDataLength;
63 USHORT Reserved; 68 USHORT Reserved;
64 union { 69 union {
65 struct { 70 struct {
66 USHORT SubstituteNameOffset; 71 USHORT SubstituteNameOffset;
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 } 1662 }
1658 1663
1659 // Restore the original $TMP. 1664 // Restore the original $TMP.
1660 if (original_tmp) { 1665 if (original_tmp) {
1661 ::_tputenv_s(kTmpKey, original_tmp); 1666 ::_tputenv_s(kTmpKey, original_tmp);
1662 free(original_tmp); 1667 free(original_tmp);
1663 } else { 1668 } else {
1664 ::_tputenv_s(kTmpKey, _T("")); 1669 ::_tputenv_s(kTmpKey, _T(""));
1665 } 1670 }
1666 } 1671 }
1672
1673 TEST_F(FileUtilTest, IsOnNetworkDrive) {
1674 const struct UnaryBooleanTestData cases[] = {
1675 { FPL(""), false },
1676 { FPL("c:\\"), false },
1677 { FPL("c:"), false },
1678 { FPL("c:\\windows\\notepad.exe"), false },
1679 /*
cpu_(ooo_6.6-7.5) 2016/04/15 20:55:33 hmmm ... rather use an environment variable, so ev
1680 // Uncomment and edit, for manual testing only.
1681 { FPL("\\\\server\\share\\file.txt"), true },
1682 { FPL("\\\\server\\share"), true },
1683 { FPL("\\\\server\\share\\"), true },
1684 { FPL("\\\\server\\"), false },
1685 { FPL("\\\\server"), false },
1686 */
1687 };
1688
1689 for (size_t i = 0; i < arraysize(cases); ++i) {
1690 FilePath input(cases[i].input);
1691 bool observed = IsOnNetworkDrive(input);
1692 EXPECT_EQ(cases[i].expected, observed) <<
1693 "i: " << i << ", input: " << input.value();
1694 }
1695 }
1667 #endif // OS_WIN 1696 #endif // OS_WIN
1668 1697
1669 TEST_F(FileUtilTest, CreateTemporaryFileTest) { 1698 TEST_F(FileUtilTest, CreateTemporaryFileTest) {
1670 FilePath temp_files[3]; 1699 FilePath temp_files[3];
1671 for (int i = 0; i < 3; i++) { 1700 for (int i = 0; i < 3; i++) {
1672 ASSERT_TRUE(CreateTemporaryFile(&(temp_files[i]))); 1701 ASSERT_TRUE(CreateTemporaryFile(&(temp_files[i])));
1673 EXPECT_TRUE(PathExists(temp_files[i])); 1702 EXPECT_TRUE(PathExists(temp_files[i]));
1674 EXPECT_FALSE(DirectoryExists(temp_files[i])); 1703 EXPECT_FALSE(DirectoryExists(temp_files[i]));
1675 } 1704 }
1676 for (int i = 0; i < 3; i++) 1705 for (int i = 0; i < 3; i++)
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 // Trying to close it should crash. This is important for security. 2549 // Trying to close it should crash. This is important for security.
2521 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); 2550 EXPECT_DEATH(CloseWithScopedFD(fds[1]), "");
2522 #endif 2551 #endif
2523 } 2552 }
2524 2553
2525 #endif // defined(OS_POSIX) 2554 #endif // defined(OS_POSIX)
2526 2555
2527 } // namespace 2556 } // namespace
2528 2557
2529 } // namespace base 2558 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util.h ('k') | base/files/file_util_win.cc » ('j') | base/files/file_util_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698