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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_split.h" | 7 #include "base/string_split.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 PumpLoop(); | 141 PumpLoop(); |
142 } | 142 } |
143 | 143 |
144 void RunPageCycler() { | 144 void RunPageCycler() { |
145 page_cycler_->Run(); | 145 page_cycler_->Run(); |
146 PumpLoop(); | 146 PumpLoop(); |
147 } | 147 } |
148 | 148 |
149 void PumpLoop() { | 149 void PumpLoop() { |
150 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 150 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
151 message_loop()->RunAllPending(); | 151 message_loop()->RunUntilIdle(); |
152 } | 152 } |
153 | 153 |
154 void CloseBrowser() { | 154 void CloseBrowser() { |
155 DestroyBrowserAndProfile(); | 155 DestroyBrowserAndProfile(); |
156 PumpLoop(); | 156 PumpLoop(); |
157 } | 157 } |
158 | 158 |
159 MockPageCycler* page_cycler() { | 159 MockPageCycler* page_cycler() { |
160 return page_cycler_.get(); | 160 return page_cycler_.get(); |
161 } | 161 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 301 |
302 set_page_cycler(new MockPageCycler(browser(), | 302 set_page_cycler(new MockPageCycler(browser(), |
303 urls_file(), | 303 urls_file(), |
304 errors_file())); | 304 errors_file())); |
305 RunPageCycler(); | 305 RunPageCycler(); |
306 | 306 |
307 EXPECT_CALL(*page_cycler(), | 307 EXPECT_CALL(*page_cycler(), |
308 DidFinishLoad(kFrameID, kAboutURL, kIsMainFrame, _)) | 308 DidFinishLoad(kFrameID, kAboutURL, kIsMainFrame, _)) |
309 .WillOnce(Invoke(page_cycler(), | 309 .WillOnce(Invoke(page_cycler(), |
310 &MockPageCycler::PageCyclerDidFinishLoad)); | 310 &MockPageCycler::PageCyclerDidFinishLoad)); |
311 message_loop()->RunAllPending(); | 311 message_loop()->RunUntilIdle(); |
312 | 312 |
313 FinishLoad(); | 313 FinishLoad(); |
314 | 314 |
315 CloseBrowser(); | 315 CloseBrowser(); |
316 PumpLoop(); | 316 PumpLoop(); |
317 | 317 |
318 std::string errors_output; | 318 std::string errors_output; |
319 std::string errors_expected; | 319 std::string errors_expected; |
320 ASSERT_TRUE(file_util::ReadFileToString(errors_file(), | 320 ASSERT_TRUE(file_util::ReadFileToString(errors_file(), |
321 &errors_output)); | 321 &errors_output)); |
(...skipping 22 matching lines...) Expand all Loading... |
344 .WillRepeatedly(Invoke(page_cycler(), | 344 .WillRepeatedly(Invoke(page_cycler(), |
345 &MockPageCycler::PageCyclerDidFinishLoad)); | 345 &MockPageCycler::PageCyclerDidFinishLoad)); |
346 | 346 |
347 for (int i = 0; i < kNumLoads; ++i) | 347 for (int i = 0; i < kNumLoads; ++i) |
348 FinishLoad(); | 348 FinishLoad(); |
349 | 349 |
350 PumpLoop(); | 350 PumpLoop(); |
351 EXPECT_FALSE(PathExists(errors_file())); | 351 EXPECT_FALSE(PathExists(errors_file())); |
352 ASSERT_TRUE(PathExists(stats_file())); | 352 ASSERT_TRUE(PathExists(stats_file())); |
353 } | 353 } |
OLD | NEW |