| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // This file provides reliablity test which runs under UI test framework. The | 5 // This file provides reliablity test which runs under UI test framework. The |
| 6 // test is intended to run within QEMU environment. | 6 // test is intended to run within QEMU environment. |
| 7 // | 7 // |
| 8 // Usage 1: reliability_test | 8 // Usage 1: reliability_test |
| 9 // Upon invocation, it visits a hard coded list of sample URLs. This is mainly | 9 // Upon invocation, it visits a hard coded list of sample URLs. This is mainly |
| 10 // used by buildbot, to verify reliability_test itself runs ok. | 10 // used by buildbot, to verify reliability_test itself runs ok. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #include <fstream> | 36 #include <fstream> |
| 37 #include <iostream> | 37 #include <iostream> |
| 38 | 38 |
| 39 #include "base/command_line.h" | 39 #include "base/command_line.h" |
| 40 #include "base/file_path.h" | 40 #include "base/file_path.h" |
| 41 #include "base/file_util.h" | 41 #include "base/file_util.h" |
| 42 #include "base/file_version_info.h" | 42 #include "base/file_version_info.h" |
| 43 #include "base/path_service.h" | 43 #include "base/path_service.h" |
| 44 #include "base/string_util.h" | 44 #include "base/string_util.h" |
| 45 #include "base/test_file_util.h" |
| 45 #include "base/time.h" | 46 #include "base/time.h" |
| 46 #include "base/time_format.h" | 47 #include "base/time_format.h" |
| 47 #include "chrome/browser/net/url_fixer_upper.h" | 48 #include "chrome/browser/net/url_fixer_upper.h" |
| 48 #include "chrome/common/chrome_constants.h" | 49 #include "chrome/common/chrome_constants.h" |
| 49 #include "chrome/common/chrome_paths.h" | 50 #include "chrome/common/chrome_paths.h" |
| 50 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
| 51 #include "chrome/common/logging_chrome.h" | 52 #include "chrome/common/logging_chrome.h" |
| 52 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
| 53 #include "chrome/common/pref_service.h" | 54 #include "chrome/common/pref_service.h" |
| 54 #include "chrome/test/automation/automation_messages.h" | 55 #include "chrome/test/automation/automation_messages.h" |
| 55 #include "chrome/test/automation/automation_proxy.h" | 56 #include "chrome/test/automation/automation_proxy.h" |
| 56 #include "chrome/test/automation/browser_proxy.h" | 57 #include "chrome/test/automation/browser_proxy.h" |
| 57 #include "chrome/test/automation/tab_proxy.h" | 58 #include "chrome/test/automation/tab_proxy.h" |
| 58 #include "chrome/test/automation/window_proxy.h" | 59 #include "chrome/test/automation/window_proxy.h" |
| 59 #include "chrome/test/ui/ui_test.h" | 60 #include "chrome/test/ui/ui_test.h" |
| 60 #include "chrome/test/perf/mem_usage.h" | 61 #include "chrome/test/perf/mem_usage.h" |
| 61 #include "chrome/test/reliability/page_load_test.h" | 62 #include "chrome/test/reliability/page_load_test.h" |
| 62 #include "net/base/net_util.h" | 63 #include "net/base/net_util.h" |
| 63 | 64 |
| 65 #if defined(OS_WIN) |
| 66 #define MAYBE_Reliability Reliability |
| 67 #else // defined(OS_WIN) |
| 68 // TODO(estade): port till we can enable this. |
| 69 #define MAYBE_Reliability DISABLED_Reliability |
| 70 #endif // !defined(OS_WIN) |
| 71 |
| 64 namespace { | 72 namespace { |
| 65 | 73 |
| 66 // See comments at the beginning of the file for the definition of switches. | 74 // See comments at the beginning of the file for the definition of switches. |
| 67 const wchar_t kSiteSwitch[] = L"site"; | 75 const wchar_t kSiteSwitch[] = L"site"; |
| 68 const wchar_t kStartPageSwitch[] = L"startpage"; | 76 const wchar_t kStartPageSwitch[] = L"startpage"; |
| 69 const wchar_t kEndPageSwitch[] = L"endpage"; | 77 const wchar_t kEndPageSwitch[] = L"endpage"; |
| 70 const wchar_t kListSwitch[] = L"list"; | 78 const wchar_t kListSwitch[] = L"list"; |
| 71 const wchar_t kStartIndexSwitch[] = L"startline"; | 79 const wchar_t kStartIndexSwitch[] = L"startline"; |
| 72 const wchar_t kEndIndexSwitch[] = L"endline"; | 80 const wchar_t kEndIndexSwitch[] = L"endline"; |
| 73 const wchar_t kIterationSwitch[] = L"iterations"; | 81 const wchar_t kIterationSwitch[] = L"iterations"; |
| 74 const wchar_t kContinuousLoadSwitch[] = L"continuousload"; | 82 const wchar_t kContinuousLoadSwitch[] = L"continuousload"; |
| 75 const wchar_t kMemoryUsageSwitch[] = L"memoryusage"; | 83 const wchar_t kMemoryUsageSwitch[] = L"memoryusage"; |
| 76 const wchar_t kEndURLSwitch[] = L"endurl"; | 84 const wchar_t kEndURLSwitch[] = L"endurl"; |
| 77 const wchar_t kLogFileSwitch[] = L"logfile"; | 85 const wchar_t kLogFileSwitch[] = L"logfile"; |
| 78 const wchar_t kTimeoutSwitch[] = L"timeout"; | 86 const wchar_t kTimeoutSwitch[] = L"timeout"; |
| 79 const wchar_t kNoPageDownSwitch[] = L"nopagedown"; | 87 const wchar_t kNoPageDownSwitch[] = L"nopagedown"; |
| 80 const wchar_t kSaveDebugLogSwitch[] = L"savedebuglog"; | 88 const wchar_t kSaveDebugLogSwitch[] = L"savedebuglog"; |
| 81 | 89 |
| 82 std::wstring server_url = L"http://urllist.com"; | 90 const char kDefaultServerUrl[] = "http://urllist.com"; |
| 83 const wchar_t test_page_1[] = L"page1.html"; | 91 char* server_url = NULL; |
| 84 const wchar_t test_page_2[] = L"page2.html"; | 92 const char kTestPage1[] = "page1.html"; |
| 85 const wchar_t crash_url[] = L"about:crash"; | 93 const char kTestPage2[] = "page2.html"; |
| 94 const char crash_url[] = "about:crash"; |
| 86 | 95 |
| 87 // These are copied from v8 definitions as we cannot include them. | 96 // These are copied from v8 definitions as we cannot include them. |
| 88 const wchar_t kV8LogFileSwitch[] = L"logfile"; | 97 const wchar_t kV8LogFileSwitch[] = L"logfile"; |
| 89 const wchar_t kV8LogFileDefaultName[] = L"v8.log"; | 98 const char kV8LogFileDefaultName[] = "v8.log"; |
| 90 | 99 |
| 91 // String name of local chrome dll for looking up file information. | 100 // String name of local chrome dll for looking up file information. |
| 92 std::wstring kChromeDll = L"chrome.dll"; | 101 const wchar_t kChromeDll[] = L"chrome.dll"; |
| 93 | 102 |
| 94 bool append_page_id = false; | 103 bool append_page_id = false; |
| 95 int32 start_page; | 104 int32 start_page; |
| 96 int32 end_page; | 105 int32 end_page; |
| 97 std::wstring url_file_path; | 106 FilePath url_file_path; |
| 98 int32 start_index = 1; | 107 int32 start_index = 1; |
| 99 int32 end_index = kint32max; | 108 int32 end_index = kint32max; |
| 100 int32 iterations = 1; | 109 int32 iterations = 1; |
| 101 bool memory_usage = false; | 110 bool memory_usage = false; |
| 102 bool continuous_load = false; | 111 bool continuous_load = false; |
| 103 bool browser_existing = false; | 112 bool browser_existing = false; |
| 104 bool page_down = true; | 113 bool page_down = true; |
| 105 std::wstring end_url; | 114 GURL end_url; |
| 106 std::wstring log_file_path; | 115 FilePath log_file_path; |
| 107 uint32 timeout_ms = INFINITE; | 116 int timeout_ms = -1; |
| 108 bool save_debug_log = false; | 117 bool save_debug_log = false; |
| 109 std::wstring chrome_log_path; | 118 FilePath chrome_log_path; |
| 110 std::wstring v8_log_path; | 119 FilePath v8_log_path; |
| 111 std::wstring test_log_path; | 120 FilePath test_log_path; |
| 112 bool stand_alone = false; | 121 bool stand_alone = false; |
| 113 | 122 |
| 114 class PageLoadTest : public UITest { | 123 class PageLoadTest : public UITest { |
| 115 public: | 124 public: |
| 116 enum NavigationResult { | 125 enum NavigationResult { |
| 117 NAVIGATION_ERROR = 0, | 126 NAVIGATION_ERROR = 0, |
| 118 NAVIGATION_SUCCESS, | 127 NAVIGATION_SUCCESS, |
| 119 NAVIGATION_AUTH_NEEDED, | 128 NAVIGATION_AUTH_NEEDED, |
| 120 NAVIGATION_TIME_OUT, | 129 NAVIGATION_TIME_OUT, |
| 121 }; | 130 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 int renderer_crash_count; | 141 int renderer_crash_count; |
| 133 int plugin_crash_count; | 142 int plugin_crash_count; |
| 134 } NavigationMetrics; | 143 } NavigationMetrics; |
| 135 | 144 |
| 136 PageLoadTest() { | 145 PageLoadTest() { |
| 137 show_window_ = true; | 146 show_window_ = true; |
| 138 } | 147 } |
| 139 | 148 |
| 140 // Accept URL as string here because the url may also act as a test id | 149 // Accept URL as string here because the url may also act as a test id |
| 141 // and needs to be logged in its original format even if invalid. | 150 // and needs to be logged in its original format even if invalid. |
| 142 void NavigateToURLLogResult(const std::wstring& url_string, | 151 void NavigateToURLLogResult(const GURL& url, |
| 143 std::ofstream& log_file, | 152 std::ofstream& log_file, |
| 144 NavigationMetrics* metrics_output) { | 153 NavigationMetrics* metrics_output) { |
| 145 GURL url = GURL(url_string); | |
| 146 NavigationMetrics metrics = {NAVIGATION_ERROR}; | 154 NavigationMetrics metrics = {NAVIGATION_ERROR}; |
| 147 std::ofstream test_log; | 155 std::ofstream test_log; |
| 148 | 156 |
| 149 // Create a test log. | 157 // Create a test log. |
| 150 test_log_path = L"test_log.log"; | 158 test_log_path = FilePath(FILE_PATH_LITERAL("test_log.log")); |
| 151 test_log.open(test_log_path.c_str()); | 159 test_log.open(test_log_path.value().c_str()); |
| 152 | 160 |
| 161 // TODO(estade): port. |
| 162 #if defined(OS_WIN) |
| 153 // Check file version info for chrome dll. | 163 // Check file version info for chrome dll. |
| 154 FileVersionInfo* file_info; | 164 FileVersionInfo* file_info; |
| 155 file_info = FileVersionInfo::CreateFileVersionInfo(kChromeDll); | 165 file_info = FileVersionInfo::CreateFileVersionInfo(kChromeDll); |
| 156 std::wstring last_change = file_info->last_change(); | 166 std::wstring last_change = file_info->last_change(); |
| 157 test_log << "Last Change: "; | 167 test_log << "Last Change: "; |
| 158 test_log << last_change << std::endl; | 168 test_log << last_change << std::endl; |
| 169 #endif // defined(OS_WIN) |
| 159 | 170 |
| 160 // Log timestamp for test start. | 171 // Log timestamp for test start. |
| 161 base::Time time_now = base::Time::Now(); | 172 base::Time time_now = base::Time::Now(); |
| 162 double time_start = time_now.ToDoubleT(); | 173 double time_start = time_now.ToDoubleT(); |
| 163 test_log << "Test Start: "; | 174 test_log << "Test Start: "; |
| 164 test_log << base::TimeFormatFriendlyDateAndTime(time_now) << std::endl; | 175 test_log << base::TimeFormatFriendlyDateAndTime(time_now) << std::endl; |
| 165 | 176 |
| 166 if (!continuous_load && !browser_existing) { | 177 if (!continuous_load && !browser_existing) { |
| 167 LaunchBrowserAndServer(); | 178 LaunchBrowserAndServer(); |
| 168 browser_existing = true; | 179 browser_existing = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 189 if (page_down) { | 200 if (page_down) { |
| 190 // Page down twice. | 201 // Page down twice. |
| 191 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0))
; | 202 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0))
; |
| 192 if (browser.get()) { | 203 if (browser.get()) { |
| 193 scoped_refptr<WindowProxy> window(browser->GetWindow()); | 204 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
| 194 if (window.get()) { | 205 if (window.get()) { |
| 195 bool activation_timeout; | 206 bool activation_timeout; |
| 196 browser->BringToFrontWithTimeout(action_max_timeout_ms(), | 207 browser->BringToFrontWithTimeout(action_max_timeout_ms(), |
| 197 &activation_timeout); | 208 &activation_timeout); |
| 198 if (!activation_timeout) { | 209 if (!activation_timeout) { |
| 210 // TODO(estade): port. |
| 211 #if defined(OS_WIN) |
| 199 window->SimulateOSKeyPress(VK_NEXT, 0); | 212 window->SimulateOSKeyPress(VK_NEXT, 0); |
| 200 PlatformThread::Sleep(sleep_timeout_ms()); | 213 PlatformThread::Sleep(sleep_timeout_ms()); |
| 201 window->SimulateOSKeyPress(VK_NEXT, 0); | 214 window->SimulateOSKeyPress(VK_NEXT, 0); |
| 202 PlatformThread::Sleep(sleep_timeout_ms()); | 215 PlatformThread::Sleep(sleep_timeout_ms()); |
| 216 #endif // defined(OS_WIN) |
| 203 } | 217 } |
| 204 } | 218 } |
| 205 } | 219 } |
| 206 } | 220 } |
| 207 } | 221 } |
| 208 } | 222 } |
| 209 | 223 |
| 210 // Log navigate complete time. | 224 // Log navigate complete time. |
| 211 time_now = base::Time::Now(); | 225 time_now = base::Time::Now(); |
| 212 test_log << "navigate_complete_seconds="; | 226 test_log << "navigate_complete_seconds="; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 case AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED: | 262 case AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED: |
| 249 metrics.result = NAVIGATION_AUTH_NEEDED; | 263 metrics.result = NAVIGATION_AUTH_NEEDED; |
| 250 break; | 264 break; |
| 251 default: | 265 default: |
| 252 metrics.result = NAVIGATION_ERROR; | 266 metrics.result = NAVIGATION_ERROR; |
| 253 break; | 267 break; |
| 254 } | 268 } |
| 255 } | 269 } |
| 256 | 270 |
| 257 if (log_file.is_open()) { | 271 if (log_file.is_open()) { |
| 258 log_file << url_string; | 272 log_file << url.spec(); |
| 259 switch (metrics.result) { | 273 switch (metrics.result) { |
| 260 case NAVIGATION_ERROR: | 274 case NAVIGATION_ERROR: |
| 261 log_file << " error"; | 275 log_file << " error"; |
| 262 break; | 276 break; |
| 263 case NAVIGATION_SUCCESS: | 277 case NAVIGATION_SUCCESS: |
| 264 log_file << " success"; | 278 log_file << " success"; |
| 265 break; | 279 break; |
| 266 case NAVIGATION_AUTH_NEEDED: | 280 case NAVIGATION_AUTH_NEEDED: |
| 267 log_file << " auth_needed"; | 281 log_file << " auth_needed"; |
| 268 break; | 282 break; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 285 << " " << 0 \ | 299 << " " << 0 \ |
| 286 << " " << metrics.plugin_crash_count \ | 300 << " " << metrics.plugin_crash_count \ |
| 287 << " " << metrics.crash_dump_count; | 301 << " " << metrics.crash_dump_count; |
| 288 } | 302 } |
| 289 | 303 |
| 290 // Close test log. | 304 // Close test log. |
| 291 test_log.close(); | 305 test_log.close(); |
| 292 | 306 |
| 293 if (log_file.is_open() && save_debug_log && !continuous_load) | 307 if (log_file.is_open() && save_debug_log && !continuous_load) |
| 294 SaveDebugLogs(log_file); | 308 SaveDebugLogs(log_file); |
| 295 | 309 |
| 310 // TODO(estade): port. |
| 311 #if defined(OS_WIN) |
| 296 // Log revision information for Chrome build under test. | 312 // Log revision information for Chrome build under test. |
| 297 log_file << " " << "revision=" << last_change; | 313 log_file << " " << "revision=" << last_change; |
| 314 #endif // defined(OS_WIN) |
| 298 | 315 |
| 299 // Get crash dumps. | 316 // Get crash dumps. |
| 300 LogOrDeleteNewCrashDumps(log_file, &metrics); | 317 LogOrDeleteNewCrashDumps(log_file, &metrics); |
| 301 | 318 |
| 302 if (log_file.is_open()) { | 319 if (log_file.is_open()) { |
| 303 log_file << std::endl; | 320 log_file << std::endl; |
| 304 } | 321 } |
| 305 | 322 |
| 306 if (metrics_output) { | 323 if (metrics_output) { |
| 307 *metrics_output = metrics; | 324 *metrics_output = metrics; |
| 308 } | 325 } |
| 309 } | 326 } |
| 310 | 327 |
| 311 void NavigateThroughPageID(std::ofstream& log_file) { | 328 void NavigateThroughPageID(std::ofstream& log_file) { |
| 312 if (append_page_id) { | 329 if (append_page_id) { |
| 313 // For usage 2 | 330 // For usage 2 |
| 314 for (int i = start_page; i <= end_page; ++i) { | 331 for (int i = start_page; i <= end_page; ++i) { |
| 315 std::wstring test_page_url( | 332 const char* server = server_url ? server_url : kDefaultServerUrl; |
| 316 StringPrintf(L"%ls/page?id=%d", server_url.c_str(), i)); | 333 std::string test_page_url( |
| 317 NavigateToURLLogResult(test_page_url, log_file, NULL); | 334 StringPrintf("%s/page?id=%d", server, i)); |
| 335 NavigateToURLLogResult(GURL(test_page_url), log_file, NULL); |
| 318 } | 336 } |
| 319 } else { | 337 } else { |
| 320 // Don't run if single process mode. | 338 // Don't run if single process mode. |
| 321 // Also don't run if running as a standalone program which is for | 339 // Also don't run if running as a standalone program which is for |
| 322 // distributed testing, to avoid mistakenly hitting web sites with many | 340 // distributed testing, to avoid mistakenly hitting web sites with many |
| 323 // instances. | 341 // instances. |
| 324 if (in_process_renderer() || stand_alone) | 342 if (in_process_renderer() || stand_alone) |
| 325 return; | 343 return; |
| 326 // For usage 1 | 344 // For usage 1 |
| 327 NavigationMetrics metrics; | 345 NavigationMetrics metrics; |
| 328 if (timeout_ms == INFINITE) | 346 if (timeout_ms == -1) |
| 329 timeout_ms = 2000; | 347 timeout_ms = 2000; |
| 330 | 348 |
| 331 // Though it would be nice to test the page down code path in usage 1, | 349 // Though it would be nice to test the page down code path in usage 1, |
| 332 // enabling page down adds several seconds to the test and does not seem | 350 // enabling page down adds several seconds to the test and does not seem |
| 333 // worth the tradeoff. It is also potentially disruptive when running the | 351 // worth the tradeoff. It is also potentially disruptive when running the |
| 334 // test in the background as it will send the event to the window that | 352 // test in the background as it will send the event to the window that |
| 335 // has focus. | 353 // has focus. |
| 336 page_down = false; | 354 page_down = false; |
| 337 | 355 |
| 338 FilePath sample_data_dir = GetSampleDataDir(); | 356 FilePath sample_data_dir = GetSampleDataDir(); |
| 339 FilePath test_page_1 = sample_data_dir.AppendASCII("page1.html"); | 357 FilePath test_page_1 = sample_data_dir.AppendASCII(kTestPage1); |
| 340 FilePath test_page_2 = sample_data_dir.AppendASCII("page2.html"); | 358 FilePath test_page_2 = sample_data_dir.AppendASCII(kTestPage2); |
| 341 | 359 |
| 342 GURL test_url_1 = net::FilePathToFileURL(test_page_1); | 360 GURL test_url_1 = net::FilePathToFileURL(test_page_1); |
| 343 GURL test_url_2 = net::FilePathToFileURL(test_page_2); | 361 GURL test_url_2 = net::FilePathToFileURL(test_page_2); |
| 344 | 362 |
| 345 // Convert back to string so that all calls to navigate are the same. | 363 NavigateToURLLogResult(test_url_1, log_file, &metrics); |
| 346 const std::wstring test_url_1_string = ASCIIToWide(test_url_1.spec()); | |
| 347 const std::wstring test_url_2_string = ASCIIToWide(test_url_2.spec()); | |
| 348 | |
| 349 NavigateToURLLogResult(test_url_1_string, log_file, &metrics); | |
| 350 // Verify everything is fine | 364 // Verify everything is fine |
| 351 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); | 365 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); |
| 352 EXPECT_EQ(0, metrics.crash_dump_count); | 366 EXPECT_EQ(0, metrics.crash_dump_count); |
| 353 EXPECT_EQ(true, metrics.browser_clean_exit); | 367 EXPECT_EQ(true, metrics.browser_clean_exit); |
| 354 EXPECT_EQ(1, metrics.browser_launch_count); | 368 EXPECT_EQ(1, metrics.browser_launch_count); |
| 355 // Both starting page and test_url_1 are loaded. | 369 // Both starting page and test_url_1 are loaded. |
| 356 EXPECT_EQ(2, metrics.page_load_count); | 370 EXPECT_EQ(2, metrics.page_load_count); |
| 357 EXPECT_EQ(0, metrics.browser_crash_count); | 371 EXPECT_EQ(0, metrics.browser_crash_count); |
| 358 EXPECT_EQ(0, metrics.renderer_crash_count); | 372 EXPECT_EQ(0, metrics.renderer_crash_count); |
| 359 EXPECT_EQ(0, metrics.plugin_crash_count); | 373 EXPECT_EQ(0, metrics.plugin_crash_count); |
| 360 | 374 |
| 361 // Go to "about:crash" | 375 // Go to "about:crash" |
| 362 NavigateToURLLogResult(std::wstring(crash_url), log_file, &metrics); | 376 NavigateToURLLogResult(GURL(crash_url), log_file, &metrics); |
| 363 // Found a crash dump | 377 // Found a crash dump |
| 364 EXPECT_EQ(1, metrics.crash_dump_count) << kFailedNoCrashService; | 378 EXPECT_EQ(1, metrics.crash_dump_count) << kFailedNoCrashService; |
| 365 // Browser did not crash, and exited cleanly. | 379 // Browser did not crash, and exited cleanly. |
| 366 EXPECT_EQ(true, metrics.browser_clean_exit); | 380 EXPECT_EQ(true, metrics.browser_clean_exit); |
| 367 EXPECT_EQ(1, metrics.browser_launch_count); | 381 EXPECT_EQ(1, metrics.browser_launch_count); |
| 368 // Only the renderer should have crashed. | 382 // Only the renderer should have crashed. |
| 369 EXPECT_EQ(0, metrics.browser_crash_count); | 383 EXPECT_EQ(0, metrics.browser_crash_count); |
| 370 EXPECT_EQ(1, metrics.renderer_crash_count); | 384 EXPECT_EQ(1, metrics.renderer_crash_count); |
| 371 EXPECT_EQ(0, metrics.plugin_crash_count); | 385 EXPECT_EQ(0, metrics.plugin_crash_count); |
| 372 | 386 |
| 373 NavigateToURLLogResult(test_url_2_string, log_file, &metrics); | 387 NavigateToURLLogResult(test_url_2, log_file, &metrics); |
| 374 // The data on previous crash should be cleared and we should get | 388 // The data on previous crash should be cleared and we should get |
| 375 // metrics for a successful page load. | 389 // metrics for a successful page load. |
| 376 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); | 390 EXPECT_EQ(NAVIGATION_SUCCESS, metrics.result); |
| 377 EXPECT_EQ(0, metrics.crash_dump_count); | 391 EXPECT_EQ(0, metrics.crash_dump_count); |
| 378 EXPECT_EQ(true, metrics.browser_clean_exit); | 392 EXPECT_EQ(true, metrics.browser_clean_exit); |
| 379 EXPECT_EQ(1, metrics.browser_launch_count); | 393 EXPECT_EQ(1, metrics.browser_launch_count); |
| 380 EXPECT_EQ(0, metrics.browser_crash_count); | 394 EXPECT_EQ(0, metrics.browser_crash_count); |
| 381 EXPECT_EQ(0, metrics.renderer_crash_count); | 395 EXPECT_EQ(0, metrics.renderer_crash_count); |
| 382 EXPECT_EQ(0, metrics.plugin_crash_count); | 396 EXPECT_EQ(0, metrics.plugin_crash_count); |
| 383 | 397 |
| 384 // Verify metrics service does what we need when browser process crashes. | 398 // Verify metrics service does what we need when browser process crashes. |
| 385 HANDLE browser_process; | |
| 386 LaunchBrowserAndServer(); | 399 LaunchBrowserAndServer(); |
| 387 { | 400 { |
| 388 // TabProxy should be released before Browser is closed. | 401 // TabProxy should be released before Browser is closed. |
| 389 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 402 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 390 if (tab_proxy.get()) { | 403 if (tab_proxy.get()) { |
| 391 tab_proxy->NavigateToURL(GURL(test_url_1)); | 404 tab_proxy->NavigateToURL(GURL(test_url_1)); |
| 392 } | 405 } |
| 393 } | 406 } |
| 394 // Kill browser process. | 407 // Kill browser process. |
| 395 browser_process = process(); | 408 base::ProcessHandle browser_process = process(); |
| 396 TerminateProcess(browser_process, 0); | 409 base::KillProcess(browser_process, 0, false); |
| 397 | 410 |
| 398 GetStabilityMetrics(&metrics); | 411 GetStabilityMetrics(&metrics); |
| 399 // This is not a clean shutdown. | 412 // This is not a clean shutdown. |
| 400 EXPECT_EQ(false, metrics.browser_clean_exit); | 413 EXPECT_EQ(false, metrics.browser_clean_exit); |
| 401 EXPECT_EQ(1, metrics.browser_crash_count); | 414 EXPECT_EQ(1, metrics.browser_crash_count); |
| 402 EXPECT_EQ(0, metrics.renderer_crash_count); | 415 EXPECT_EQ(0, metrics.renderer_crash_count); |
| 403 EXPECT_EQ(0, metrics.plugin_crash_count); | 416 EXPECT_EQ(0, metrics.plugin_crash_count); |
| 404 // Relaunch browser so UITest does not fire assertion during TearDown. | 417 // Relaunch browser so UITest does not fire assertion during TearDown. |
| 405 LaunchBrowserAndServer(); | 418 LaunchBrowserAndServer(); |
| 406 } | 419 } |
| 407 } | 420 } |
| 408 | 421 |
| 409 // For usage 3 | 422 // For usage 3 |
| 410 void NavigateThroughURLList(std::ofstream& log_file) { | 423 void NavigateThroughURLList(std::ofstream& log_file) { |
| 411 std::ifstream file(url_file_path.c_str()); | 424 std::ifstream file(url_file_path.value().c_str()); |
| 412 ASSERT_TRUE(file.is_open()); | 425 ASSERT_TRUE(file.is_open()); |
| 413 | 426 |
| 414 for (int line_index = 1; | 427 for (int line_index = 1; |
| 415 line_index <= end_index && !file.eof(); | 428 line_index <= end_index && !file.eof(); |
| 416 ++line_index) { | 429 ++line_index) { |
| 417 std::string url_str; | 430 std::string url_str; |
| 418 std::getline(file, url_str); | 431 std::getline(file, url_str); |
| 419 | 432 |
| 420 if (file.fail()) | 433 if (file.fail()) |
| 421 break; | 434 break; |
| 422 | 435 |
| 423 if (start_index <= line_index) { | 436 if (start_index <= line_index) { |
| 424 NavigateToURLLogResult(ASCIIToWide(url_str), log_file, NULL); | 437 NavigateToURLLogResult(GURL(url_str), log_file, NULL); |
| 425 } | 438 } |
| 426 } | 439 } |
| 427 | 440 |
| 428 file.close(); | 441 file.close(); |
| 429 } | 442 } |
| 430 | 443 |
| 431 protected: | 444 protected: |
| 432 // Call the base class's SetUp method and initialize our own class members. | 445 // Call the base class's SetUp method and initialize our own class members. |
| 433 virtual void SetUp() { | 446 virtual void SetUp() { |
| 434 UITest::SetUp(); | 447 UITest::SetUp(); |
| 435 browser_existing = true; | 448 browser_existing = true; |
| 436 | 449 |
| 450 // TODO(estade): port. |
| 451 #if defined(OS_WIN) |
| 437 // Initialize crash_dumps_dir_path_. | 452 // Initialize crash_dumps_dir_path_. |
| 438 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); | 453 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); |
| 439 // Initialize crash_dumps_. | 454 // Initialize crash_dumps_. |
| 440 WIN32_FIND_DATAW find_data; | 455 WIN32_FIND_DATAW find_data; |
| 441 HANDLE find_handle; | 456 HANDLE find_handle; |
| 442 std::wstring dir_spec(crash_dumps_dir_path_); | 457 std::wstring dir_spec(crash_dumps_dir_path_); |
| 443 dir_spec.append(L"\\*"); // list all files in the directory | 458 dir_spec.append(L"\\*"); // list all files in the directory |
| 444 find_handle = FindFirstFileW(dir_spec.c_str(), &find_data); | 459 find_handle = FindFirstFileW(dir_spec.c_str(), &find_data); |
| 445 if (find_handle != INVALID_HANDLE_VALUE) { | 460 if (find_handle != INVALID_HANDLE_VALUE) { |
| 446 if (wcsstr(find_data.cFileName, L".dmp")) | 461 if (wcsstr(find_data.cFileName, L".dmp")) |
| 447 crash_dumps_[std::wstring(find_data.cFileName)] = true; | 462 crash_dumps_[std::wstring(find_data.cFileName)] = true; |
| 448 while (FindNextFile(find_handle, &find_data)) { | 463 while (FindNextFile(find_handle, &find_data)) { |
| 449 if (wcsstr(find_data.cFileName, L".dmp")) | 464 if (wcsstr(find_data.cFileName, L".dmp")) |
| 450 crash_dumps_[std::wstring(find_data.cFileName)] = true; | 465 crash_dumps_[std::wstring(find_data.cFileName)] = true; |
| 451 } | 466 } |
| 452 FindClose(find_handle); | 467 FindClose(find_handle); |
| 453 } | 468 } |
| 469 #endif // defined(OS_WIN) |
| 454 } | 470 } |
| 455 | 471 |
| 456 FilePath ConstructSavedDebugLogPath(const FilePath& debug_log_path, | 472 FilePath ConstructSavedDebugLogPath(const FilePath& debug_log_path, |
| 457 int index) { | 473 int index) { |
| 458 std::wstring suffix(L"_"); | 474 std::string suffix("_"); |
| 459 suffix.append(IntToWString(index)); | 475 suffix.append(IntToString(index)); |
| 460 return debug_log_path.InsertBeforeExtension(suffix); | 476 return debug_log_path.InsertBeforeExtensionASCII(suffix); |
| 461 } | 477 } |
| 462 | 478 |
| 463 void SaveDebugLog(const std::wstring& log_path, const std::wstring& log_id, | 479 void SaveDebugLog(const FilePath& log_path, const std::wstring& log_id, |
| 464 std::ofstream& log_file, int index) { | 480 std::ofstream& log_file, int index) { |
| 465 if (!log_path.empty()) { | 481 if (!log_path.empty()) { |
| 466 FilePath log_file_path(log_path); | |
| 467 FilePath saved_log_file_path = | 482 FilePath saved_log_file_path = |
| 468 ConstructSavedDebugLogPath(log_file_path, index); | 483 ConstructSavedDebugLogPath(log_path, index); |
| 469 if (file_util::Move(log_file_path, saved_log_file_path)) { | 484 if (file_util::Move(log_file_path, saved_log_file_path)) { |
| 470 log_file << " " << log_id << "=" << saved_log_file_path.value(); | 485 log_file << " " << log_id << "=" << saved_log_file_path.value(); |
| 471 } | 486 } |
| 472 } | 487 } |
| 473 } | 488 } |
| 474 | 489 |
| 475 // Rename the chrome and v8 debug log files if existing, and save the file | 490 // Rename the chrome and v8 debug log files if existing, and save the file |
| 476 // paths in the log_file provided. | 491 // paths in the log_file provided. |
| 477 void SaveDebugLogs(std::ofstream& log_file) { | 492 void SaveDebugLogs(std::ofstream& log_file) { |
| 478 static int url_count = 1; | 493 static int url_count = 1; |
| 479 SaveDebugLog(chrome_log_path, L"chrome_log", log_file, url_count); | 494 SaveDebugLog(chrome_log_path, L"chrome_log", log_file, url_count); |
| 480 SaveDebugLog(v8_log_path, L"v8_log", log_file, url_count); | 495 SaveDebugLog(v8_log_path, L"v8_log", log_file, url_count); |
| 481 SaveDebugLog(test_log_path, L"test_log", log_file, url_count); | 496 SaveDebugLog(test_log_path, L"test_log", log_file, url_count); |
| 482 url_count++; | 497 url_count++; |
| 483 } | 498 } |
| 484 | 499 |
| 485 // If a log_file is provided, log the crash dump with the given path; | 500 // If a log_file is provided, log the crash dump with the given path; |
| 486 // otherwise, delete the crash dump file. | 501 // otherwise, delete the crash dump file. |
| 487 void LogOrDeleteCrashDump(std::ofstream& log_file, | 502 void LogOrDeleteCrashDump(std::ofstream& log_file, |
| 488 std::wstring crash_dump_file_name) { | 503 std::wstring crash_dump_file_name) { |
| 489 | |
| 490 std::wstring crash_dump_file_path(crash_dumps_dir_path_); | 504 std::wstring crash_dump_file_path(crash_dumps_dir_path_); |
| 491 crash_dump_file_path.append(L"\\"); | 505 crash_dump_file_path.append(L"\\"); |
| 492 crash_dump_file_path.append(crash_dump_file_name); | 506 crash_dump_file_path.append(crash_dump_file_name); |
| 493 std::wstring crash_text_file_path(crash_dump_file_path); | 507 std::wstring crash_text_file_path(crash_dump_file_path); |
| 494 crash_text_file_path.replace(crash_text_file_path.length() - 3, | 508 crash_text_file_path.replace(crash_text_file_path.length() - 3, |
| 495 3, L"txt"); | 509 3, L"txt"); |
| 496 | 510 |
| 497 if (log_file.is_open()) { | 511 if (log_file.is_open()) { |
| 498 crash_dumps_[crash_dump_file_name] = true; | 512 crash_dumps_[crash_dump_file_name] = true; |
| 499 log_file << " crash_dump=" << crash_dump_file_path; | 513 log_file << " crash_dump=" << crash_dump_file_path; |
| 500 } else { | 514 } else { |
| 501 ASSERT_TRUE(DeleteFileW(crash_dump_file_path.c_str())); | 515 ASSERT_TRUE(file_util::DieFileDie(crash_dump_file_path, false)); |
| 502 ASSERT_TRUE(DeleteFileW(crash_text_file_path.c_str())); | 516 ASSERT_TRUE(file_util::DieFileDie(crash_text_file_path, false)); |
| 503 } | 517 } |
| 504 } | 518 } |
| 505 | 519 |
| 506 // Check whether there are new .dmp files. Additionally, write | 520 // Check whether there are new .dmp files. Additionally, write |
| 507 // " crash_dump=<full path name of the .dmp file>" | 521 // " crash_dump=<full path name of the .dmp file>" |
| 508 // to log_file. | 522 // to log_file. |
| 509 void LogOrDeleteNewCrashDumps(std::ofstream& log_file, | 523 void LogOrDeleteNewCrashDumps(std::ofstream& log_file, |
| 510 NavigationMetrics* metrics) { | 524 NavigationMetrics* metrics) { |
| 525 // TODO(estade): port. |
| 526 #if defined(OS_WIN) |
| 511 WIN32_FIND_DATAW find_data; | 527 WIN32_FIND_DATAW find_data; |
| 512 HANDLE find_handle; | 528 HANDLE find_handle; |
| 513 int num_dumps = 0; | 529 int num_dumps = 0; |
| 514 | 530 |
| 515 std::wstring dir_spec(crash_dumps_dir_path_); | 531 std::wstring dir_spec(crash_dumps_dir_path_); |
| 516 dir_spec.append(L"\\*"); // list all files in the directory | 532 dir_spec.append(L"\\*"); // list all files in the directory |
| 517 find_handle = FindFirstFileW(dir_spec.c_str(), &find_data); | 533 find_handle = FindFirstFileW(dir_spec.c_str(), &find_data); |
| 518 if (find_handle != INVALID_HANDLE_VALUE) { | 534 if (find_handle != INVALID_HANDLE_VALUE) { |
| 519 if (wcsstr(find_data.cFileName, L".dmp") && | 535 if (wcsstr(find_data.cFileName, L".dmp") && |
| 520 !crash_dumps_[std::wstring(find_data.cFileName)]) { | 536 !crash_dumps_[std::wstring(find_data.cFileName)]) { |
| 521 LogOrDeleteCrashDump(log_file, find_data.cFileName); | 537 LogOrDeleteCrashDump(log_file, find_data.cFileName); |
| 522 num_dumps++; | 538 num_dumps++; |
| 523 } | 539 } |
| 524 while (FindNextFile(find_handle, &find_data)) { | 540 while (FindNextFile(find_handle, &find_data)) { |
| 525 if (wcsstr(find_data.cFileName, L".dmp") && | 541 if (wcsstr(find_data.cFileName, L".dmp") && |
| 526 !crash_dumps_[std::wstring(find_data.cFileName)]) { | 542 !crash_dumps_[std::wstring(find_data.cFileName)]) { |
| 527 LogOrDeleteCrashDump(log_file, find_data.cFileName); | 543 LogOrDeleteCrashDump(log_file, find_data.cFileName); |
| 528 num_dumps++; | 544 num_dumps++; |
| 529 } | 545 } |
| 530 } | 546 } |
| 531 FindClose(find_handle); | 547 FindClose(find_handle); |
| 532 } | 548 } |
| 533 | 549 |
| 534 if (metrics) | 550 if (metrics) |
| 535 metrics->crash_dump_count = num_dumps; | 551 metrics->crash_dump_count = num_dumps; |
| 552 #endif // defined(OS_WIN) |
| 536 } | 553 } |
| 537 | 554 |
| 538 // Get a PrefService whose contents correspond to the Local State file | 555 // Get a PrefService whose contents correspond to the Local State file |
| 539 // that was saved by the app as it closed. The caller takes ownership of the | 556 // that was saved by the app as it closed. The caller takes ownership of the |
| 540 // returned PrefService object. | 557 // returned PrefService object. |
| 541 PrefService* GetLocalState() { | 558 PrefService* GetLocalState() { |
| 542 FilePath local_state_path = user_data_dir() | 559 FilePath local_state_path = user_data_dir() |
| 543 .Append(chrome::kLocalStateFilename); | 560 .Append(chrome::kLocalStateFilename); |
| 544 | 561 |
| 545 PrefService* local_state(new PrefService(local_state_path, NULL)); | 562 PrefService* local_state(new PrefService(local_state_path, NULL)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // The set is implemented as a std::map. The key is the file name, and | 610 // The set is implemented as a std::map. The key is the file name, and |
| 594 // the value is false (the file is not in the set) or true (the file is | 611 // the value is false (the file is not in the set) or true (the file is |
| 595 // in the set). The initial value for any key in std::map is 0 (false), | 612 // in the set). The initial value for any key in std::map is 0 (false), |
| 596 // which in this case means a new file is not in the set initially, | 613 // which in this case means a new file is not in the set initially, |
| 597 // exactly the semantics we want. | 614 // exactly the semantics we want. |
| 598 std::map<std::wstring, bool> crash_dumps_; | 615 std::map<std::wstring, bool> crash_dumps_; |
| 599 }; | 616 }; |
| 600 | 617 |
| 601 } // namespace | 618 } // namespace |
| 602 | 619 |
| 603 TEST_F(PageLoadTest, Reliability) { | 620 TEST_F(PageLoadTest, MAYBE_Reliability) { |
| 604 std::ofstream log_file; | 621 std::ofstream log_file; |
| 605 | 622 |
| 606 if (!log_file_path.empty()) { | 623 if (!log_file_path.empty()) { |
| 607 log_file.open(log_file_path.c_str()); | 624 log_file.open(log_file_path.value().c_str()); |
| 608 } | 625 } |
| 609 | 626 |
| 610 for (int k = 0; k < iterations; ++k) { | 627 for (int k = 0; k < iterations; ++k) { |
| 611 if (url_file_path.empty()) { | 628 if (url_file_path.empty()) { |
| 612 NavigateThroughPageID(log_file); | 629 NavigateThroughPageID(log_file); |
| 613 } else { | 630 } else { |
| 614 NavigateThroughURLList(log_file); | 631 NavigateThroughURLList(log_file); |
| 615 } | 632 } |
| 616 | 633 |
| 634 // TODO(estade): port. |
| 635 #if defined(OS_WIN) |
| 617 if (memory_usage) | 636 if (memory_usage) |
| 618 PrintChromeMemoryUsageInfo(); | 637 PrintChromeMemoryUsageInfo(); |
| 638 #endif // defined(OS_WIN) |
| 619 } | 639 } |
| 620 | 640 |
| 621 if (!end_url.empty()) { | 641 if (!end_url.is_empty()) { |
| 622 NavigateToURLLogResult(end_url, log_file, NULL); | 642 NavigateToURLLogResult(end_url, log_file, NULL); |
| 623 } | 643 } |
| 624 | 644 |
| 625 log_file.close(); | 645 log_file.close(); |
| 626 } | 646 } |
| 627 | 647 |
| 628 namespace { | 648 namespace { |
| 629 void ReportHandler(const std::string& str) { | 649 void ReportHandler(const std::string& str) { |
| 630 // Ignore report events. | 650 // Ignore report events. |
| 631 } | 651 } |
| 632 } | 652 } |
| 633 | 653 |
| 634 void SetPageRange(const CommandLine& parsed_command_line) { | 654 void SetPageRange(const CommandLine& parsed_command_line) { |
| 635 // If calling into this function, we are running as a standalone program. | 655 // If calling into this function, we are running as a standalone program. |
| 636 stand_alone = true; | 656 stand_alone = true; |
| 637 | 657 |
| 638 // Since we use --enable-dcheck for reliability tests, suppress the error | 658 // Since we use --enable-dcheck for reliability tests, suppress the error |
| 639 // dialog in the test process. | 659 // dialog in the test process. |
| 640 logging::SetLogReportHandler(ReportHandler); | 660 logging::SetLogReportHandler(ReportHandler); |
| 641 | 661 |
| 642 if (parsed_command_line.HasSwitch(kStartPageSwitch)) { | 662 if (parsed_command_line.HasSwitch(kStartPageSwitch)) { |
| 643 ASSERT_TRUE(parsed_command_line.HasSwitch(kEndPageSwitch)); | 663 ASSERT_TRUE(parsed_command_line.HasSwitch(kEndPageSwitch)); |
| 644 start_page = | 664 ASSERT_TRUE( |
| 645 _wtoi(parsed_command_line.GetSwitchValue(kStartPageSwitch).c_str()); | 665 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( |
| 646 end_page = | 666 kStartPageSwitch)), &start_page)); |
| 647 _wtoi(parsed_command_line.GetSwitchValue(kEndPageSwitch).c_str()); | 667 ASSERT_TRUE( |
| 668 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( |
| 669 kEndPageSwitch)), &end_page)); |
| 648 ASSERT_TRUE(start_page > 0 && end_page > 0); | 670 ASSERT_TRUE(start_page > 0 && end_page > 0); |
| 649 ASSERT_TRUE(start_page < end_page); | 671 ASSERT_TRUE(start_page < end_page); |
| 650 append_page_id = true; | 672 append_page_id = true; |
| 651 } else { | 673 } else { |
| 652 ASSERT_FALSE(parsed_command_line.HasSwitch(kEndPageSwitch)); | 674 ASSERT_FALSE(parsed_command_line.HasSwitch(kEndPageSwitch)); |
| 653 } | 675 } |
| 654 | 676 |
| 655 if (parsed_command_line.HasSwitch(kSiteSwitch)) | 677 if (parsed_command_line.HasSwitch(kSiteSwitch)) { |
| 656 server_url.assign(parsed_command_line.GetSwitchValue(kSiteSwitch)); | 678 server_url = |
| 679 strdup(WideToUTF8(parsed_command_line.GetSwitchValue(kSiteSwitch))); |
| 680 } |
| 657 | 681 |
| 658 if (parsed_command_line.HasSwitch(kStartIndexSwitch)) { | 682 if (parsed_command_line.HasSwitch(kStartIndexSwitch)) { |
| 659 start_index = | 683 ASSERT_TRUE( |
| 660 _wtoi(parsed_command_line.GetSwitchValue(kStartIndexSwitch).c_str()); | 684 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( |
| 685 kStartIndexSwitch)), &start_index)); |
| 661 ASSERT_TRUE(start_index > 0); | 686 ASSERT_TRUE(start_index > 0); |
| 662 } | 687 } |
| 663 | 688 |
| 664 if (parsed_command_line.HasSwitch(kEndIndexSwitch)) { | 689 if (parsed_command_line.HasSwitch(kEndIndexSwitch)) { |
| 665 end_index = | 690 ASSERT_TRUE( |
| 666 _wtoi(parsed_command_line.GetSwitchValue(kEndIndexSwitch).c_str()); | 691 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( |
| 692 kEndIndexSwitch)), &end_index)); |
| 667 ASSERT_TRUE(end_index > 0); | 693 ASSERT_TRUE(end_index > 0); |
| 668 } | 694 } |
| 669 | 695 |
| 670 ASSERT_TRUE(end_index >= start_index); | 696 ASSERT_TRUE(end_index >= start_index); |
| 671 | 697 |
| 672 if (parsed_command_line.HasSwitch(kListSwitch)) | 698 if (parsed_command_line.HasSwitch(kListSwitch)) { |
| 673 url_file_path.assign(parsed_command_line.GetSwitchValue(kListSwitch)); | 699 url_file_path = FilePath::FromWStringHack( |
| 700 parsed_command_line.GetSwitchValue(kListSwitch)); |
| 701 } |
| 674 | 702 |
| 675 if (parsed_command_line.HasSwitch(kIterationSwitch)) { | 703 if (parsed_command_line.HasSwitch(kIterationSwitch)) { |
| 676 iterations = | 704 ASSERT_TRUE( |
| 677 _wtoi(parsed_command_line.GetSwitchValue(kIterationSwitch).c_str()); | 705 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( |
| 706 kIterationSwitch)), &iterations)); |
| 678 ASSERT_TRUE(iterations > 0); | 707 ASSERT_TRUE(iterations > 0); |
| 679 } | 708 } |
| 680 | 709 |
| 681 if (parsed_command_line.HasSwitch(kMemoryUsageSwitch)) | 710 if (parsed_command_line.HasSwitch(kMemoryUsageSwitch)) |
| 682 memory_usage = true; | 711 memory_usage = true; |
| 683 | 712 |
| 684 if (parsed_command_line.HasSwitch(kContinuousLoadSwitch)) | 713 if (parsed_command_line.HasSwitch(kContinuousLoadSwitch)) |
| 685 continuous_load = true; | 714 continuous_load = true; |
| 686 | 715 |
| 687 if (parsed_command_line.HasSwitch(kEndURLSwitch)) | 716 if (parsed_command_line.HasSwitch(kEndURLSwitch)) { |
| 688 end_url.assign(parsed_command_line.GetSwitchValue(kEndURLSwitch)); | 717 end_url = GURL(WideToUTF8( |
| 718 parsed_command_line.GetSwitchValue(kEndURLSwitch))); |
| 719 } |
| 689 | 720 |
| 690 if (parsed_command_line.HasSwitch(kLogFileSwitch)) | 721 if (parsed_command_line.HasSwitch(kLogFileSwitch)) { |
| 691 log_file_path.assign(parsed_command_line.GetSwitchValue(kLogFileSwitch)); | 722 log_file_path = |
| 723 FilePath::FromWStringHack(parsed_command_line.GetSwitchValue(kLogFileSwi
tch)); |
| 724 } |
| 692 | 725 |
| 693 if (parsed_command_line.HasSwitch(kTimeoutSwitch)) { | 726 if (parsed_command_line.HasSwitch(kTimeoutSwitch)) { |
| 694 timeout_ms = | 727 ASSERT_TRUE( |
| 695 _wtoi(parsed_command_line.GetSwitchValue(kTimeoutSwitch).c_str()); | 728 StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( |
| 729 kTimeoutSwitch)), &timeout_ms)); |
| 696 ASSERT_TRUE(timeout_ms > 0); | 730 ASSERT_TRUE(timeout_ms > 0); |
| 697 } | 731 } |
| 698 | 732 |
| 699 if (parsed_command_line.HasSwitch(kNoPageDownSwitch)) | 733 if (parsed_command_line.HasSwitch(kNoPageDownSwitch)) |
| 700 page_down = false; | 734 page_down = false; |
| 701 | 735 |
| 702 if (parsed_command_line.HasSwitch(kSaveDebugLogSwitch)) { | 736 if (parsed_command_line.HasSwitch(kSaveDebugLogSwitch)) { |
| 703 save_debug_log = true; | 737 save_debug_log = true; |
| 704 chrome_log_path = logging::GetLogFileName(); | 738 chrome_log_path = logging::GetLogFileName(); |
| 705 // We won't get v8 log unless --no-sandbox is specified. | 739 // We won't get v8 log unless --no-sandbox is specified. |
| 706 if (parsed_command_line.HasSwitch(switches::kNoSandbox)) { | 740 if (parsed_command_line.HasSwitch(switches::kNoSandbox)) { |
| 707 PathService::Get(base::DIR_CURRENT, &v8_log_path); | 741 PathService::Get(base::DIR_CURRENT, &v8_log_path); |
| 708 file_util::AppendToPath(&v8_log_path, kV8LogFileDefaultName); | 742 v8_log_path = v8_log_path.AppendASCII(kV8LogFileDefaultName); |
| 709 // The command line switch may override the default v8 log path. | 743 // The command line switch may override the default v8 log path. |
| 710 if (parsed_command_line.HasSwitch(switches::kJavaScriptFlags)) { | 744 if (parsed_command_line.HasSwitch(switches::kJavaScriptFlags)) { |
| 711 CommandLine v8_command_line( | 745 CommandLine v8_command_line( |
| 712 parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags)); | 746 parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags)); |
| 713 if (v8_command_line.HasSwitch(kV8LogFileSwitch)) { | 747 if (v8_command_line.HasSwitch(kV8LogFileSwitch)) { |
| 714 v8_log_path = v8_command_line.GetSwitchValue(kV8LogFileSwitch); | 748 v8_log_path = FilePath::FromWStringHack( |
| 749 v8_command_line.GetSwitchValue(kV8LogFileSwitch)); |
| 715 if (!file_util::AbsolutePath(&v8_log_path)) { | 750 if (!file_util::AbsolutePath(&v8_log_path)) { |
| 716 v8_log_path.clear(); | 751 v8_log_path = FilePath(); |
| 717 } | 752 } |
| 718 } | 753 } |
| 719 } | 754 } |
| 720 } | 755 } |
| 721 } | 756 } |
| 722 } | 757 } |
| OLD | NEW |