Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: chrome/test/automated_ui_tests/automated_ui_tests.cc

Issue 73083: Submitting http://codereview.chromium.org/73075 on behalf of shinichiro.hamaj... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/automated_ui_tests/automated_ui_tests.h ('k') | chrome/test/ui/ui_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
14 #include "chrome/app/chrome_dll_resource.h" 15 #include "chrome/app/chrome_dll_resource.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/character_encoding.h" 17 #include "chrome/browser/character_encoding.h"
17 #include "chrome/browser/view_ids.h" 18 #include "chrome/browser/view_ids.h"
18 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/env_vars.h" 20 #include "chrome/common/env_vars.h"
20 #include "chrome/common/libxml_utils.h" 21 #include "chrome/common/libxml_utils.h"
21 #include "chrome/common/win_util.h" 22 #include "chrome/common/win_util.h"
22 #include "chrome/test/automated_ui_tests/automated_ui_tests.h" 23 #include "chrome/test/automated_ui_tests/automated_ui_tests.h"
23 #include "chrome/test/automation/browser_proxy.h" 24 #include "chrome/test/automation/browser_proxy.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 "TaskManager", 75 "TaskManager",
75 "JavaScriptDebugger", 76 "JavaScriptDebugger",
76 "JavaScriptConsole", 77 "JavaScriptConsole",
77 "ClearBrowsingData", 78 "ClearBrowsingData",
78 "ImportSettings", 79 "ImportSettings",
79 "EditSearchEngines", 80 "EditSearchEngines",
80 "ViewPasswords" 81 "ViewPasswords"
81 }; 82 };
82 83
83 AutomatedUITest::AutomatedUITest() 84 AutomatedUITest::AutomatedUITest()
84 : total_crashes_(0), 85 : test_start_time_(base::Time::Now()),
86 total_crashes_(0),
85 debug_logging_enabled_(false), 87 debug_logging_enabled_(false),
86 post_action_delay_(0) { 88 post_action_delay_(0) {
87 show_window_ = true; 89 show_window_ = true;
88 GetSystemTimeAsFileTime(&test_start_time_);
89 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 90 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
90 if (parsed_command_line.HasSwitch(kDebugModeSwitch)) 91 if (parsed_command_line.HasSwitch(kDebugModeSwitch))
91 debug_logging_enabled_ = true; 92 debug_logging_enabled_ = true;
92 if (parsed_command_line.HasSwitch(kWaitSwitch)) { 93 if (parsed_command_line.HasSwitch(kWaitSwitch)) {
93 std::wstring str = parsed_command_line.GetSwitchValue(kWaitSwitch); 94 std::wstring str = parsed_command_line.GetSwitchValue(kWaitSwitch);
94 if (str.empty()) { 95 if (str.empty()) {
95 post_action_delay_ = 1; 96 post_action_delay_ = 1;
96 } else { 97 } else {
97 post_action_delay_ = static_cast<int>(StringToInt64(str)); 98 post_action_delay_ = static_cast<int>(StringToInt64(str));
98 } 99 }
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 935
935 if (most_recent_file_name.empty()) { 936 if (most_recent_file_name.empty()) {
936 return L""; 937 return L"";
937 } else { 938 } else {
938 file_util::AppendToPath(&crash_dump_path, most_recent_file_name); 939 file_util::AppendToPath(&crash_dump_path, most_recent_file_name);
939 return crash_dump_path; 940 return crash_dump_path;
940 } 941 }
941 } 942 }
942 943
943 bool AutomatedUITest::DidCrash(bool update_total_crashes) { 944 bool AutomatedUITest::DidCrash(bool update_total_crashes) {
944 std::wstring crash_dump_path; 945 FilePath crash_dump_path;
945 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); 946 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path);
946 // Each crash creates two dump files, so we divide by two here. 947 // Each crash creates two dump files, so we divide by two here.
947 int actual_crashes = file_util::CountFilesCreatedAfter( 948 int actual_crashes = file_util::CountFilesCreatedAfter(
948 crash_dump_path, test_start_time_) / 2; 949 crash_dump_path, test_start_time_) / 2;
949 950
950 // If there are more crash dumps than the total dumps which we have recorded 951 // If there are more crash dumps than the total dumps which we have recorded
951 // then this is a new crash. 952 // then this is a new crash.
952 if (actual_crashes > total_crashes_) { 953 if (actual_crashes > total_crashes_) {
953 if (update_total_crashes) 954 if (update_total_crashes)
954 total_crashes_ = actual_crashes; 955 total_crashes_ = actual_crashes;
955 return true; 956 return true;
956 } else { 957 } else {
957 return false; 958 return false;
958 } 959 }
959 } 960 }
960 961
961 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { 962 TEST_F(AutomatedUITest, TheOneAndOnlyTest) {
962 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 963 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
963 if (parsed_command_line.HasSwitch(kReproSwitch)) 964 if (parsed_command_line.HasSwitch(kReproSwitch))
964 RunReproduction(); 965 RunReproduction();
965 else 966 else
966 RunAutomatedUITest(); 967 RunAutomatedUITest();
967 } 968 }
OLDNEW
« no previous file with comments | « chrome/test/automated_ui_tests/automated_ui_tests.h ('k') | chrome/test/ui/ui_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698