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

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

Issue 5967003: Refactor UITestBase/ProxyLauncher. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add POD struct to hold some launcher variables. Created 9 years, 11 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
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 13 matching lines...) Expand all
24 : ChromeTestSuite(argc, argv) { 24 : ChromeTestSuite(argc, argv) {
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 crash_service_ = NULL; 26 crash_service_ = NULL;
27 #endif 27 #endif
28 } 28 }
29 29
30 void UITestSuite::Initialize() { 30 void UITestSuite::Initialize() {
31 ChromeTestSuite::Initialize(); 31 ChromeTestSuite::Initialize();
32 32
33 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 33 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
34 UITest::set_in_process_renderer( 34 ProxyLauncher::set_in_process_renderer(
35 parsed_command_line.HasSwitch(switches::kSingleProcess)); 35 parsed_command_line.HasSwitch(switches::kSingleProcess));
36 UITest::set_no_sandbox( 36 ProxyLauncher::set_no_sandbox(
37 parsed_command_line.HasSwitch(switches::kNoSandbox)); 37 parsed_command_line.HasSwitch(switches::kNoSandbox));
38 UITest::set_full_memory_dump( 38 ProxyLauncher::set_full_memory_dump(
39 parsed_command_line.HasSwitch(switches::kFullMemoryCrashReport)); 39 parsed_command_line.HasSwitch(switches::kFullMemoryCrashReport));
40 UITest::set_safe_plugins( 40 ProxyLauncher::set_safe_plugins(
41 parsed_command_line.HasSwitch(switches::kSafePlugins)); 41 parsed_command_line.HasSwitch(switches::kSafePlugins));
42 UITest::set_dump_histograms_on_exit( 42 ProxyLauncher::set_dump_histograms_on_exit(
43 parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit)); 43 parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit));
44 UITest::set_enable_dcheck( 44 ProxyLauncher::set_enable_dcheck(
45 parsed_command_line.HasSwitch(switches::kEnableDCHECK)); 45 parsed_command_line.HasSwitch(switches::kEnableDCHECK));
46 UITest::set_silent_dump_on_dcheck( 46 ProxyLauncher::set_silent_dump_on_dcheck(
47 parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK)); 47 parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK));
48 UITest::set_disable_breakpad( 48 ProxyLauncher::set_disable_breakpad(
49 parsed_command_line.HasSwitch(switches::kDisableBreakpad)); 49 parsed_command_line.HasSwitch(switches::kDisableBreakpad));
50 50
51 #if defined(OS_WIN) 51 #if defined(OS_WIN)
52 int batch_count = 0; 52 int batch_count = 0;
53 int batch_index = 0; 53 int batch_index = 0;
54 std::string batch_count_str = 54 std::string batch_count_str =
55 parsed_command_line.GetSwitchValueASCII(UITestSuite::kBatchCount); 55 parsed_command_line.GetSwitchValueASCII(UITestSuite::kBatchCount);
56 if (!batch_count_str.empty()) { 56 if (!batch_count_str.empty()) {
57 base::StringToInt(batch_count_str, &batch_count); 57 base::StringToInt(batch_count_str, &batch_count);
58 } 58 }
(...skipping 12 matching lines...) Expand all
71 std::string batch_index_env(UITestSuite::kGTestShardIndex); 71 std::string batch_index_env(UITestSuite::kGTestShardIndex);
72 batch_index_env.append(batch_index_str); 72 batch_index_env.append(batch_index_str);
73 _putenv(batch_count_env.c_str()); 73 _putenv(batch_count_env.c_str());
74 _putenv(batch_index_env.c_str()); 74 _putenv(batch_index_env.c_str());
75 } 75 }
76 #endif 76 #endif
77 77
78 std::string js_flags = 78 std::string js_flags =
79 parsed_command_line.GetSwitchValueASCII(switches::kJavaScriptFlags); 79 parsed_command_line.GetSwitchValueASCII(switches::kJavaScriptFlags);
80 if (!js_flags.empty()) 80 if (!js_flags.empty())
81 UITest::set_js_flags(js_flags); 81 ProxyLauncher::set_js_flags(js_flags);
82 std::string log_level = 82 std::string log_level =
83 parsed_command_line.GetSwitchValueASCII(switches::kLoggingLevel); 83 parsed_command_line.GetSwitchValueASCII(switches::kLoggingLevel);
84 if (!log_level.empty()) 84 if (!log_level.empty())
85 UITest::set_log_level(log_level); 85 ProxyLauncher::set_log_level(log_level);
86 86
87 #if defined(OS_WIN) 87 #if defined(OS_WIN)
88 LoadCrashService(); 88 LoadCrashService();
89 #endif 89 #endif
90 } 90 }
91 91
92 void UITestSuite::Shutdown() { 92 void UITestSuite::Shutdown() {
93 #if defined(OS_WIN) 93 #if defined(OS_WIN)
94 if (crash_service_) 94 if (crash_service_)
95 base::KillProcess(crash_service_, 0, false); 95 base::KillProcess(crash_service_, 0, false);
96 #endif 96 #endif
97 97
98 ChromeTestSuite::Shutdown(); 98 ChromeTestSuite::Shutdown();
99 } 99 }
100 100
101 void UITestSuite::SuppressErrorDialogs() { 101 void UITestSuite::SuppressErrorDialogs() {
102 TestSuite::SuppressErrorDialogs(); 102 TestSuite::SuppressErrorDialogs();
103 UITest::set_show_error_dialogs(false); 103 ProxyLauncher::set_show_error_dialogs(false);
104 } 104 }
105 105
106 #if defined(OS_WIN) 106 #if defined(OS_WIN)
107 void UITestSuite::LoadCrashService() { 107 void UITestSuite::LoadCrashService() {
108 scoped_ptr<base::Environment> env(base::Environment::Create()); 108 scoped_ptr<base::Environment> env(base::Environment::Create());
109 if (env->HasVar(env_vars::kHeadless)) 109 if (env->HasVar(env_vars::kHeadless))
110 return; 110 return;
111 111
112 if (base::GetProcessCount(L"crash_service.exe", NULL)) 112 if (base::GetProcessCount(L"crash_service.exe", NULL))
113 return; 113 return;
114 114
115 FilePath exe_dir; 115 FilePath exe_dir;
116 if (!PathService::Get(base::DIR_EXE, &exe_dir)) { 116 if (!PathService::Get(base::DIR_EXE, &exe_dir)) {
117 DCHECK(false); 117 DCHECK(false);
118 return; 118 return;
119 } 119 }
120 120
121 FilePath crash_service = exe_dir.Append(L"crash_service.exe"); 121 FilePath crash_service = exe_dir.Append(L"crash_service.exe");
122 if (!base::LaunchApp(crash_service.ToWStringHack(), false, false, 122 if (!base::LaunchApp(crash_service.ToWStringHack(), false, false,
123 &crash_service_)) { 123 &crash_service_)) {
124 printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \ 124 printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \
125 "you if any test crashes!\n"); 125 "you if any test crashes!\n");
126 return; 126 return;
127 } 127 }
128 128
129 printf("Started crash_service.exe so you know if a test crashes!\n"); 129 printf("Started crash_service.exe so you know if a test crashes!\n");
130 } 130 }
131 #endif 131 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698