| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <fstream> | 5 #include <fstream> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/time.h" | |
| 15 #include "chrome/app/chrome_dll_resource.h" | 14 #include "chrome/app/chrome_dll_resource.h" |
| 16 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/character_encoding.h" | 16 #include "chrome/browser/character_encoding.h" |
| 18 #include "chrome/browser/view_ids.h" | 17 #include "chrome/browser/view_ids.h" |
| 19 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 20 #include "chrome/common/env_vars.h" | 19 #include "chrome/common/env_vars.h" |
| 21 #include "chrome/common/libxml_utils.h" | 20 #include "chrome/common/libxml_utils.h" |
| 22 #include "chrome/common/win_util.h" | 21 #include "chrome/common/win_util.h" |
| 23 #include "chrome/test/automated_ui_tests/automated_ui_tests.h" | 22 #include "chrome/test/automated_ui_tests/automated_ui_tests.h" |
| 24 #include "chrome/test/automation/browser_proxy.h" | 23 #include "chrome/test/automation/browser_proxy.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 "TaskManager", | 74 "TaskManager", |
| 76 "JavaScriptDebugger", | 75 "JavaScriptDebugger", |
| 77 "JavaScriptConsole", | 76 "JavaScriptConsole", |
| 78 "ClearBrowsingData", | 77 "ClearBrowsingData", |
| 79 "ImportSettings", | 78 "ImportSettings", |
| 80 "EditSearchEngines", | 79 "EditSearchEngines", |
| 81 "ViewPasswords" | 80 "ViewPasswords" |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 AutomatedUITest::AutomatedUITest() | 83 AutomatedUITest::AutomatedUITest() |
| 85 : test_start_time_(base::Time::Now()), | 84 : total_crashes_(0), |
| 86 total_crashes_(0), | |
| 87 debug_logging_enabled_(false), | 85 debug_logging_enabled_(false), |
| 88 post_action_delay_(0) { | 86 post_action_delay_(0) { |
| 89 show_window_ = true; | 87 show_window_ = true; |
| 88 GetSystemTimeAsFileTime(&test_start_time_); |
| 90 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 89 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 91 if (parsed_command_line.HasSwitch(kDebugModeSwitch)) | 90 if (parsed_command_line.HasSwitch(kDebugModeSwitch)) |
| 92 debug_logging_enabled_ = true; | 91 debug_logging_enabled_ = true; |
| 93 if (parsed_command_line.HasSwitch(kWaitSwitch)) { | 92 if (parsed_command_line.HasSwitch(kWaitSwitch)) { |
| 94 std::wstring str = parsed_command_line.GetSwitchValue(kWaitSwitch); | 93 std::wstring str = parsed_command_line.GetSwitchValue(kWaitSwitch); |
| 95 if (str.empty()) { | 94 if (str.empty()) { |
| 96 post_action_delay_ = 1; | 95 post_action_delay_ = 1; |
| 97 } else { | 96 } else { |
| 98 post_action_delay_ = static_cast<int>(StringToInt64(str)); | 97 post_action_delay_ = static_cast<int>(StringToInt64(str)); |
| 99 } | 98 } |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 | 934 |
| 936 if (most_recent_file_name.empty()) { | 935 if (most_recent_file_name.empty()) { |
| 937 return L""; | 936 return L""; |
| 938 } else { | 937 } else { |
| 939 file_util::AppendToPath(&crash_dump_path, most_recent_file_name); | 938 file_util::AppendToPath(&crash_dump_path, most_recent_file_name); |
| 940 return crash_dump_path; | 939 return crash_dump_path; |
| 941 } | 940 } |
| 942 } | 941 } |
| 943 | 942 |
| 944 bool AutomatedUITest::DidCrash(bool update_total_crashes) { | 943 bool AutomatedUITest::DidCrash(bool update_total_crashes) { |
| 945 FilePath crash_dump_path; | 944 std::wstring crash_dump_path; |
| 946 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); | 945 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); |
| 947 // Each crash creates two dump files, so we divide by two here. | 946 // Each crash creates two dump files, so we divide by two here. |
| 948 int actual_crashes = file_util::CountFilesCreatedAfter( | 947 int actual_crashes = file_util::CountFilesCreatedAfter( |
| 949 crash_dump_path, test_start_time_) / 2; | 948 crash_dump_path, test_start_time_) / 2; |
| 950 | 949 |
| 951 // If there are more crash dumps than the total dumps which we have recorded | 950 // If there are more crash dumps than the total dumps which we have recorded |
| 952 // then this is a new crash. | 951 // then this is a new crash. |
| 953 if (actual_crashes > total_crashes_) { | 952 if (actual_crashes > total_crashes_) { |
| 954 if (update_total_crashes) | 953 if (update_total_crashes) |
| 955 total_crashes_ = actual_crashes; | 954 total_crashes_ = actual_crashes; |
| 956 return true; | 955 return true; |
| 957 } else { | 956 } else { |
| 958 return false; | 957 return false; |
| 959 } | 958 } |
| 960 } | 959 } |
| 961 | 960 |
| 962 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { | 961 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { |
| 963 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 962 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 964 if (parsed_command_line.HasSwitch(kReproSwitch)) | 963 if (parsed_command_line.HasSwitch(kReproSwitch)) |
| 965 RunReproduction(); | 964 RunReproduction(); |
| 966 else | 965 else |
| 967 RunAutomatedUITest(); | 966 RunAutomatedUITest(); |
| 968 } | 967 } |
| OLD | NEW |