| 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/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "net/http/http_cache.h" | 10 #include "net/http/http_cache.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) { | 43 if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) { |
| 44 const std::string timeout_str = parsed_command_line.GetSwitchValueASCII( | 44 const std::string timeout_str = parsed_command_line.GetSwitchValueASCII( |
| 45 test_shell::kTestShellTimeOut); | 45 test_shell::kTestShellTimeOut); |
| 46 int timeout_ms; | 46 int timeout_ms; |
| 47 if (base::StringToInt(timeout_str, &timeout_ms) && timeout_ms > 0) | 47 if (base::StringToInt(timeout_str, &timeout_ms) && timeout_ms > 0) |
| 48 TestShell::SetFileTestTimeout(timeout_ms); | 48 TestShell::SetFileTestTimeout(timeout_ms); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Optionally use playback mode (for instance if running automated tests). | 51 SimpleResourceLoaderBridge::Init(cache_path, net::HttpCache::NORMAL, false); |
| 52 net::HttpCache::Mode mode = | |
| 53 parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ? | |
| 54 net::HttpCache::PLAYBACK : net::HttpCache::NORMAL; | |
| 55 SimpleResourceLoaderBridge::Init(cache_path, mode, false); | |
| 56 | 52 |
| 57 TestShellTest::SetUp(); | 53 TestShellTest::SetUp(); |
| 58 } | 54 } |
| 59 | 55 |
| 60 virtual void TearDown() { | 56 virtual void TearDown() { |
| 61 TestShellTest::TearDown(); | 57 TestShellTest::TearDown(); |
| 62 | 58 |
| 63 SimpleResourceLoaderBridge::Shutdown(); | 59 SimpleResourceLoaderBridge::Shutdown(); |
| 64 } | 60 } |
| 65 | 61 |
| 66 void NavigateToURL(const std::string& test_url) { | 62 void NavigateToURL(const std::string& test_url) { |
| 67 test_shell_->LoadURL(GURL(test_url)); | 63 test_shell_->LoadURL(GURL(test_url)); |
| 68 test_shell_->WaitTestFinished(); | 64 test_shell_->WaitTestFinished(); |
| 69 | 65 |
| 70 // Depends on TestShellTests::TearDown to load blank page and | 66 // Depends on TestShellTests::TearDown to load blank page and |
| 71 // the TestShell destructor to call garbage collection. | 67 // the TestShell destructor to call garbage collection. |
| 72 } | 68 } |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 TEST_F(NodeLeakTest, TestURL) { | 71 TEST_F(NodeLeakTest, TestURL) { |
| 76 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 72 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 77 if (parsed_command_line.HasSwitch(kTestUrlSwitch)) | 73 if (parsed_command_line.HasSwitch(kTestUrlSwitch)) |
| 78 NavigateToURL(parsed_command_line.GetSwitchValueASCII(kTestUrlSwitch)); | 74 NavigateToURL(parsed_command_line.GetSwitchValueASCII(kTestUrlSwitch)); |
| 79 } | 75 } |
| 80 | 76 |
| 81 } // namespace | 77 } // namespace |
| OLD | NEW |