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_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/http/http_cache.h" | 9 #include "net/http/http_cache.h" |
10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // A test to help determine if any nodes have been leaked as a result of | 23 // A test to help determine if any nodes have been leaked as a result of |
24 // visiting a given URL. If enabled in WebCore, the number of leaked nodes | 24 // visiting a given URL. If enabled in WebCore, the number of leaked nodes |
25 // can be printed upon termination. This is only enabled in debug builds, so | 25 // can be printed upon termination. This is only enabled in debug builds, so |
26 // it only makes sense to run this using a debug build. | 26 // it only makes sense to run this using a debug build. |
27 // | 27 // |
28 // It will load a URL, visit about:blank, and then perform garbage collection. | 28 // It will load a URL, visit about:blank, and then perform garbage collection. |
29 // The number of remaining (potentially leaked) nodes will be printed on exit. | 29 // The number of remaining (potentially leaked) nodes will be printed on exit. |
30 class NodeLeakTest : public TestShellTest { | 30 class NodeLeakTest : public TestShellTest { |
31 public: | 31 public: |
32 virtual void SetUp() { | 32 virtual void SetUp() { |
33 CommandLine parsed_command_line; | 33 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
34 | 34 |
35 std::wstring js_flags = | 35 std::wstring js_flags = |
36 parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags); | 36 parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags); |
37 CommandLine::AppendSwitch(&js_flags, L"expose-gc"); | 37 js_flags += L" --expose-gc"; |
38 webkit_glue::SetJavaScriptFlags(js_flags); | 38 webkit_glue::SetJavaScriptFlags(js_flags); |
39 // Expose GCController to JavaScript as well. | 39 // Expose GCController to JavaScript as well. |
40 webkit_glue::SetShouldExposeGCController(true); | 40 webkit_glue::SetShouldExposeGCController(true); |
41 | 41 |
42 std::wstring cache_path = | 42 std::wstring cache_path = |
43 parsed_command_line.GetSwitchValue(test_shell::kCacheDir); | 43 parsed_command_line.GetSwitchValue(test_shell::kCacheDir); |
44 if (cache_path.empty()) { | 44 if (cache_path.empty()) { |
45 PathService::Get(base::DIR_EXE, &cache_path); | 45 PathService::Get(base::DIR_EXE, &cache_path); |
46 file_util::AppendToPath(&cache_path, L"cache"); | 46 file_util::AppendToPath(&cache_path, L"cache"); |
47 } | 47 } |
(...skipping 11 matching lines...) Expand all Loading... |
59 parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ? | 59 parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ? |
60 net::HttpCache::PLAYBACK : net::HttpCache::NORMAL; | 60 net::HttpCache::PLAYBACK : net::HttpCache::NORMAL; |
61 SimpleResourceLoaderBridge::Init( | 61 SimpleResourceLoaderBridge::Init( |
62 new TestShellRequestContext(cache_path, mode, false)); | 62 new TestShellRequestContext(cache_path, mode, false)); |
63 | 63 |
64 TestShellTest::SetUp(); | 64 TestShellTest::SetUp(); |
65 } | 65 } |
66 | 66 |
67 virtual void TearDown() { | 67 virtual void TearDown() { |
68 TestShellTest::TearDown(); | 68 TestShellTest::TearDown(); |
69 | 69 |
70 SimpleResourceLoaderBridge::Shutdown(); | 70 SimpleResourceLoaderBridge::Shutdown(); |
71 } | 71 } |
72 | 72 |
73 void NavigateToURL(const std::wstring& test_url) { | 73 void NavigateToURL(const std::wstring& test_url) { |
74 test_shell_->LoadURL(test_url.c_str()); | 74 test_shell_->LoadURL(test_url.c_str()); |
75 test_shell_->WaitTestFinished(); | 75 test_shell_->WaitTestFinished(); |
76 | 76 |
77 // Depends on TestShellTests::TearDown to load blank page and | 77 // Depends on TestShellTests::TearDown to load blank page and |
78 // the TestShell destructor to call garbage collection. | 78 // the TestShell destructor to call garbage collection. |
79 } | 79 } |
80 }; | 80 }; |
81 | 81 |
82 TEST_F(NodeLeakTest, TestURL) { | 82 TEST_F(NodeLeakTest, TestURL) { |
83 CommandLine parsed_command_line; | 83 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
84 if (parsed_command_line.HasSwitch(kTestUrlSwitch)) { | 84 if (parsed_command_line.HasSwitch(kTestUrlSwitch)) { |
85 NavigateToURL(parsed_command_line.GetSwitchValue(kTestUrlSwitch).c_str()); | 85 NavigateToURL(parsed_command_line.GetSwitchValue(kTestUrlSwitch).c_str()); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 } // namespace | 89 } // namespace |
OLD | NEW |