| 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 420 } |
| 420 | 421 |
| 421 return result; | 422 return result; |
| 422 } | 423 } |
| 423 | 424 |
| 424 int UITestBase::GetCrashCount() const { | 425 int UITestBase::GetCrashCount() const { |
| 425 base::FilePath crash_dump_path; | 426 base::FilePath crash_dump_path; |
| 426 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); | 427 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); |
| 427 | 428 |
| 428 int files_found = 0; | 429 int files_found = 0; |
| 429 file_util::FileEnumerator en(crash_dump_path, false, | 430 base::FileEnumerator en(crash_dump_path, false, base::FileEnumerator::FILES); |
| 430 file_util::FileEnumerator::FILES); | |
| 431 while (!en.Next().empty()) { | 431 while (!en.Next().empty()) { |
| 432 file_util::FileEnumerator::FindInfo info; | 432 if (en.GetInfo().GetLastModifiedTime() > test_start_time_) |
| 433 if (file_util::FileEnumerator::GetLastModifiedTime(info) > test_start_time_) | |
| 434 files_found++; | 433 files_found++; |
| 435 } | 434 } |
| 436 | 435 |
| 437 #if defined(OS_WIN) | 436 #if defined(OS_WIN) |
| 438 // Each crash creates two dump files on Windows. | 437 // Each crash creates two dump files on Windows. |
| 439 return files_found / 2; | 438 return files_found / 2; |
| 440 #else | 439 #else |
| 441 return files_found; | 440 return files_found; |
| 442 #endif | 441 #endif |
| 443 } | 442 } |
| 444 | 443 |
| 445 std::string UITestBase::CheckErrorsAndCrashes() const { | 444 std::string UITestBase::CheckErrorsAndCrashes() const { |
| 446 // Make sure that we didn't encounter any assertion failures | 445 // Make sure that we didn't encounter any assertion failures |
| 447 logging::AssertionList assertions; | 446 logging::AssertionList assertions; |
| 448 logging::GetFatalAssertions(&assertions); | 447 logging::GetFatalAssertions(&assertions); |
| 449 | 448 |
| 450 // If there were errors, get all the error strings for display. | 449 // If there were errors, get all the error strings for display. |
| 451 std::wstring failures = | 450 std::wstring failures = |
| 452 L"The following error(s) occurred in the application during this test:"; | 451 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... |
| 694 ASSERT_TRUE(session_end_completed); | 693 ASSERT_TRUE(session_end_completed); |
| 695 | 694 |
| 696 // Make sure session restore says we didn't crash. | 695 // Make sure session restore says we didn't crash. |
| 697 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); | 696 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); |
| 698 ASSERT_TRUE(profile_prefs.get()); | 697 ASSERT_TRUE(profile_prefs.get()); |
| 699 std::string exit_type; | 698 std::string exit_type; |
| 700 ASSERT_TRUE(profile_prefs->GetString(prefs::kSessionExitedCleanly, | 699 ASSERT_TRUE(profile_prefs->GetString(prefs::kSessionExitedCleanly, |
| 701 &exit_type)); | 700 &exit_type)); |
| 702 EXPECT_EQ(ProfileImpl::kPrefExitTypeNormal, exit_type); | 701 EXPECT_EQ(ProfileImpl::kPrefExitTypeNormal, exit_type); |
| 703 } | 702 } |
| OLD | NEW |