| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" | 9 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" |
| 10 #include "chrome/browser/devtools/device/devtools_android_bridge.h" | 10 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 const char kPortForwardingTestPage[] = | 24 const char kPortForwardingTestPage[] = |
| 25 "files/devtools/port_forwarding/main.html"; | 25 "files/devtools/port_forwarding/main.html"; |
| 26 | 26 |
| 27 const int kDefaultDebuggingPort = 9223; | 27 const int kDefaultDebuggingPort = 9223; |
| 28 } | 28 } |
| 29 | 29 |
| 30 class PortForwardingTest: public InProcessBrowserTest { | 30 class PortForwardingTest: public InProcessBrowserTest { |
| 31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 31 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 32 InProcessBrowserTest::SetUpCommandLine(command_line); | 32 InProcessBrowserTest::SetUpCommandLine(command_line); |
| 33 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, | 33 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, |
| 34 base::IntToString(kDefaultDebuggingPort)); | 34 base::IntToString(kDefaultDebuggingPort)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 class Listener : public DevToolsAndroidBridge::PortForwardingListener { | 38 class Listener : public DevToolsAndroidBridge::PortForwardingListener { |
| 39 public: | 39 public: |
| 40 explicit Listener(Profile* profile) | 40 explicit Listener(Profile* profile) |
| 41 : profile_(profile), | 41 : profile_(profile), |
| 42 skip_empty_devices_(true) { | 42 skip_empty_devices_(true) { |
| 43 DevToolsAndroidBridge::Factory::GetForProfile(profile_)-> | 43 DevToolsAndroidBridge::Factory::GetForProfile(profile_)-> |
| 44 AddPortForwardingListener(this); | 44 AddPortForwardingListener(this); |
| 45 } | 45 } |
| 46 | 46 |
| 47 virtual ~Listener() { | 47 virtual ~Listener() { |
| 48 DevToolsAndroidBridge::Factory::GetForProfile(profile_)-> | 48 DevToolsAndroidBridge::Factory::GetForProfile(profile_)-> |
| 49 RemovePortForwardingListener(this); | 49 RemovePortForwardingListener(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual void PortStatusChanged(const ForwardingStatus& status) OVERRIDE { | 52 virtual void PortStatusChanged(const ForwardingStatus& status) override { |
| 53 if (status.empty() && skip_empty_devices_) | 53 if (status.empty() && skip_empty_devices_) |
| 54 return; | 54 return; |
| 55 base::MessageLoop::current()->PostTask( | 55 base::MessageLoop::current()->PostTask( |
| 56 FROM_HERE, base::MessageLoop::QuitClosure()); | 56 FROM_HERE, base::MessageLoop::QuitClosure()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void set_skip_empty_devices(bool skip_empty_devices) { | 59 void set_skip_empty_devices(bool skip_empty_devices) { |
| 60 skip_empty_devices_ = skip_empty_devices; | 60 skip_empty_devices_ = skip_empty_devices; |
| 61 } | 61 } |
| 62 | 62 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 rvh, | 120 rvh, |
| 121 "window.domAutomationController.send(getBodyMarginLeft())", | 121 "window.domAutomationController.send(getBodyMarginLeft())", |
| 122 &result)); | 122 &result)); |
| 123 ASSERT_EQ("100px", result) << "CSS has not loaded."; | 123 ASSERT_EQ("100px", result) << "CSS has not loaded."; |
| 124 | 124 |
| 125 // Test that disabling port forwarding is handled normally. | 125 // Test that disabling port forwarding is handled normally. |
| 126 wait_for_port_forwarding.set_skip_empty_devices(false); | 126 wait_for_port_forwarding.set_skip_empty_devices(false); |
| 127 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, false); | 127 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, false); |
| 128 content::RunMessageLoop(); | 128 content::RunMessageLoop(); |
| 129 } | 129 } |
| OLD | NEW |