Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // Creates an instance of the test_shell. | 5 // Creates an instance of the test_shell. |
| 6 #include "build/build_config.h" | |
| 6 | 7 |
| 7 #include <stdlib.h> // required by _set_abort_behavior | 8 #include <stdlib.h> // required by _set_abort_behavior |
| 8 | 9 |
| 10 #if defined(OS_WIN) | |
| 9 #include <windows.h> | 11 #include <windows.h> |
| 10 #include <commctrl.h> | 12 #include <commctrl.h> |
| 13 #include "base/event_recorder.h" | |
| 14 #include "base/gfx/native_theme.h" | |
| 15 #include "base/resource_util.h" | |
| 16 #include "breakpad/src/client/windows/handler/exception_handler.h" | |
| 17 #include "webkit/tools/test_shell/foreground_helper.h" | |
| 18 #endif | |
| 19 | |
| 20 #if defined(OS_LINUX) | |
| 21 #include <gtk/gtk.h> | |
| 22 #endif | |
| 11 | 23 |
| 12 #include "base/at_exit.h" | 24 #include "base/at_exit.h" |
| 13 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 15 #include "base/event_recorder.h" | |
| 16 #include "base/file_util.h" | 27 #include "base/file_util.h" |
| 17 #include "base/gfx/native_theme.h" | |
| 18 #include "base/icu_util.h" | 28 #include "base/icu_util.h" |
| 19 #include "base/memory_debug.h" | 29 #include "base/memory_debug.h" |
| 20 #include "base/message_loop.h" | 30 #include "base/message_loop.h" |
| 21 #include "base/path_service.h" | 31 #include "base/path_service.h" |
| 22 #include "base/process_util.h" | 32 #include "base/process_util.h" |
| 23 #include "base/resource_util.h" | |
| 24 #include "base/stack_container.h" | 33 #include "base/stack_container.h" |
| 25 #include "base/stats_table.h" | 34 #include "base/stats_table.h" |
| 26 #include "base/string_util.h" | 35 #include "base/string_util.h" |
| 27 #include "base/trace_event.h" | 36 #include "base/trace_event.h" |
| 28 #include "breakpad/src/client/windows/handler/exception_handler.h" | |
| 29 #include "net/base/cookie_monster.h" | 37 #include "net/base/cookie_monster.h" |
| 30 #include "net/base/net_module.h" | 38 #include "net/base/net_module.h" |
| 31 #include "net/http/http_cache.h" | 39 #include "net/http/http_cache.h" |
| 32 #include "net/http/http_network_layer.h" | 40 #include "net/http/http_network_layer.h" |
| 33 #include "net/url_request/url_request_context.h" | 41 #include "net/url_request/url_request_context.h" |
| 34 #include "webkit/glue/webkit_glue.h" | 42 #include "webkit/glue/webkit_glue.h" |
| 35 #include "webkit/glue/window_open_disposition.h" | 43 #include "webkit/glue/window_open_disposition.h" |
| 36 #include "webkit/tools/test_shell/foreground_helper.h" | |
| 37 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 44 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 38 #include "webkit/tools/test_shell/test_shell.h" | 45 #include "webkit/tools/test_shell/test_shell.h" |
| 39 #include "webkit/tools/test_shell/test_shell_request_context.h" | 46 #include "webkit/tools/test_shell/test_shell_request_context.h" |
| 40 #include "webkit/tools/test_shell/test_shell_switches.h" | 47 #include "webkit/tools/test_shell/test_shell_switches.h" |
| 41 | 48 |
| 49 #include <iostream> | |
| 50 using namespace std; | |
| 51 | |
| 52 #if defined(OS_WIN) | |
| 42 // This is only set for layout tests. | 53 // This is only set for layout tests. |
| 43 static wchar_t g_currentTestName[MAX_PATH]; | 54 static wchar_t g_currentTestName[MAX_PATH]; |
| 55 #endif | |
| 44 | 56 |
| 45 namespace { | 57 namespace { |
| 46 | 58 |
| 47 // StatsTable initialization parameters. | 59 // StatsTable initialization parameters. |
| 48 static wchar_t* kStatsFile = L"testshell"; | 60 static const wchar_t* kStatsFile = L"testshell"; |
| 49 static int kStatsFileThreads = 20; | 61 static int kStatsFileThreads = 20; |
| 50 static int kStatsFileCounters = 200; | 62 static int kStatsFileCounters = 200; |
| 51 | 63 |
| 64 #if defined(OS_WIN) | |
| 52 std::string GetDataResource(HMODULE module, int resource_id) { | 65 std::string GetDataResource(HMODULE module, int resource_id) { |
| 53 void* data_ptr; | 66 void* data_ptr; |
| 54 size_t data_size; | 67 size_t data_size; |
| 55 return base::GetDataResourceFromModule(module, resource_id, &data_ptr, | 68 return base::GetDataResourceFromModule(module, resource_id, &data_ptr, |
| 56 &data_size) ? | 69 &data_size) ? |
| 57 std::string(static_cast<char*>(data_ptr), data_size) : std::string(); | 70 std::string(static_cast<char*>(data_ptr), data_size) : std::string(); |
| 58 } | 71 } |
| 59 | 72 |
| 60 // This is called indirectly by the network layer to access resources. | 73 // This is called indirectly by the network layer to access resources. |
| 61 std::string NetResourceProvider(int key) { | 74 std::string NetResourceProvider(int key) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 newPath->append(L"-"); | 116 newPath->append(L"-"); |
| 104 newPath->append(minidumpID); | 117 newPath->append(minidumpID); |
| 105 newPath->append(L".dmp"); | 118 newPath->append(L".dmp"); |
| 106 | 119 |
| 107 // May use the heap, but oh well. If this fails, we'll just have the | 120 // May use the heap, but oh well. If this fails, we'll just have the |
| 108 // original dump file lying around. | 121 // original dump file lying around. |
| 109 _wrename(origPath->c_str(), newPath->c_str()); | 122 _wrename(origPath->c_str(), newPath->c_str()); |
| 110 | 123 |
| 111 return false; | 124 return false; |
| 112 } | 125 } |
| 126 #endif | |
| 127 | |
| 113 } // namespace | 128 } // namespace |
| 114 | 129 |
| 130 | |
| 115 int main(int argc, char* argv[]) { | 131 int main(int argc, char* argv[]) { |
| 116 process_util::EnableTerminationOnHeapCorruption(); | 132 process_util::EnableTerminationOnHeapCorruption(); |
| 117 #ifdef _CRTDBG_MAP_ALLOC | 133 #ifdef _CRTDBG_MAP_ALLOC |
| 118 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 134 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
| 119 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); | 135 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); |
| 120 #endif | 136 #endif |
| 121 // Some tests may use base::Singleton<>, thus we need to instanciate | 137 // Some tests may use base::Singleton<>, thus we need to instanciate |
| 122 // the AtExitManager or else we will leak objects. | 138 // the AtExitManager or else we will leak objects. |
| 123 base::AtExitManager at_exit_manager; | 139 base::AtExitManager at_exit_manager; |
| 124 | 140 |
| 141 #if defined(OS_LINUX) | |
| 142 gtk_init(&argc, &argv); | |
| 143 // Only parse the command line after GTK's had a crack at it. | |
| 144 CommandLine::SetArgcArgv(argc, argv); | |
| 145 #endif | |
| 146 | |
| 125 CommandLine parsed_command_line; | 147 CommandLine parsed_command_line; |
| 148 #if defined(OS_WIN) | |
| 126 if (parsed_command_line.HasSwitch(test_shell::kStartupDialog)) | 149 if (parsed_command_line.HasSwitch(test_shell::kStartupDialog)) |
| 127 MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK); | 150 MessageBox(NULL, L"attach to me?", L"test_shell", MB_OK); |
| 151 #endif | |
| 128 | 152 |
| 129 // Allocate a message loop for this thread. Although it is not used | 153 // Allocate a message loop for this thread. Although it is not used |
| 130 // directly, its constructor sets up some necessary state. | 154 // directly, its constructor sets up some necessary state. |
| 131 MessageLoopForUI main_message_loop; | 155 MessageLoopForUI main_message_loop; |
| 132 | 156 |
| 133 bool suppress_error_dialogs = | 157 bool suppress_error_dialogs = ( |
| 134 (GetEnvironmentVariable(L"CHROME_HEADLESS", NULL, 0) || | 158 #if defined(OS_WIN) |
| 159 GetEnvironmentVariable(L"CHROME_HEADLESS", NULL, 0) || | |
| 160 #endif | |
| 135 parsed_command_line.HasSwitch(test_shell::kNoErrorDialogs) || | 161 parsed_command_line.HasSwitch(test_shell::kNoErrorDialogs) || |
| 136 parsed_command_line.HasSwitch(test_shell::kLayoutTests)); | 162 parsed_command_line.HasSwitch(test_shell::kLayoutTests)); |
| 137 bool layout_test_mode = | 163 bool layout_test_mode = |
| 138 parsed_command_line.HasSwitch(test_shell::kLayoutTests); | 164 parsed_command_line.HasSwitch(test_shell::kLayoutTests); |
| 139 | 165 |
| 140 TestShell::InitLogging(suppress_error_dialogs, layout_test_mode); | 166 TestShell::InitLogging(suppress_error_dialogs, layout_test_mode); |
| 141 | 167 |
| 142 // Set this early before we start using WebCore. | 168 // Set this early before we start using WebCore. |
| 143 webkit_glue::SetLayoutTestMode(layout_test_mode); | 169 webkit_glue::SetLayoutTestMode(layout_test_mode); |
| 144 | 170 |
| 145 // Suppress abort message in v8 library in debugging mode. | 171 // Suppress abort message in v8 library in debugging mode. |
| 146 // V8 calls abort() when it hits assertion errors. | 172 // V8 calls abort() when it hits assertion errors. |
| 173 #if defined(OS_WIN) | |
| 147 if (suppress_error_dialogs) { | 174 if (suppress_error_dialogs) { |
| 148 _set_abort_behavior(0, _WRITE_ABORT_MSG); | 175 _set_abort_behavior(0, _WRITE_ABORT_MSG); |
| 149 } | 176 } |
| 177 #endif | |
| 150 | 178 |
| 151 if (parsed_command_line.HasSwitch(test_shell::kEnableTracing)) | 179 if (parsed_command_line.HasSwitch(test_shell::kEnableTracing)) |
| 152 base::TraceLog::StartTracing(); | 180 base::TraceLog::StartTracing(); |
| 153 | 181 |
| 154 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
| 155 // Make the selection of network stacks early on before any consumers try to | 183 // Make the selection of network stacks early on before any consumers try to |
| 156 // issue HTTP requests. | 184 // issue HTTP requests. |
| 157 if (parsed_command_line.HasSwitch(test_shell::kUseWinHttp)) | 185 if (parsed_command_line.HasSwitch(test_shell::kUseWinHttp)) |
| 158 net::HttpNetworkLayer::UseWinHttp(true); | 186 net::HttpNetworkLayer::UseWinHttp(true); |
| 159 #endif | 187 #endif |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 181 } | 209 } |
| 182 | 210 |
| 183 // Initializing with a default context, which means no on-disk cookie DB, | 211 // Initializing with a default context, which means no on-disk cookie DB, |
| 184 // and no support for directory listings. | 212 // and no support for directory listings. |
| 185 SimpleResourceLoaderBridge::Init( | 213 SimpleResourceLoaderBridge::Init( |
| 186 new TestShellRequestContext(cache_path, cache_mode)); | 214 new TestShellRequestContext(cache_path, cache_mode)); |
| 187 | 215 |
| 188 // Load ICU data tables | 216 // Load ICU data tables |
| 189 icu_util::Initialize(); | 217 icu_util::Initialize(); |
| 190 | 218 |
| 219 #if defined(OS_WIN) | |
| 191 // Config the network module so it has access to a limited set of resources. | 220 // Config the network module so it has access to a limited set of resources. |
| 192 net::NetModule::SetResourceProvider(NetResourceProvider); | 221 net::NetModule::SetResourceProvider(NetResourceProvider); |
| 193 | 222 |
| 194 INITCOMMONCONTROLSEX InitCtrlEx; | 223 INITCOMMONCONTROLSEX InitCtrlEx; |
| 195 | 224 |
| 196 InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); | 225 InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); |
| 197 InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; | 226 InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; |
| 198 InitCommonControlsEx(&InitCtrlEx); | 227 InitCommonControlsEx(&InitCtrlEx); |
| 199 | 228 |
| 200 // Register the Ahem font used by layout tests. | 229 // Register the Ahem font used by layout tests. |
| 201 DWORD num_fonts = 1; | 230 DWORD num_fonts = 1; |
| 202 void* font_ptr; | 231 void* font_ptr; |
| 203 size_t font_size; | 232 size_t font_size; |
| 204 if (base::GetDataResourceFromModule(::GetModuleHandle(NULL), IDR_AHEM_FONT, | 233 if (base::GetDataResourceFromModule(::GetModuleHandle(NULL), IDR_AHEM_FONT, |
| 205 &font_ptr, &font_size)) { | 234 &font_ptr, &font_size)) { |
| 206 HANDLE rc = AddFontMemResourceEx(font_ptr, font_size, 0, &num_fonts); | 235 HANDLE rc = AddFontMemResourceEx(font_ptr, font_size, 0, &num_fonts); |
| 207 DCHECK(rc != 0); | 236 DCHECK(rc != 0); |
| 208 } | 237 } |
| 238 #endif | |
| 209 | 239 |
| 210 bool interactive = !layout_test_mode; | 240 bool interactive = !layout_test_mode; |
| 211 TestShell::InitializeTestShell(interactive); | 241 TestShell::InitializeTestShell(interactive); |
| 212 | 242 |
| 213 if (parsed_command_line.HasSwitch(test_shell::kAllowScriptsToCloseWindows)) | 243 if (parsed_command_line.HasSwitch(test_shell::kAllowScriptsToCloseWindows)) |
| 214 TestShell::SetAllowScriptsToCloseWindows(); | 244 TestShell::SetAllowScriptsToCloseWindows(); |
| 215 | 245 |
| 216 // Disable user themes for layout tests so pixel tests are consistent. | 246 // Disable user themes for layout tests so pixel tests are consistent. |
| 247 #if defined(OS_WIN) | |
| 217 if (!interactive) | 248 if (!interactive) |
| 218 gfx::NativeTheme::instance()->DisableTheming(); | 249 gfx::NativeTheme::instance()->DisableTheming(); |
| 250 #endif | |
| 219 | 251 |
| 220 if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) { | 252 if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) { |
| 221 const std::wstring timeout_str = parsed_command_line.GetSwitchValue( | 253 const std::wstring timeout_str = parsed_command_line.GetSwitchValue( |
| 222 test_shell::kTestShellTimeOut); | 254 test_shell::kTestShellTimeOut); |
| 223 int timeout_ms = static_cast<int>(StringToInt64(timeout_str.c_str())); | 255 int timeout_ms = static_cast<int>(StringToInt64(timeout_str.c_str())); |
| 224 if (timeout_ms > 0) | 256 if (timeout_ms > 0) |
| 225 TestShell::SetFileTestTimeout(timeout_ms); | 257 TestShell::SetFileTestTimeout(timeout_ms); |
| 226 } | 258 } |
| 227 | 259 |
| 260 #if defined(OS_WIN) | |
| 228 // Initialize global strings | 261 // Initialize global strings |
| 229 TestShell::RegisterWindowClass(); | 262 TestShell::RegisterWindowClass(); |
| 263 #endif | |
| 230 | 264 |
| 231 // Treat the first loose value as the initial URL to open. | 265 // Treat the first loose value as the initial URL to open. |
| 232 std::wstring uri; | 266 std::wstring uri; |
| 233 | 267 |
| 234 // Default to a homepage if we're interactive. | 268 // Default to a homepage if we're interactive. |
| 235 if (interactive) { | 269 if (interactive) { |
| 236 PathService::Get(base::DIR_SOURCE_ROOT, &uri); | 270 PathService::Get(base::DIR_SOURCE_ROOT, &uri); |
| 237 file_util::AppendToPath(&uri, L"webkit"); | 271 file_util::AppendToPath(&uri, L"webkit"); |
| 238 file_util::AppendToPath(&uri, L"data"); | 272 file_util::AppendToPath(&uri, L"data"); |
| 239 file_util::AppendToPath(&uri, L"test_shell"); | 273 file_util::AppendToPath(&uri, L"test_shell"); |
| 240 file_util::AppendToPath(&uri, L"index.html"); | 274 file_util::AppendToPath(&uri, L"index.html"); |
| 241 } | 275 } |
| 242 | 276 |
| 243 if (parsed_command_line.GetLooseValueCount() > 0) { | 277 if (parsed_command_line.GetLooseValueCount() > 0) { |
| 244 CommandLine::LooseValueIterator iter( | 278 CommandLine::LooseValueIterator iter( |
| 245 parsed_command_line.GetLooseValuesBegin()); | 279 parsed_command_line.GetLooseValuesBegin()); |
| 246 uri = *iter; | 280 uri = *iter; |
| 247 } | 281 } |
| 248 | 282 |
| 283 #if defined(OS_WIN) | |
| 249 if (parsed_command_line.HasSwitch(test_shell::kCrashDumps)) { | 284 if (parsed_command_line.HasSwitch(test_shell::kCrashDumps)) { |
| 250 std::wstring dir( | 285 std::wstring dir( |
| 251 parsed_command_line.GetSwitchValue(test_shell::kCrashDumps)); | 286 parsed_command_line.GetSwitchValue(test_shell::kCrashDumps)); |
| 252 new google_breakpad::ExceptionHandler(dir, 0, &MinidumpCallback, 0, true); | 287 new google_breakpad::ExceptionHandler(dir, 0, &MinidumpCallback, 0, true); |
| 253 } | 288 } |
| 289 #endif | |
| 254 | 290 |
| 255 std::wstring js_flags = | 291 std::wstring js_flags = |
| 256 parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags); | 292 parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags); |
| 257 // Test shell always exposes the GC. | 293 // Test shell always exposes the GC. |
| 258 CommandLine::AppendSwitch(&js_flags, L"expose-gc"); | 294 CommandLine::AppendSwitch(&js_flags, L"expose-gc"); |
| 259 webkit_glue::SetJavaScriptFlags(js_flags); | 295 webkit_glue::SetJavaScriptFlags(js_flags); |
| 260 | 296 |
| 261 // load and initialize the stats table. | 297 // load and initialize the stats table. |
| 262 StatsTable *table = new StatsTable(kStatsFile, kStatsFileThreads, kStatsFileCo unters); | 298 StatsTable *table = new StatsTable(kStatsFile, kStatsFileThreads, kStatsFileCo unters); |
| 263 StatsTable::set_current(table); | 299 StatsTable::set_current(table); |
| 264 | 300 |
| 265 TestShell* shell; | 301 TestShell* shell; |
| 266 if (TestShell::CreateNewWindow(uri, &shell)) { | 302 if (TestShell::CreateNewWindow(uri, &shell)) { |
| 303 #if defined(OS_WIN) | |
| 267 if (record_mode || playback_mode) { | 304 if (record_mode || playback_mode) { |
| 268 // Move the window to the upper left corner for consistent | 305 // Move the window to the upper left corner for consistent |
| 269 // record/playback mode. For automation, we want this to work | 306 // record/playback mode. For automation, we want this to work |
| 270 // on build systems where the script invoking us is a background | 307 // on build systems where the script invoking us is a background |
| 271 // process. So for this case, make our window the topmost window | 308 // process. So for this case, make our window the topmost window |
| 272 // as well. | 309 // as well. |
| 273 ForegroundHelper::SetForeground(shell->mainWnd()); | 310 ForegroundHelper::SetForeground(shell->mainWnd()); |
| 274 ::SetWindowPos(shell->mainWnd(), HWND_TOP, 0, 0, 600, 800, 0); | 311 ::SetWindowPos(shell->mainWnd(), HWND_TOP, 0, 0, 600, 800, 0); |
| 275 // Tell webkit as well. | 312 // Tell webkit as well. |
| 276 webkit_glue::SetRecordPlaybackMode(true); | 313 webkit_glue::SetRecordPlaybackMode(true); |
| 277 } | 314 } |
| 315 #endif | |
| 278 | 316 |
| 279 shell->Show(shell->webView(), NEW_WINDOW); | 317 shell->Show(shell->webView(), NEW_WINDOW); |
| 280 | 318 |
| 281 if (parsed_command_line.HasSwitch(test_shell::kDumpStatsTable)) | 319 if (parsed_command_line.HasSwitch(test_shell::kDumpStatsTable)) |
| 282 shell->DumpStatsTableOnExit(); | 320 shell->DumpStatsTableOnExit(); |
| 283 | 321 |
| 322 #if defined(OS_WIN) | |
| 284 bool no_events = parsed_command_line.HasSwitch(test_shell::kNoEvents); | 323 bool no_events = parsed_command_line.HasSwitch(test_shell::kNoEvents); |
| 285 if ((record_mode || playback_mode) && !no_events) { | 324 if ((record_mode || playback_mode) && !no_events) { |
| 286 std::wstring script_path = cache_path; | 325 std::wstring script_path = cache_path; |
| 287 // Create the cache directory in case it doesn't exist. | 326 // Create the cache directory in case it doesn't exist. |
| 288 file_util::CreateDirectory(cache_path); | 327 file_util::CreateDirectory(cache_path); |
| 289 file_util::AppendToPath(&script_path, L"script.log"); | 328 file_util::AppendToPath(&script_path, L"script.log"); |
| 290 if (record_mode) | 329 if (record_mode) |
| 291 base::EventRecorder::current()->StartRecording(script_path); | 330 base::EventRecorder::current()->StartRecording(script_path); |
| 292 if (playback_mode) | 331 if (playback_mode) |
| 293 base::EventRecorder::current()->StartPlayback(script_path); | 332 base::EventRecorder::current()->StartPlayback(script_path); |
| 294 } | 333 } |
| 334 #endif | |
| 295 | 335 |
| 296 if (parsed_command_line.HasSwitch(test_shell::kDebugMemoryInUse)) { | 336 if (parsed_command_line.HasSwitch(test_shell::kDebugMemoryInUse)) { |
| 297 base::MemoryDebug::SetMemoryInUseEnabled(true); | 337 base::MemoryDebug::SetMemoryInUseEnabled(true); |
| 298 // Dump all in use memory at startup | 338 // Dump all in use memory at startup |
| 299 base::MemoryDebug::DumpAllMemoryInUse(); | 339 base::MemoryDebug::DumpAllMemoryInUse(); |
| 300 } | 340 } |
| 301 | 341 |
| 302 // See if we need to run the tests. | 342 // See if we need to run the tests. |
| 303 if (layout_test_mode) { | 343 if (layout_test_mode) { |
| 304 // Set up for the kind of test requested. | 344 // Set up for the kind of test requested. |
| 305 TestShell::TestParams params; | 345 TestShell::TestParams params; |
| 306 if (parsed_command_line.HasSwitch(test_shell::kDumpPixels)) { | 346 if (parsed_command_line.HasSwitch(test_shell::kDumpPixels)) { |
| 307 // The pixel test flag also gives the image file name to use. | 347 // The pixel test flag also gives the image file name to use. |
| 308 params.dump_pixels = true; | 348 params.dump_pixels = true; |
| 309 params.pixel_file_name = parsed_command_line.GetSwitchValue( | 349 params.pixel_file_name = parsed_command_line.GetSwitchValue( |
| 310 test_shell::kDumpPixels); | 350 test_shell::kDumpPixels); |
| 311 if (params.pixel_file_name.size() == 0) { | 351 if (params.pixel_file_name.size() == 0) { |
| 312 fprintf(stderr, "No file specified for pixel tests"); | 352 fprintf(stderr, "No file specified for pixel tests"); |
| 313 exit(1); | 353 exit(1); |
| 314 } | 354 } |
| 315 } | 355 } |
| 316 if (parsed_command_line.HasSwitch(test_shell::kNoTree)) { | 356 if (parsed_command_line.HasSwitch(test_shell::kNoTree)) { |
| 317 params.dump_tree = false; | 357 params.dump_tree = false; |
| 318 } | 358 } |
| 319 | 359 |
| 320 if (uri.length() == 0) { | 360 if (uri.length() == 0) { |
| 321 // Watch stdin for URLs. | 361 // Watch stdin for URLs. |
| 322 char filenameBuffer[2048]; | 362 char filenameBuffer[2048]; |
| 363 cerr << "Watching for urls!" << endl; | |
|
tony
2008/11/13 22:21:15
Nit: Can you remove this or turn it into DLOG(INFO
| |
| 323 while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) { | 364 while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) { |
| 324 char *newLine = strchr(filenameBuffer, '\n'); | 365 char *newLine = strchr(filenameBuffer, '\n'); |
| 325 if (newLine) | 366 if (newLine) |
| 326 *newLine = '\0'; | 367 *newLine = '\0'; |
| 368 cerr << "newLine: " << newLine << endl; | |
|
tony
2008/11/13 22:21:15
Same as above.
| |
| 369 | |
| 327 if (!*filenameBuffer) | 370 if (!*filenameBuffer) |
| 328 continue; | 371 continue; |
| 329 | 372 |
| 373 #if defined(OS_WIN) | |
| 330 SetCurrentTestName(filenameBuffer); | 374 SetCurrentTestName(filenameBuffer); |
| 375 #endif | |
| 331 | 376 |
| 332 if (!TestShell::RunFileTest(filenameBuffer, params)) | 377 if (!TestShell::RunFileTest(filenameBuffer, params)) |
| 333 break; | 378 break; |
| 334 } | 379 } |
| 335 } else { | 380 } else { |
| 336 TestShell::RunFileTest(WideToUTF8(uri).c_str(), params); | 381 TestShell::RunFileTest(WideToUTF8(uri).c_str(), params); |
| 337 } | 382 } |
| 338 | 383 |
| 339 shell->CallJSGC(); | 384 shell->CallJSGC(); |
| 340 shell->CallJSGC(); | 385 shell->CallJSGC(); |
| 341 if (shell) delete shell; | 386 if (shell) delete shell; |
| 342 } else { | 387 } else { |
| 343 MessageLoop::current()->Run(); | 388 MessageLoop::current()->Run(); |
| 344 } | 389 } |
| 345 | 390 |
| 346 // Flush any remaining messages. This ensures that any accumulated | 391 // Flush any remaining messages. This ensures that any accumulated |
| 347 // Task objects get destroyed before we exit, which avoids noise in | 392 // Task objects get destroyed before we exit, which avoids noise in |
| 348 // purify leak-test results. | 393 // purify leak-test results. |
| 349 MessageLoop::current()->RunAllPending(); | 394 MessageLoop::current()->RunAllPending(); |
| 350 | 395 |
| 396 #if defined(OS_WIN) | |
| 351 if (record_mode) | 397 if (record_mode) |
| 352 base::EventRecorder::current()->StopRecording(); | 398 base::EventRecorder::current()->StopRecording(); |
| 353 if (playback_mode) | 399 if (playback_mode) |
| 354 base::EventRecorder::current()->StopPlayback(); | 400 base::EventRecorder::current()->StopPlayback(); |
| 401 #endif | |
| 355 } | 402 } |
| 356 | 403 |
| 357 TestShell::ShutdownTestShell(); | 404 TestShell::ShutdownTestShell(); |
| 358 TestShell::CleanupLogging(); | 405 TestShell::CleanupLogging(); |
| 359 | 406 |
| 360 // Tear down shared StatsTable; prevents unit_tests from leaking it. | 407 // Tear down shared StatsTable; prevents unit_tests from leaking it. |
| 361 StatsTable::set_current(NULL); | 408 StatsTable::set_current(NULL); |
| 362 delete table; | 409 delete table; |
| 363 | 410 |
| 364 #ifdef _CRTDBG_MAP_ALLOC | 411 #ifdef _CRTDBG_MAP_ALLOC |
| 365 _CrtDumpMemoryLeaks(); | 412 _CrtDumpMemoryLeaks(); |
| 366 #endif | 413 #endif |
| 367 return 0; | 414 return 0; |
| 368 } | 415 } |
| OLD | NEW |