Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: chrome/browser/devtools/device/port_forwarding_browsertest.cc

Issue 503763002: DevTools: Test for disabling PortForwardingController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/port_forwarding_controller.h" 10 #include "chrome/browser/devtools/device/port_forwarding_controller.h"
(...skipping 20 matching lines...) Expand all
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 PortForwardingController::Listener { 38 class Listener : public PortForwardingController::Listener {
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 PortForwardingController::Factory::GetForProfile(profile_)-> 43 PortForwardingController::Factory::GetForProfile(profile_)->
43 AddListener(this); 44 AddListener(this);
44 } 45 }
45 46
46 virtual ~Listener() { 47 virtual ~Listener() {
47 PortForwardingController::Factory::GetForProfile(profile_)-> 48 PortForwardingController::Factory::GetForProfile(profile_)->
48 RemoveListener(this); 49 RemoveListener(this);
49 } 50 }
50 51
51 virtual void PortStatusChanged(const DevicesStatus& status) OVERRIDE { 52 virtual void PortStatusChanged(const DevicesStatus& status) OVERRIDE {
52 if (status.empty()) 53 if (status.empty() && skip_empty_devices_)
53 return; 54 return;
54 base::MessageLoop::current()->PostTask( 55 base::MessageLoop::current()->PostTask(
55 FROM_HERE, base::MessageLoop::QuitClosure()); 56 FROM_HERE, base::MessageLoop::QuitClosure());
56 } 57 }
57 58
59 void set_skip_empty_devices(bool skip_empty_devices) {
60 skip_empty_devices_ = skip_empty_devices;
61 }
62
58 private: 63 private:
59 Profile* profile_; 64 Profile* profile_;
65 bool skip_empty_devices_;
60 }; 66 };
61 }; 67 };
62 68
63 IN_PROC_BROWSER_TEST_F(PortForwardingTest, 69 IN_PROC_BROWSER_TEST_F(PortForwardingTest,
64 LoadPageWithStyleAnsScript) { 70 LoadPageWithStyleAnsScript) {
65 Profile* profile = browser()->profile(); 71 Profile* profile = browser()->profile();
66 72
67 AndroidDeviceManager::DeviceProviders device_providers; 73 AndroidDeviceManager::DeviceProviders device_providers;
68 device_providers.push_back(new SelfAsDeviceProvider(kDefaultDebuggingPort)); 74 device_providers.push_back(new SelfAsDeviceProvider(kDefaultDebuggingPort));
69 DevToolsAndroidBridge::Factory::GetForProfile(profile)-> 75 DevToolsAndroidBridge::Factory::GetForProfile(profile)->
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 "window.domAutomationController.send(getBodyTextContent())", 114 "window.domAutomationController.send(getBodyTextContent())",
109 &result)); 115 &result));
110 ASSERT_EQ("content", result) << "Javascript has not loaded."; 116 ASSERT_EQ("content", result) << "Javascript has not loaded.";
111 117
112 ASSERT_TRUE( 118 ASSERT_TRUE(
113 content::ExecuteScriptAndExtractString( 119 content::ExecuteScriptAndExtractString(
114 rvh, 120 rvh,
115 "window.domAutomationController.send(getBodyMarginLeft())", 121 "window.domAutomationController.send(getBodyMarginLeft())",
116 &result)); 122 &result));
117 ASSERT_EQ("100px", result) << "CSS has not loaded."; 123 ASSERT_EQ("100px", result) << "CSS has not loaded.";
124
125 // Test that disabling port forwarding is handled normally.
126 wait_for_port_forwarding.set_skip_empty_devices(false);
127 prefs->SetBoolean(prefs::kDevToolsPortForwardingEnabled, false);
128 content::RunMessageLoop();
118 } 129 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698