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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 const wchar_t bogus_content[] = L"I'm cannon fodder."; | 178 const wchar_t bogus_content[] = L"I'm cannon fodder."; |
179 | 179 |
180 const int FILES_AND_DIRECTORIES = | 180 const int FILES_AND_DIRECTORIES = |
181 FileEnumerator::FILES | FileEnumerator::DIRECTORIES; | 181 FileEnumerator::FILES | FileEnumerator::DIRECTORIES; |
182 | 182 |
183 // file_util winds up using autoreleased objects on the Mac, so this needs | 183 // file_util winds up using autoreleased objects on the Mac, so this needs |
184 // to be a PlatformTest | 184 // to be a PlatformTest |
185 class FileUtilTest : public PlatformTest { | 185 class FileUtilTest : public PlatformTest { |
186 protected: | 186 protected: |
187 virtual void SetUp() override { | 187 void SetUp() override { |
188 PlatformTest::SetUp(); | 188 PlatformTest::SetUp(); |
189 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 189 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
190 } | 190 } |
191 | 191 |
192 ScopedTempDir temp_dir_; | 192 ScopedTempDir temp_dir_; |
193 }; | 193 }; |
194 | 194 |
195 // Collects all the results from the given file enumerator, and provides an | 195 // Collects all the results from the given file enumerator, and provides an |
196 // interface to query whether a given file is present. | 196 // interface to query whether a given file is present. |
197 class FindResultCollector { | 197 class FindResultCollector { |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 // Testing VerifyPathControlledByAdmin() is hard, because there is no | 2163 // Testing VerifyPathControlledByAdmin() is hard, because there is no |
2164 // way a test can make a file owned by root, or change file paths | 2164 // way a test can make a file owned by root, or change file paths |
2165 // at the root of the file system. VerifyPathControlledByAdmin() | 2165 // at the root of the file system. VerifyPathControlledByAdmin() |
2166 // is implemented as a call to VerifyPathControlledByUser, which gives | 2166 // is implemented as a call to VerifyPathControlledByUser, which gives |
2167 // us the ability to test with paths under the test's temp directory, | 2167 // us the ability to test with paths under the test's temp directory, |
2168 // using a user id we control. | 2168 // using a user id we control. |
2169 // Pull tests of VerifyPathControlledByUserTest() into a separate test class | 2169 // Pull tests of VerifyPathControlledByUserTest() into a separate test class |
2170 // with a common SetUp() method. | 2170 // with a common SetUp() method. |
2171 class VerifyPathControlledByUserTest : public FileUtilTest { | 2171 class VerifyPathControlledByUserTest : public FileUtilTest { |
2172 protected: | 2172 protected: |
2173 virtual void SetUp() override { | 2173 void SetUp() override { |
2174 FileUtilTest::SetUp(); | 2174 FileUtilTest::SetUp(); |
2175 | 2175 |
2176 // Create a basic structure used by each test. | 2176 // Create a basic structure used by each test. |
2177 // base_dir_ | 2177 // base_dir_ |
2178 // |-> sub_dir_ | 2178 // |-> sub_dir_ |
2179 // |-> text_file_ | 2179 // |-> text_file_ |
2180 | 2180 |
2181 base_dir_ = temp_dir_.path().AppendASCII("base_dir"); | 2181 base_dir_ = temp_dir_.path().AppendASCII("base_dir"); |
2182 ASSERT_TRUE(CreateDirectory(base_dir_)); | 2182 ASSERT_TRUE(CreateDirectory(base_dir_)); |
2183 | 2183 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 // Trying to close it should crash. This is important for security. | 2606 // Trying to close it should crash. This is important for security. |
2607 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); | 2607 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); |
2608 #endif | 2608 #endif |
2609 } | 2609 } |
2610 | 2610 |
2611 #endif // defined(OS_POSIX) | 2611 #endif // defined(OS_POSIX) |
2612 | 2612 |
2613 } // namespace | 2613 } // namespace |
2614 | 2614 |
2615 } // namespace base | 2615 } // namespace base |
OLD | NEW |