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 // The test scrubber uses a Google Test event listener to trigger scrubs. | 5 // The test scrubber uses a Google Test event listener to trigger scrubs. |
6 // Scrubs are performed at the start of the test program and at the conclusion | 6 // Scrubs are performed at the start of the test program and at the conclusion |
7 // of each test. | 7 // of each test. |
8 | 8 |
9 #include "chrome_frame/test/test_scrubber.h" | 9 #include "chrome_frame/test/test_scrubber.h" |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 ASCIIToWide(switches::kChromeFrame)); | 108 ASCIIToWide(switches::kChromeFrame)); |
109 | 109 |
110 // Delete the user data directory. | 110 // Delete the user data directory. |
111 base::FilePath data_directory(data_directory_override_.empty() ? | 111 base::FilePath data_directory(data_directory_override_.empty() ? |
112 default_data_directory_ : | 112 default_data_directory_ : |
113 data_directory_override_); | 113 data_directory_override_); |
114 | 114 |
115 VLOG_IF(1, base::PathExists(data_directory)) | 115 VLOG_IF(1, base::PathExists(data_directory)) |
116 << __FUNCTION__ << " deleting user data directory " | 116 << __FUNCTION__ << " deleting user data directory " |
117 << data_directory.value(); | 117 << data_directory.value(); |
118 bool deleted = base::Delete(data_directory, true); | 118 bool deleted = base::DeleteFile(data_directory, true); |
119 LOG_IF(ERROR, !deleted) | 119 LOG_IF(ERROR, !deleted) |
120 << "Failed to delete user data directory directory " | 120 << "Failed to delete user data directory directory " |
121 << data_directory.value(); | 121 << data_directory.value(); |
122 | 122 |
123 // Clear the overridden data directory for the next test. | 123 // Clear the overridden data directory for the next test. |
124 data_directory_override_.clear(); | 124 data_directory_override_.clear(); |
125 } | 125 } |
126 | 126 |
127 base::LazyInstance<TestScrubber> g_scrubber = LAZY_INSTANCE_INITIALIZER; | 127 base::LazyInstance<TestScrubber> g_scrubber = LAZY_INSTANCE_INITIALIZER; |
128 | 128 |
129 } // namespace | 129 } // namespace |
130 | 130 |
131 void InstallTestScrubber(testing::UnitTest* unit_test) { | 131 void InstallTestScrubber(testing::UnitTest* unit_test) { |
132 // Must be called before running any tests. | 132 // Must be called before running any tests. |
133 DCHECK(unit_test); | 133 DCHECK(unit_test); |
134 DCHECK(!unit_test->current_test_case()); | 134 DCHECK(!unit_test->current_test_case()); |
135 | 135 |
136 g_scrubber.Get().Initialize(unit_test); | 136 g_scrubber.Get().Initialize(unit_test); |
137 } | 137 } |
138 | 138 |
139 void OverrideDataDirectoryForThisTest( | 139 void OverrideDataDirectoryForThisTest( |
140 const base::StringPiece16& user_data_dir) { | 140 const base::StringPiece16& user_data_dir) { |
141 // Must be called within the context of a test. | 141 // Must be called within the context of a test. |
142 DCHECK(testing::UnitTest::GetInstance()->current_test_info()); | 142 DCHECK(testing::UnitTest::GetInstance()->current_test_info()); |
143 | 143 |
144 g_scrubber.Get().set_data_directory_override(user_data_dir); | 144 g_scrubber.Get().set_data_directory_override(user_data_dir); |
145 } | 145 } |
146 | 146 |
147 } // namespace chrome_frame_test | 147 } // namespace chrome_frame_test |
OLD | NEW |