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

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

Issue 3057033: Remove GetSwitchValue() from chrome/* where easy. (Closed)
Patch Set: finally Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 7 #include <string>
8 8
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 UITest::set_safe_plugins( 42 UITest::set_safe_plugins(
43 parsed_command_line.HasSwitch(switches::kSafePlugins)); 43 parsed_command_line.HasSwitch(switches::kSafePlugins));
44 UITest::set_dump_histograms_on_exit( 44 UITest::set_dump_histograms_on_exit(
45 parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit)); 45 parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit));
46 UITest::set_enable_dcheck( 46 UITest::set_enable_dcheck(
47 parsed_command_line.HasSwitch(switches::kEnableDCHECK)); 47 parsed_command_line.HasSwitch(switches::kEnableDCHECK));
48 UITest::set_silent_dump_on_dcheck( 48 UITest::set_silent_dump_on_dcheck(
49 parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK)); 49 parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK));
50 UITest::set_disable_breakpad( 50 UITest::set_disable_breakpad(
51 parsed_command_line.HasSwitch(switches::kDisableBreakpad)); 51 parsed_command_line.HasSwitch(switches::kDisableBreakpad));
52 std::wstring test_timeout = 52 std::string test_timeout =
53 parsed_command_line.GetSwitchValue(UITestSuite::kTestTimeout); 53 parsed_command_line.GetSwitchValueASCII(UITestSuite::kTestTimeout);
54 if (!test_timeout.empty()) { 54 if (!test_timeout.empty()) {
55 int timeout; 55 int timeout;
56 base::StringToInt(WideToUTF8(test_timeout), &timeout); 56 base::StringToInt(test_timeout, &timeout);
57 UITest::set_test_timeout_ms(timeout); 57 UITest::set_test_timeout_ms(timeout);
58 } 58 }
59 59
60 #if defined(OS_WIN) 60 #if defined(OS_WIN)
61 int batch_count = 0; 61 int batch_count = 0;
62 int batch_index = 0; 62 int batch_index = 0;
63 std::wstring batch_count_str = 63 std::string batch_count_str =
64 parsed_command_line.GetSwitchValue(UITestSuite::kBatchCount); 64 parsed_command_line.GetSwitchValueASCII(UITestSuite::kBatchCount);
65 if (!batch_count_str.empty()) { 65 if (!batch_count_str.empty()) {
66 base::StringToInt(WideToUTF16Hack(batch_count_str), &batch_count); 66 base::StringToInt(batch_count_str, &batch_count);
67 } 67 }
68 std::wstring batch_index_str = 68 std::string batch_index_str =
69 parsed_command_line.GetSwitchValue(UITestSuite::kBatchIndex); 69 parsed_command_line.GetSwitchValueASCII(UITestSuite::kBatchIndex);
70 if (!batch_index_str.empty()) { 70 if (!batch_index_str.empty()) {
71 base::StringToInt(WideToUTF16Hack(batch_index_str), &batch_index); 71 base::StringToInt(batch_index_str, &batch_index);
72 } 72 }
73 if (batch_count > 0 && batch_index >= 0 && batch_index < batch_count) { 73 if (batch_count > 0 && batch_index >= 0 && batch_index < batch_count) {
74 // Running UI test in parallel. Gtest supports running tests in shards, 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. 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. 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. 77 // See http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.
78 std::string batch_count_env(UITestSuite::kGTestTotalShards); 78 std::string batch_count_env(UITestSuite::kGTestTotalShards);
79 batch_count_env.append(WideToASCII(batch_count_str)); 79 batch_count_env.append(batch_count_str);
80 std::string batch_index_env(UITestSuite::kGTestShardIndex); 80 std::string batch_index_env(UITestSuite::kGTestShardIndex);
81 batch_index_env.append(WideToASCII(batch_index_str)); 81 batch_index_env.append(batch_index_str);
82 _putenv(batch_count_env.c_str()); 82 _putenv(batch_count_env.c_str());
83 _putenv(batch_index_env.c_str()); 83 _putenv(batch_index_env.c_str());
84 } 84 }
85 #endif 85 #endif
86 86
87 std::string js_flags = 87 std::string js_flags =
88 parsed_command_line.GetSwitchValueASCII(switches::kJavaScriptFlags); 88 parsed_command_line.GetSwitchValueASCII(switches::kJavaScriptFlags);
89 if (!js_flags.empty()) 89 if (!js_flags.empty())
90 UITest::set_js_flags(js_flags); 90 UITest::set_js_flags(js_flags);
91 std::string log_level = 91 std::string log_level =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (!base::LaunchApp(crash_service.ToWStringHack(), false, false, 131 if (!base::LaunchApp(crash_service.ToWStringHack(), false, false,
132 &crash_service_)) { 132 &crash_service_)) {
133 printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \ 133 printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \
134 "you if any test crashes!\n"); 134 "you if any test crashes!\n");
135 return; 135 return;
136 } 136 }
137 137
138 printf("Started crash_service.exe so you know if a test crashes!\n"); 138 printf("Started crash_service.exe so you know if a test crashes!\n");
139 } 139 }
140 #endif 140 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698