| 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 | 26 |
| 27 namespace { | 27 namespace { |
| 28 const char kPortForwardingTestPage[] = | 28 const char kPortForwardingTestPage[] = "/devtools/port_forwarding/main.html"; |
| 29 "files/devtools/port_forwarding/main.html"; | |
| 30 | 29 |
| 31 const int kDefaultDebuggingPort = 9223; | 30 const int kDefaultDebuggingPort = 9223; |
| 32 const int kAlternativeDebuggingPort = 9224; | 31 const int kAlternativeDebuggingPort = 9224; |
| 33 | 32 |
| 34 } | 33 } |
| 35 | 34 |
| 36 class PortForwardingTest: public InProcessBrowserTest { | 35 class PortForwardingTest: public InProcessBrowserTest { |
| 37 virtual int GetRemoteDebuggingPort() { | 36 virtual int GetRemoteDebuggingPort() { |
| 38 return kDefaultDebuggingPort; | 37 return kDefaultDebuggingPort; |
| 39 } | 38 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 DISABLED_LoadPageWithStyleAnsScript) { | 80 DISABLED_LoadPageWithStyleAnsScript) { |
| 82 Profile* profile = browser()->profile(); | 81 Profile* profile = browser()->profile(); |
| 83 | 82 |
| 84 AndroidDeviceManager::DeviceProviders device_providers; | 83 AndroidDeviceManager::DeviceProviders device_providers; |
| 85 | 84 |
| 86 device_providers.push_back( | 85 device_providers.push_back( |
| 87 TCPDeviceProvider::CreateForLocalhost(kDefaultDebuggingPort)); | 86 TCPDeviceProvider::CreateForLocalhost(kDefaultDebuggingPort)); |
| 88 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> | 87 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> |
| 89 set_device_providers_for_test(device_providers); | 88 set_device_providers_for_test(device_providers); |
| 90 | 89 |
| 91 ASSERT_TRUE(test_server()->Start()); | 90 ASSERT_TRUE(embedded_test_server()->Start()); |
| 92 GURL original_url = test_server()->GetURL(kPortForwardingTestPage); | 91 GURL original_url = embedded_test_server()->GetURL(kPortForwardingTestPage); |
| 93 | 92 |
| 94 std::string forwarding_port("8000"); | 93 std::string forwarding_port("8000"); |
| 95 GURL forwarding_url(original_url.scheme() + "://" + | 94 GURL forwarding_url(original_url.scheme() + "://" + |
| 96 original_url.host() + ":" + forwarding_port + original_url.path()); | 95 original_url.host() + ":" + forwarding_port + original_url.path()); |
| 97 | 96 |
| 98 PrefService* prefs = profile->GetPrefs(); | 97 PrefService* prefs = profile->GetPrefs(); |
| 99 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); | 98 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); |
| 100 | 99 |
| 101 base::DictionaryValue config; | 100 base::DictionaryValue config; |
| 102 config.SetString( | 101 config.SetString( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 151 |
| 153 AndroidDeviceManager::DeviceProviders device_providers; | 152 AndroidDeviceManager::DeviceProviders device_providers; |
| 154 | 153 |
| 155 scoped_refptr<TCPDeviceProvider> self_provider( | 154 scoped_refptr<TCPDeviceProvider> self_provider( |
| 156 TCPDeviceProvider::CreateForLocalhost(kAlternativeDebuggingPort)); | 155 TCPDeviceProvider::CreateForLocalhost(kAlternativeDebuggingPort)); |
| 157 device_providers.push_back(self_provider); | 156 device_providers.push_back(self_provider); |
| 158 | 157 |
| 159 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> | 158 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> |
| 160 set_device_providers_for_test(device_providers); | 159 set_device_providers_for_test(device_providers); |
| 161 | 160 |
| 162 ASSERT_TRUE(test_server()->Start()); | 161 ASSERT_TRUE(embedded_test_server()->Start()); |
| 163 GURL original_url = test_server()->GetURL(kPortForwardingTestPage); | 162 GURL original_url = embedded_test_server()->GetURL(kPortForwardingTestPage); |
| 164 | 163 |
| 165 std::string forwarding_port("8000"); | 164 std::string forwarding_port("8000"); |
| 166 GURL forwarding_url(original_url.scheme() + "://" + | 165 GURL forwarding_url(original_url.scheme() + "://" + |
| 167 original_url.host() + ":" + forwarding_port + original_url.path()); | 166 original_url.host() + ":" + forwarding_port + original_url.path()); |
| 168 | 167 |
| 169 PrefService* prefs = profile->GetPrefs(); | 168 PrefService* prefs = profile->GetPrefs(); |
| 170 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); | 169 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, true); |
| 171 | 170 |
| 172 base::DictionaryValue config; | 171 base::DictionaryValue config; |
| 173 config.SetString( | 172 config.SetString( |
| 174 forwarding_port, original_url.host() + ":" + original_url.port()); | 173 forwarding_port, original_url.host() + ":" + original_url.port()); |
| 175 prefs->Set(prefs::kDevToolsPortForwardingConfig, config); | 174 prefs->Set(prefs::kDevToolsPortForwardingConfig, config); |
| 176 | 175 |
| 177 scoped_ptr<Listener> wait_for_port_forwarding(new Listener(profile)); | 176 scoped_ptr<Listener> wait_for_port_forwarding(new Listener(profile)); |
| 178 content::RunMessageLoop(); | 177 content::RunMessageLoop(); |
| 179 | 178 |
| 180 self_provider->set_release_callback_for_test( | 179 self_provider->set_release_callback_for_test( |
| 181 base::Bind(&base::MessageLoop::PostTask, | 180 base::Bind(&base::MessageLoop::PostTask, |
| 182 base::Unretained(base::MessageLoop::current()), FROM_HERE, | 181 base::Unretained(base::MessageLoop::current()), FROM_HERE, |
| 183 base::MessageLoop::QuitWhenIdleClosure())); | 182 base::MessageLoop::QuitWhenIdleClosure())); |
| 184 wait_for_port_forwarding.reset(); | 183 wait_for_port_forwarding.reset(); |
| 185 content::RunMessageLoop(); | 184 content::RunMessageLoop(); |
| 186 } | 185 } |
| OLD | NEW |