OLD | NEW |
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 "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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 const file_util::FileEnumerator::FileType FILES_AND_DIRECTORIES = | 136 const file_util::FileEnumerator::FileType FILES_AND_DIRECTORIES = |
137 static_cast<file_util::FileEnumerator::FileType>( | 137 static_cast<file_util::FileEnumerator::FileType>( |
138 file_util::FileEnumerator::FILES | | 138 file_util::FileEnumerator::FILES | |
139 file_util::FileEnumerator::DIRECTORIES); | 139 file_util::FileEnumerator::DIRECTORIES); |
140 | 140 |
141 // file_util winds up using autoreleased objects on the Mac, so this needs | 141 // file_util winds up using autoreleased objects on the Mac, so this needs |
142 // to be a PlatformTest | 142 // to be a PlatformTest |
143 class FileUtilTest : public PlatformTest { | 143 class FileUtilTest : public PlatformTest { |
144 protected: | 144 protected: |
145 virtual void SetUp() { | 145 virtual void SetUp() OVERRIDE { |
146 PlatformTest::SetUp(); | 146 PlatformTest::SetUp(); |
147 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 147 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
148 } | 148 } |
149 | 149 |
150 ScopedTempDir temp_dir_; | 150 ScopedTempDir temp_dir_; |
151 }; | 151 }; |
152 | 152 |
153 // Collects all the results from the given file enumerator, and provides an | 153 // Collects all the results from the given file enumerator, and provides an |
154 // interface to query whether a given file is present. | 154 // interface to query whether a given file is present. |
155 class FindResultCollector { | 155 class FindResultCollector { |
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 // Testing VerifyPathControlledByAdmin() is hard, because there is no | 1889 // Testing VerifyPathControlledByAdmin() is hard, because there is no |
1890 // way a test can make a file owned by root, or change file paths | 1890 // way a test can make a file owned by root, or change file paths |
1891 // at the root of the file system. VerifyPathControlledByAdmin() | 1891 // at the root of the file system. VerifyPathControlledByAdmin() |
1892 // is implemented as a call to VerifyPathControlledByUser, which gives | 1892 // is implemented as a call to VerifyPathControlledByUser, which gives |
1893 // us the ability to test with paths under the test's temp directory, | 1893 // us the ability to test with paths under the test's temp directory, |
1894 // using a user id we control. | 1894 // using a user id we control. |
1895 // Pull tests of VerifyPathControlledByUserTest() into a separate test class | 1895 // Pull tests of VerifyPathControlledByUserTest() into a separate test class |
1896 // with a common SetUp() method. | 1896 // with a common SetUp() method. |
1897 class VerifyPathControlledByUserTest : public FileUtilTest { | 1897 class VerifyPathControlledByUserTest : public FileUtilTest { |
1898 protected: | 1898 protected: |
1899 virtual void SetUp() { | 1899 virtual void SetUp() OVERRIDE { |
1900 FileUtilTest::SetUp(); | 1900 FileUtilTest::SetUp(); |
1901 | 1901 |
1902 // Create a basic structure used by each test. | 1902 // Create a basic structure used by each test. |
1903 // base_dir_ | 1903 // base_dir_ |
1904 // |-> sub_dir_ | 1904 // |-> sub_dir_ |
1905 // |-> text_file_ | 1905 // |-> text_file_ |
1906 | 1906 |
1907 base_dir_ = temp_dir_.path().AppendASCII("base_dir"); | 1907 base_dir_ = temp_dir_.path().AppendASCII("base_dir"); |
1908 ASSERT_TRUE(file_util::CreateDirectory(base_dir_)); | 1908 ASSERT_TRUE(file_util::CreateDirectory(base_dir_)); |
1909 | 1909 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2247 file_util::VerifyPathControlledByUser( | 2247 file_util::VerifyPathControlledByUser( |
2248 base_dir_, text_file_, uid_, ok_gids_)); | 2248 base_dir_, text_file_, uid_, ok_gids_)); |
2249 EXPECT_TRUE( | 2249 EXPECT_TRUE( |
2250 file_util::VerifyPathControlledByUser( | 2250 file_util::VerifyPathControlledByUser( |
2251 sub_dir_, text_file_, uid_, ok_gids_)); | 2251 sub_dir_, text_file_, uid_, ok_gids_)); |
2252 } | 2252 } |
2253 | 2253 |
2254 #endif // defined(OS_POSIX) | 2254 #endif // defined(OS_POSIX) |
2255 | 2255 |
2256 } // namespace | 2256 } // namespace |
OLD | NEW |