| 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/string_number_conversions.h" |
| 8 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 9 #include "net/http/http_cache.h" | 10 #include "net/http/http_cache.h" |
| 10 #include "net/url_request/url_request_context.h" | 11 #include "net/url_request/url_request_context.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webkit/glue/webkit_glue.h" | 13 #include "webkit/glue/webkit_glue.h" |
| 13 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 14 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 14 #include "webkit/tools/test_shell/test_shell.h" | 15 #include "webkit/tools/test_shell/test_shell.h" |
| 15 #include "webkit/tools/test_shell/test_shell_request_context.h" | 16 #include "webkit/tools/test_shell/test_shell_request_context.h" |
| 16 #include "webkit/tools/test_shell/test_shell_switches.h" | 17 #include "webkit/tools/test_shell/test_shell_switches.h" |
| 17 #include "webkit/tools/test_shell/test_shell_test.h" | 18 #include "webkit/tools/test_shell/test_shell_test.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 FilePath cache_path = | 36 FilePath cache_path = |
| 36 parsed_command_line.GetSwitchValuePath(test_shell::kCacheDir); | 37 parsed_command_line.GetSwitchValuePath(test_shell::kCacheDir); |
| 37 if (cache_path.empty()) { | 38 if (cache_path.empty()) { |
| 38 PathService::Get(base::DIR_EXE, &cache_path); | 39 PathService::Get(base::DIR_EXE, &cache_path); |
| 39 cache_path = cache_path.AppendASCII("cache"); | 40 cache_path = cache_path.AppendASCII("cache"); |
| 40 } | 41 } |
| 41 | 42 |
| 42 if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) { | 43 if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) { |
| 43 const std::wstring timeout_str = parsed_command_line.GetSwitchValue( | 44 const std::wstring timeout_str = parsed_command_line.GetSwitchValue( |
| 44 test_shell::kTestShellTimeOut); | 45 test_shell::kTestShellTimeOut); |
| 45 int timeout_ms = | 46 int timeout_ms; |
| 46 static_cast<int>(StringToInt64(WideToUTF16Hack(timeout_str.c_str()))); | 47 if (base::StringToInt(WideToUTF8(timeout_str), &timeout_ms) && |
| 47 if (timeout_ms > 0) | 48 timeout_ms > 0) |
| 48 TestShell::SetFileTestTimeout(timeout_ms); | 49 TestShell::SetFileTestTimeout(timeout_ms); |
| 49 } | 50 } |
| 50 | 51 |
| 51 // Optionally use playback mode (for instance if running automated tests). | 52 // Optionally use playback mode (for instance if running automated tests). |
| 52 net::HttpCache::Mode mode = | 53 net::HttpCache::Mode mode = |
| 53 parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ? | 54 parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ? |
| 54 net::HttpCache::PLAYBACK : net::HttpCache::NORMAL; | 55 net::HttpCache::PLAYBACK : net::HttpCache::NORMAL; |
| 55 SimpleResourceLoaderBridge::Init(cache_path, mode, false); | 56 SimpleResourceLoaderBridge::Init(cache_path, mode, false); |
| 56 | 57 |
| 57 TestShellTest::SetUp(); | 58 TestShellTest::SetUp(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 72 } | 73 } |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 TEST_F(NodeLeakTest, TestURL) { | 76 TEST_F(NodeLeakTest, TestURL) { |
| 76 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 77 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 77 if (parsed_command_line.HasSwitch(kTestUrlSwitch)) | 78 if (parsed_command_line.HasSwitch(kTestUrlSwitch)) |
| 78 NavigateToURL(parsed_command_line.GetSwitchValue(kTestUrlSwitch).c_str()); | 79 NavigateToURL(parsed_command_line.GetSwitchValue(kTestUrlSwitch).c_str()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 } // namespace | 82 } // namespace |
| OLD | NEW |