| 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 #include "build/build_config.h" |
| 7 | 7 |
| 8 #include <stdlib.h> // required by _set_abort_behavior | 8 #include <stdlib.h> // required by _set_abort_behavior |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
| 26 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 27 #include "base/file_util.h" | 27 #include "base/file_util.h" |
| 28 #include "base/icu_util.h" | 28 #include "base/icu_util.h" |
| 29 #include "base/memory_debug.h" | 29 #include "base/memory_debug.h" |
| 30 #include "base/message_loop.h" | 30 #include "base/message_loop.h" |
| 31 #include "base/path_service.h" | 31 #include "base/path_service.h" |
| 32 #include "base/process_util.h" | 32 #include "base/process_util.h" |
| 33 #include "base/rand_util.h" | 33 #include "base/rand_util.h" |
| 34 #include "base/stats_table.h" | 34 #include "base/stats_table.h" |
| 35 #include "base/string_piece.h" | |
| 36 #include "base/string_util.h" | 35 #include "base/string_util.h" |
| 37 #include "base/sys_info.h" | 36 #include "base/sys_info.h" |
| 38 #include "base/trace_event.h" | 37 #include "base/trace_event.h" |
| 39 #include "net/base/cookie_monster.h" | 38 #include "net/base/cookie_monster.h" |
| 40 #include "net/base/net_module.h" | 39 #include "net/base/net_module.h" |
| 41 #include "net/http/http_cache.h" | 40 #include "net/http/http_cache.h" |
| 42 #include "net/url_request/url_request_context.h" | 41 #include "net/url_request/url_request_context.h" |
| 43 #include "webkit/glue/webkit_glue.h" | 42 #include "webkit/glue/webkit_glue.h" |
| 44 #include "webkit/glue/window_open_disposition.h" | 43 #include "webkit/glue/window_open_disposition.h" |
| 45 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 44 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 46 #include "webkit/tools/test_shell/test_shell.h" | 45 #include "webkit/tools/test_shell/test_shell.h" |
| 47 #include "webkit/tools/test_shell/test_shell_request_context.h" | 46 #include "webkit/tools/test_shell/test_shell_request_context.h" |
| 48 #include "webkit/tools/test_shell/test_shell_switches.h" | 47 #include "webkit/tools/test_shell/test_shell_switches.h" |
| 49 | 48 |
| 50 #include <iostream> | 49 #include <iostream> |
| 51 using namespace std; | 50 using namespace std; |
| 52 | 51 |
| 53 static const size_t kPathBufSize = 2048; | 52 static const size_t kPathBufSize = 2048; |
| 54 | 53 |
| 55 namespace { | 54 namespace { |
| 56 | 55 |
| 57 // StatsTable initialization parameters. | 56 // StatsTable initialization parameters. |
| 58 static const char* kStatsFilePrefix = "testshell_"; | 57 static const char* kStatsFilePrefix = "testshell_"; |
| 59 static int kStatsFileThreads = 20; | 58 static int kStatsFileThreads = 20; |
| 60 static int kStatsFileCounters = 200; | 59 static int kStatsFileCounters = 200; |
| 61 | 60 |
| 62 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 63 StringPiece GetRawDataResource(HMODULE module, int resource_id) { | |
| 64 void* data_ptr; | |
| 65 size_t data_size; | |
| 66 return base::GetDataResourceFromModule(module, resource_id, &data_ptr, | |
| 67 &data_size) ? | |
| 68 StringPiece(static_cast<char*>(data_ptr), data_size) : StringPiece(); | |
| 69 } | |
| 70 | |
| 71 // This is called indirectly by the network layer to access resources. | |
| 72 StringPiece NetResourceProvider(int key) { | |
| 73 return GetRawDataResource(::GetModuleHandle(NULL), key); | |
| 74 } | |
| 75 | |
| 76 // This test approximates whether you have the Windows XP theme selected by | 62 // This test approximates whether you have the Windows XP theme selected by |
| 77 // inspecting a couple of metrics. It does not catch all cases, but it does | 63 // inspecting a couple of metrics. It does not catch all cases, but it does |
| 78 // pick up on classic vs xp, and normal vs large fonts. Something it misses | 64 // pick up on classic vs xp, and normal vs large fonts. Something it misses |
| 79 // is changes to the color scheme (which will infact cause pixel test | 65 // is changes to the color scheme (which will infact cause pixel test |
| 80 // failures). | 66 // failures). |
| 81 // | 67 // |
| 82 // ** Expected dependencies ** | 68 // ** Expected dependencies ** |
| 83 // + Theme: Windows XP | 69 // + Theme: Windows XP |
| 84 // + Color scheme: Default (blue) | 70 // + Color scheme: Default (blue) |
| 85 // + Font size: Normal | 71 // + Font size: Normal |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 203 } |
| 218 | 204 |
| 219 // Initializing with a default context, which means no on-disk cookie DB, | 205 // Initializing with a default context, which means no on-disk cookie DB, |
| 220 // and no support for directory listings. | 206 // and no support for directory listings. |
| 221 SimpleResourceLoaderBridge::Init( | 207 SimpleResourceLoaderBridge::Init( |
| 222 new TestShellRequestContext(cache_path, cache_mode, layout_test_mode)); | 208 new TestShellRequestContext(cache_path, cache_mode, layout_test_mode)); |
| 223 | 209 |
| 224 // Load ICU data tables | 210 // Load ICU data tables |
| 225 icu_util::Initialize(); | 211 icu_util::Initialize(); |
| 226 | 212 |
| 213 // Config the network module so it has access to a limited set of resources. |
| 214 net::NetModule::SetResourceProvider(TestShell::NetResourceProvider); |
| 215 |
| 227 #if defined(OS_WIN) | 216 #if defined(OS_WIN) |
| 228 // Config the network module so it has access to a limited set of resources. | |
| 229 net::NetModule::SetResourceProvider(NetResourceProvider); | |
| 230 | |
| 231 INITCOMMONCONTROLSEX InitCtrlEx; | 217 INITCOMMONCONTROLSEX InitCtrlEx; |
| 232 | 218 |
| 233 InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); | 219 InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); |
| 234 InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; | 220 InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; |
| 235 InitCommonControlsEx(&InitCtrlEx); | 221 InitCommonControlsEx(&InitCtrlEx); |
| 236 #endif | 222 #endif |
| 237 | 223 |
| 238 TestShell::InitializeTestShell(layout_test_mode); | 224 TestShell::InitializeTestShell(layout_test_mode); |
| 239 | 225 |
| 240 if (parsed_command_line.HasSwitch(test_shell::kAllowScriptsToCloseWindows)) | 226 if (parsed_command_line.HasSwitch(test_shell::kAllowScriptsToCloseWindows)) |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 389 |
| 404 // Tear down shared StatsTable; prevents unit_tests from leaking it. | 390 // Tear down shared StatsTable; prevents unit_tests from leaking it. |
| 405 StatsTable::set_current(NULL); | 391 StatsTable::set_current(NULL); |
| 406 delete table; | 392 delete table; |
| 407 | 393 |
| 408 #ifdef _CRTDBG_MAP_ALLOC | 394 #ifdef _CRTDBG_MAP_ALLOC |
| 409 _CrtDumpMemoryLeaks(); | 395 _CrtDumpMemoryLeaks(); |
| 410 #endif | 396 #endif |
| 411 return 0; | 397 return 0; |
| 412 } | 398 } |
| OLD | NEW |