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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include <set> | 12 #include <set> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/base_switches.h" | 15 #include "base/base_switches.h" |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/environment.h" | 18 #include "base/environment.h" |
19 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 20 #include "base/files/file_enumerator.h" |
20 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
21 #include "base/files/scoped_temp_dir.h" | 22 #include "base/files/scoped_temp_dir.h" |
22 #include "base/json/json_file_value_serializer.h" | 23 #include "base/json/json_file_value_serializer.h" |
23 #include "base/logging.h" | 24 #include "base/logging.h" |
24 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
25 #include "base/path_service.h" | 26 #include "base/path_service.h" |
26 #include "base/process_util.h" | 27 #include "base/process_util.h" |
27 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
28 #include "base/strings/string_split.h" | 29 #include "base/strings/string_split.h" |
29 #include "base/test/test_file_util.h" | 30 #include "base/test/test_file_util.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 441 } |
441 | 442 |
442 return source_history_file; | 443 return source_history_file; |
443 } | 444 } |
444 | 445 |
445 int UITestBase::GetCrashCount() const { | 446 int UITestBase::GetCrashCount() const { |
446 base::FilePath crash_dump_path; | 447 base::FilePath crash_dump_path; |
447 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); | 448 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); |
448 | 449 |
449 int files_found = 0; | 450 int files_found = 0; |
450 file_util::FileEnumerator en(crash_dump_path, false, | 451 base::FileEnumerator en(crash_dump_path, false, base::FileEnumerator::FILES); |
451 file_util::FileEnumerator::FILES); | |
452 while (!en.Next().empty()) { | 452 while (!en.Next().empty()) { |
453 file_util::FileEnumerator::FindInfo info; | 453 if (en.GetInfo().GetLastModifiedTime() > test_start_time_) |
454 if (file_util::FileEnumerator::GetLastModifiedTime(info) > test_start_time_) | |
455 files_found++; | 454 files_found++; |
456 } | 455 } |
457 | 456 |
458 #if defined(OS_WIN) | 457 #if defined(OS_WIN) |
459 // Each crash creates two dump files on Windows. | 458 // Each crash creates two dump files on Windows. |
460 return files_found / 2; | 459 return files_found / 2; |
461 #else | 460 #else |
462 return files_found; | 461 return files_found; |
463 #endif | 462 #endif |
464 } | 463 } |
465 | 464 |
466 std::string UITestBase::CheckErrorsAndCrashes() const { | 465 std::string UITestBase::CheckErrorsAndCrashes() const { |
467 // Make sure that we didn't encounter any assertion failures | 466 // Make sure that we didn't encounter any assertion failures |
468 logging::AssertionList assertions; | 467 logging::AssertionList assertions; |
469 logging::GetFatalAssertions(&assertions); | 468 logging::GetFatalAssertions(&assertions); |
470 | 469 |
471 // If there were errors, get all the error strings for display. | 470 // If there were errors, get all the error strings for display. |
472 std::wstring failures = | 471 std::wstring failures = |
473 L"The following error(s) occurred in the application during this test:"; | 472 L"The following error(s) occurred in the application during this test:"; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 ASSERT_TRUE(session_end_completed); | 714 ASSERT_TRUE(session_end_completed); |
716 | 715 |
717 // Make sure session restore says we didn't crash. | 716 // Make sure session restore says we didn't crash. |
718 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); | 717 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); |
719 ASSERT_TRUE(profile_prefs.get()); | 718 ASSERT_TRUE(profile_prefs.get()); |
720 std::string exit_type; | 719 std::string exit_type; |
721 ASSERT_TRUE(profile_prefs->GetString(prefs::kSessionExitedCleanly, | 720 ASSERT_TRUE(profile_prefs->GetString(prefs::kSessionExitedCleanly, |
722 &exit_type)); | 721 &exit_type)); |
723 EXPECT_EQ(ProfileImpl::kPrefExitTypeNormal, exit_type); | 722 EXPECT_EQ(ProfileImpl::kPrefExitTypeNormal, exit_type); |
724 } | 723 } |
OLD | NEW |