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

Side by Side Diff: chrome/test/ui/ui_test_suite.cc

Issue 149445: Adding command line switch to run UI test in parallel. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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/ui/ui_test_suite.h ('k') | no next file » | 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 "chrome/test/ui/ui_test_suite.h" 5 #include "chrome/test/ui/ui_test_suite.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "chrome/common/env_vars.h" 10 #include "chrome/common/env_vars.h"
11 11
12 // Force a test to use an already running browser instance. UI tests only. 12 // Force a test to use an already running browser instance. UI tests only.
13 const wchar_t UITestSuite::kUseExistingBrowser[] = L"use-existing-browser"; 13 const wchar_t UITestSuite::kUseExistingBrowser[] = L"use-existing-browser";
14 14
15 // Timeout for the test in milliseconds. UI tests only. 15 // Timeout for the test in milliseconds. UI tests only.
16 const wchar_t UITestSuite::kTestTimeout[] = L"test-timeout"; 16 const wchar_t UITestSuite::kTestTimeout[] = L"test-timeout";
17 17
18 // Parameters to run test in parallel. UI tests only.
19 const wchar_t UITestSuite::kBatchCount[] = L"batch-count";
20 const wchar_t UITestSuite::kBatchIndex[] = L"batch-index";
21 const char UITestSuite::kGTestTotalShards[] = "GTEST_TOTAL_SHARDS=";
22 const char UITestSuite::kGTestShardIndex[] = "GTEST_SHARD_INDEX=";
23
18 24
19 UITestSuite::UITestSuite(int argc, char** argv) 25 UITestSuite::UITestSuite(int argc, char** argv)
20 : ChromeTestSuite(argc, argv) { 26 : ChromeTestSuite(argc, argv) {
21 #if defined(OS_WIN) 27 #if defined(OS_WIN)
22 crash_service_ = NULL; 28 crash_service_ = NULL;
23 #endif 29 #endif
24 } 30 }
25 31
26 void UITestSuite::Initialize() { 32 void UITestSuite::Initialize() {
27 ChromeTestSuite::Initialize(); 33 ChromeTestSuite::Initialize();
(...skipping 15 matching lines...) Expand all
43 parsed_command_line.HasSwitch(switches::kEnableDCHECK)); 49 parsed_command_line.HasSwitch(switches::kEnableDCHECK));
44 UITest::set_silent_dump_on_dcheck( 50 UITest::set_silent_dump_on_dcheck(
45 parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK)); 51 parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK));
46 UITest::set_disable_breakpad( 52 UITest::set_disable_breakpad(
47 parsed_command_line.HasSwitch(switches::kDisableBreakpad)); 53 parsed_command_line.HasSwitch(switches::kDisableBreakpad));
48 std::wstring test_timeout = 54 std::wstring test_timeout =
49 parsed_command_line.GetSwitchValue(UITestSuite::kTestTimeout); 55 parsed_command_line.GetSwitchValue(UITestSuite::kTestTimeout);
50 if (!test_timeout.empty()) { 56 if (!test_timeout.empty()) {
51 UITest::set_test_timeout_ms(StringToInt(WideToUTF16Hack(test_timeout))); 57 UITest::set_test_timeout_ms(StringToInt(WideToUTF16Hack(test_timeout)));
52 } 58 }
59
60 #if defined(OS_WIN)
61 int batch_count = 0;
62 int batch_index = 0;
63 std::wstring batch_count_str =
64 parsed_command_line.GetSwitchValue(UITestSuite::kBatchCount);
65 if (!batch_count_str.empty()) {
66 batch_count = StringToInt(WideToUTF16Hack(batch_count_str));
67 }
68 std::wstring batch_index_str =
69 parsed_command_line.GetSwitchValue(UITestSuite::kBatchIndex);
70 if (!batch_index_str.empty()) {
71 batch_index = StringToInt(WideToUTF16Hack(batch_index_str));
72 }
73 if (batch_count > 0 && batch_index >= 0 && batch_index < batch_count) {
74 // Running UI test in parallel. Gtest supports running tests in shards,
75 // and every UI test instance is running with different user data dir.
76 // Thus all we need to do is to set up environment variables for gtest.
77 // See http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.
78 std::string batch_count_env(UITestSuite::kGTestTotalShards);
79 batch_count_env.append(WideToASCII(batch_count_str));
80 std::string batch_index_env(UITestSuite::kGTestShardIndex);
81 batch_index_env.append(WideToASCII(batch_index_str));
82 _putenv(batch_count_env.c_str());
83 _putenv(batch_index_env.c_str());
84 }
85 #endif
86
53 std::wstring js_flags = 87 std::wstring js_flags =
54 parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags); 88 parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags);
55 if (!js_flags.empty()) { 89 if (!js_flags.empty()) {
56 UITest::set_js_flags(js_flags); 90 UITest::set_js_flags(js_flags);
57 } 91 }
58 std::wstring log_level = 92 std::wstring log_level =
59 parsed_command_line.GetSwitchValue(switches::kLoggingLevel); 93 parsed_command_line.GetSwitchValue(switches::kLoggingLevel);
60 if (!log_level.empty()) { 94 if (!log_level.empty()) {
61 UITest::set_log_level(log_level); 95 UITest::set_log_level(log_level);
62 } 96 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (!base::LaunchApp(crash_service.ToWStringHack(), false, false, 134 if (!base::LaunchApp(crash_service.ToWStringHack(), false, false,
101 &crash_service_)) { 135 &crash_service_)) {
102 printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \ 136 printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \
103 "you if any test crashes!\n"); 137 "you if any test crashes!\n");
104 return; 138 return;
105 } 139 }
106 140
107 printf("Started crash_service.exe so you know if a test crashes!\n"); 141 printf("Started crash_service.exe so you know if a test crashes!\n");
108 } 142 }
109 #endif 143 #endif
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test_suite.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698