| 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/prefs/testing_pref_service.h" | 7 #include "base/prefs/testing_pref_service.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 DidFailProvisionalLoad(kFrameID, kIsMainFrame, _, | 250 DidFailProvisionalLoad(kFrameID, kIsMainFrame, _, |
| 251 net::ERR_INVALID_URL, error_string, _)) | 251 net::ERR_INVALID_URL, error_string, _)) |
| 252 .WillOnce(Invoke(page_cycler(), | 252 .WillOnce(Invoke(page_cycler(), |
| 253 &MockPageCycler::PageCyclerDidFailProvisionalLoad)); | 253 &MockPageCycler::PageCyclerDidFailProvisionalLoad)); |
| 254 FailProvisionalLoad(net::ERR_INVALID_URL, error_string); | 254 FailProvisionalLoad(net::ERR_INVALID_URL, error_string); |
| 255 | 255 |
| 256 PumpLoop(); | 256 PumpLoop(); |
| 257 | 257 |
| 258 std::string errors_output; | 258 std::string errors_output; |
| 259 std::string errors_expected; | 259 std::string errors_expected; |
| 260 ASSERT_TRUE(file_util::ReadFileToString(errors_file(), | 260 ASSERT_TRUE(base::ReadFileToString(errors_file(), &errors_output)); |
| 261 &errors_output)); | 261 ASSERT_TRUE(base::ReadFileToString(errors_expected_file, &errors_expected)); |
| 262 ASSERT_TRUE(file_util::ReadFileToString(errors_expected_file, | |
| 263 &errors_expected)); | |
| 264 ASSERT_EQ(errors_output, errors_expected); | 262 ASSERT_EQ(errors_output, errors_expected); |
| 265 } | 263 } |
| 266 | 264 |
| 267 TEST_F(PageCyclerTest, StatsFile) { | 265 TEST_F(PageCyclerTest, StatsFile) { |
| 268 const int kNumLoads = 4; | 266 const int kNumLoads = 4; |
| 269 | 267 |
| 270 base::ScopedTempDir temp; | 268 base::ScopedTempDir temp; |
| 271 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 269 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 272 InitFilePaths(temp.path()); | 270 InitFilePaths(temp.path()); |
| 273 | 271 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 &MockPageCycler::PageCyclerDidFinishLoad)); | 311 &MockPageCycler::PageCyclerDidFinishLoad)); |
| 314 base::RunLoop().RunUntilIdle(); | 312 base::RunLoop().RunUntilIdle(); |
| 315 | 313 |
| 316 FinishLoad(); | 314 FinishLoad(); |
| 317 | 315 |
| 318 CloseBrowser(); | 316 CloseBrowser(); |
| 319 PumpLoop(); | 317 PumpLoop(); |
| 320 | 318 |
| 321 std::string errors_output; | 319 std::string errors_output; |
| 322 std::string errors_expected; | 320 std::string errors_expected; |
| 323 ASSERT_TRUE(file_util::ReadFileToString(errors_file(), | 321 ASSERT_TRUE(base::ReadFileToString(errors_file(), &errors_output)); |
| 324 &errors_output)); | 322 ASSERT_TRUE(base::ReadFileToString(errors_expected_file, &errors_expected)); |
| 325 ASSERT_TRUE(file_util::ReadFileToString(errors_expected_file, | |
| 326 &errors_expected)); | |
| 327 ASSERT_EQ(errors_output, errors_expected); | 323 ASSERT_EQ(errors_output, errors_expected); |
| 328 } | 324 } |
| 329 | 325 |
| 330 TEST_F(PageCyclerTest, MultipleIterations) { | 326 TEST_F(PageCyclerTest, MultipleIterations) { |
| 331 const int kNumLoads = 4; | 327 const int kNumLoads = 4; |
| 332 | 328 |
| 333 base::ScopedTempDir temp; | 329 base::ScopedTempDir temp; |
| 334 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 330 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 335 InitFilePaths(temp.path()); | 331 InitFilePaths(temp.path()); |
| 336 | 332 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 347 .WillRepeatedly(Invoke(page_cycler(), | 343 .WillRepeatedly(Invoke(page_cycler(), |
| 348 &MockPageCycler::PageCyclerDidFinishLoad)); | 344 &MockPageCycler::PageCyclerDidFinishLoad)); |
| 349 | 345 |
| 350 for (int i = 0; i < kNumLoads; ++i) | 346 for (int i = 0; i < kNumLoads; ++i) |
| 351 FinishLoad(); | 347 FinishLoad(); |
| 352 | 348 |
| 353 PumpLoop(); | 349 PumpLoop(); |
| 354 EXPECT_FALSE(PathExists(errors_file())); | 350 EXPECT_FALSE(PathExists(errors_file())); |
| 355 ASSERT_TRUE(PathExists(stats_file())); | 351 ASSERT_TRUE(PathExists(stats_file())); |
| 356 } | 352 } |
| OLD | NEW |