OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
12 #include "chrome/browser/devtools/device/devtools_android_bridge.h" | 12 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
13 #include "chrome/browser/devtools/device/tcp_device_provider.h" | 13 #include "chrome/browser/devtools/device/tcp_device_provider.h" |
14 #include "chrome/browser/devtools/remote_debugging_server.h" | 14 #include "chrome/browser/devtools/remote_debugging_server.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
24 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
25 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
| 26 #include "net/test/embedded_test_server/embedded_test_server.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 const char kPortForwardingTestPage[] = | 29 const char kPortForwardingTestPage[] = "/devtools/port_forwarding/main.html"; |
29 "files/devtools/port_forwarding/main.html"; | |
30 | 30 |
31 const int kDefaultDebuggingPort = 9223; | 31 const int kDefaultDebuggingPort = 9223; |
32 const int kAlternativeDebuggingPort = 9224; | 32 const int kAlternativeDebuggingPort = 9224; |
33 | 33 |
34 } | 34 } |
35 | 35 |
36 class PortForwardingTest: public InProcessBrowserTest { | 36 class PortForwardingTest: public InProcessBrowserTest { |
37 virtual int GetRemoteDebuggingPort() { | 37 virtual int GetRemoteDebuggingPort() { |
38 return kDefaultDebuggingPort; | 38 return kDefaultDebuggingPort; |
39 } | 39 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 DISABLED_LoadPageWithStyleAnsScript) { | 81 DISABLED_LoadPageWithStyleAnsScript) { |
82 Profile* profile = browser()->profile(); | 82 Profile* profile = browser()->profile(); |
83 | 83 |
84 AndroidDeviceManager::DeviceProviders device_providers; | 84 AndroidDeviceManager::DeviceProviders device_providers; |
85 | 85 |
86 device_providers.push_back( | 86 device_providers.push_back( |
87 TCPDeviceProvider::CreateForLocalhost(kDefaultDebuggingPort)); | 87 TCPDeviceProvider::CreateForLocalhost(kDefaultDebuggingPort)); |
88 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> | 88 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> |
89 set_device_providers_for_test(device_providers); | 89 set_device_providers_for_test(device_providers); |
90 | 90 |
91 ASSERT_TRUE(test_server()->Start()); | 91 ASSERT_TRUE(embedded_test_server()->Start()); |
92 GURL original_url = test_server()->GetURL(kPortForwardingTestPage); | 92 GURL original_url = embedded_test_server()->GetURL(kPortForwardingTestPage); |
93 | 93 |
94 std::string forwarding_port("8000"); | 94 std::string forwarding_port("8000"); |
95 GURL forwarding_url(original_url.scheme() + "://" + | 95 GURL forwarding_url(original_url.scheme() + "://" + |
96 original_url.host() + ":" + forwarding_port + original_url.path()); | 96 original_url.host() + ":" + forwarding_port + original_url.path()); |
97 | 97 |
98 PrefService* prefs = profile->GetPrefs(); | 98 PrefService* prefs = profile->GetPrefs(); |
99 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); | 99 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); |
100 | 100 |
101 base::DictionaryValue config; | 101 base::DictionaryValue config; |
102 config.SetString( | 102 config.SetString( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 AndroidDeviceManager::DeviceProviders device_providers; | 153 AndroidDeviceManager::DeviceProviders device_providers; |
154 | 154 |
155 scoped_refptr<TCPDeviceProvider> self_provider( | 155 scoped_refptr<TCPDeviceProvider> self_provider( |
156 TCPDeviceProvider::CreateForLocalhost(kAlternativeDebuggingPort)); | 156 TCPDeviceProvider::CreateForLocalhost(kAlternativeDebuggingPort)); |
157 device_providers.push_back(self_provider); | 157 device_providers.push_back(self_provider); |
158 | 158 |
159 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> | 159 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> |
160 set_device_providers_for_test(device_providers); | 160 set_device_providers_for_test(device_providers); |
161 | 161 |
162 ASSERT_TRUE(test_server()->Start()); | 162 ASSERT_TRUE(embedded_test_server()->Start()); |
163 GURL original_url = test_server()->GetURL(kPortForwardingTestPage); | 163 GURL original_url = embedded_test_server()->GetURL(kPortForwardingTestPage); |
164 | 164 |
165 std::string forwarding_port("8000"); | 165 std::string forwarding_port("8000"); |
166 GURL forwarding_url(original_url.scheme() + "://" + | 166 GURL forwarding_url(original_url.scheme() + "://" + |
167 original_url.host() + ":" + forwarding_port + original_url.path()); | 167 original_url.host() + ":" + forwarding_port + original_url.path()); |
168 | 168 |
169 PrefService* prefs = profile->GetPrefs(); | 169 PrefService* prefs = profile->GetPrefs(); |
170 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); | 170 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); |
171 | 171 |
172 base::DictionaryValue config; | 172 base::DictionaryValue config; |
173 config.SetString( | 173 config.SetString( |
174 forwarding_port, original_url.host() + ":" + original_url.port()); | 174 forwarding_port, original_url.host() + ":" + original_url.port()); |
175 prefs->Set(prefs::kDevToolsPortForwardingConfig, config); | 175 prefs->Set(prefs::kDevToolsPortForwardingConfig, config); |
176 | 176 |
177 scoped_ptr<Listener> wait_for_port_forwarding(new Listener(profile)); | 177 scoped_ptr<Listener> wait_for_port_forwarding(new Listener(profile)); |
178 content::RunMessageLoop(); | 178 content::RunMessageLoop(); |
179 | 179 |
180 self_provider->set_release_callback_for_test( | 180 self_provider->set_release_callback_for_test( |
181 base::Bind(&base::MessageLoop::PostTask, | 181 base::Bind(&base::MessageLoop::PostTask, |
182 base::Unretained(base::MessageLoop::current()), FROM_HERE, | 182 base::Unretained(base::MessageLoop::current()), FROM_HERE, |
183 base::MessageLoop::QuitWhenIdleClosure())); | 183 base::MessageLoop::QuitWhenIdleClosure())); |
184 wait_for_port_forwarding.reset(); | 184 wait_for_port_forwarding.reset(); |
185 content::RunMessageLoop(); | 185 content::RunMessageLoop(); |
186 } | 186 } |
OLD | NEW |