diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-22 23:36:27 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-22 23:36:27 +0000 |
commit | 51485966913e5480f8874f38776417871f1ff5b7 (patch) | |
tree | c71782e0da9122a9b432b4bec428b4160db7371d | |
parent | e4456ae44f4f869dba417c0271594a39ad45779e (diff) | |
download | chromium_src-51485966913e5480f8874f38776417871f1ff5b7.zip chromium_src-51485966913e5480f8874f38776417871f1ff5b7.tar.gz chromium_src-51485966913e5480f8874f38776417871f1ff5b7.tar.bz2 |
Unify the two places we attempt to find the crash count.
Aside from reducing duplicated logic, I intend to change the
behavior of this (newly refactored) function.
BUG=46246
Review URL: http://codereview.chromium.org/3475008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60234 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_tests.cc | 6 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 25 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 3 |
3 files changed, 19 insertions, 15 deletions
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc index d3c6408..b75d8aa 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.cc +++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc @@ -731,11 +731,7 @@ FilePath AutomatedUITest::GetMostRecentCrashDump() { } bool AutomatedUITest::DidCrash(bool update_total_crashes) { - FilePath crash_dump_path; - PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); - // Each crash creates two dump files, so we divide by two here. - int actual_crashes = file_util::CountFilesCreatedAfter( - crash_dump_path, test_start_time_) / 2; + int actual_crashes = GetCrashCount(); // If there are more crash dumps than the total dumps which we have recorded // then this is a new crash. diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 23b6669..8dcc3a3 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -159,16 +159,7 @@ void UITestBase::TearDown() { } EXPECT_EQ(expected_errors_, assertions.size()) << failures; - // Check for crashes during the test - FilePath crash_dump_path; - PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); - int actual_crashes = - file_util::CountFilesCreatedAfter(crash_dump_path, test_start_time_); - -#if defined(OS_WIN) - // Each crash creates two dump files, so we divide by two here. - actual_crashes /= 2; -#endif + int actual_crashes = GetCrashCount(); std::wstring error_msg = L"Encountered an unexpected crash in the program during this test."; @@ -672,6 +663,20 @@ int UITestBase::GetBrowserProcessCount() { return GetRunningChromeProcesses(process_id_).size(); } +int UITestBase::GetCrashCount() { + FilePath crash_dump_path; + PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); + int actual_crashes = file_util::CountFilesCreatedAfter( + crash_dump_path, test_start_time_); + +#if defined(OS_WIN) + // Each crash creates two dump files, so we divide by two here. + actual_crashes /= 2; +#endif + + return actual_crashes; +} + static DictionaryValue* LoadDictionaryValueFromPath(const FilePath& path) { if (path.empty()) return NULL; diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index 6c124f2..7df0a8c 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -410,6 +410,9 @@ class UITestBase { // The count includes browser sub-processes. int GetBrowserProcessCount(); + // Get the number of crash dumps we've logged since the test started. + int GetCrashCount(); + // Returns a copy of local state preferences. The caller is responsible for // deleting the returned object. Returns NULL if there is an error. DictionaryValue* GetLocalState(); |