OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/devtools/android_device.h" | 5 #include "chrome/browser/devtools/android_device.h" |
6 #include "chrome/browser/devtools/devtools_adb_bridge.h" | 6 #include "chrome/browser/devtools/devtools_adb_bridge.h" |
7 #include "chrome/browser/devtools/devtools_target_impl.h" | 7 #include "chrome/browser/devtools/devtools_target_impl.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 MockDeviceImpl(const std::string& serial, int index, | 104 MockDeviceImpl(const std::string& serial, int index, |
105 bool connected, const char* device_model) | 105 bool connected, const char* device_model) |
106 : AndroidDevice(serial, connected), | 106 : AndroidDevice(serial, connected), |
107 device_model_(device_model) | 107 device_model_(device_model) |
108 {} | 108 {} |
109 | 109 |
110 virtual void RunCommand(const std::string& command, | 110 virtual void RunCommand(const std::string& command, |
111 const CommandCallback& callback) OVERRIDE { | 111 const CommandCallback& callback) OVERRIDE { |
112 const char* response; | 112 const char* response; |
113 | 113 |
114 if (command == kDeviceModelCommand) | 114 if (command == kDeviceModelCommand) { |
115 response = device_model_; | 115 response = device_model_; |
116 else if (command == kOpenedUnixSocketsCommand) | 116 } else if (command == kOpenedUnixSocketsCommand) { |
117 response = kSampleOpenedUnixSockets; | 117 response = kSampleOpenedUnixSockets; |
118 else if (command == kListProcessesCommand) | 118 } else if (command == kListProcessesCommand) { |
119 response = kSampleListProcesses; | 119 response = kSampleListProcesses; |
120 else if (command == kDumpsysCommand) | 120 } else if (command == kDumpsysCommand) { |
121 response = kSampleDumpsysCommand; | 121 response = kSampleDumpsysCommand; |
122 else | 122 } else { |
123 NOTREACHED(); | 123 NOTREACHED(); |
| 124 return; |
| 125 } |
124 | 126 |
125 base::MessageLoop::current()->PostTask( FROM_HERE, | 127 base::MessageLoop::current()->PostTask( FROM_HERE, |
126 base::Bind(&MockDeviceImpl::RunCommandCallback, | 128 base::Bind(&MockDeviceImpl::RunCommandCallback, |
127 this, callback, 0, response)); | 129 this, callback, 0, response)); |
128 } | 130 } |
129 | 131 |
130 void RunCommandCallback(const CommandCallback& callback, int result, | 132 void RunCommandCallback(const CommandCallback& callback, int result, |
131 const std::string& response) { | 133 const std::string& response) { |
132 callback.Run(result, response); | 134 callback.Run(result, response); |
133 } | 135 } |
134 | 136 |
135 virtual void OpenSocket(const std::string& name, | 137 virtual void OpenSocket(const std::string& name, |
136 const SocketCallback& callback) OVERRIDE { | 138 const SocketCallback& callback) OVERRIDE { |
137 NOTREACHED(); | 139 NOTREACHED(); |
138 } | 140 } |
139 | 141 |
140 virtual void HttpQuery(const std::string& la_name, | 142 virtual void HttpQuery(const std::string& la_name, |
141 const std::string& request, | 143 const std::string& request, |
142 const CommandCallback& callback) OVERRIDE { | 144 const CommandCallback& callback) OVERRIDE { |
143 const char* response; | 145 const char* response; |
144 | 146 |
145 if (la_name == "chrome_devtools_remote") { | 147 if (la_name == "chrome_devtools_remote") { |
146 if (request == kVersionRequest) | 148 if (request == kVersionRequest) { |
147 response = kSampleChromeVersion; | 149 response = kSampleChromeVersion; |
148 else if (request == kPageListRequest) | 150 } else if (request == kPageListRequest) { |
149 response = kSampleChromePages; | 151 response = kSampleChromePages; |
150 else | 152 } else { |
151 NOTREACHED(); | 153 NOTREACHED(); |
| 154 return; |
| 155 } |
152 } else if (la_name == "webview_devtools_remote_2425") { | 156 } else if (la_name == "webview_devtools_remote_2425") { |
153 if (request == kVersionRequest) | 157 if (request == kVersionRequest) { |
154 response = kSampleWebViewVersion; | 158 response = kSampleWebViewVersion; |
155 else if (request == kPageListRequest) | 159 } else if (request == kPageListRequest) { |
156 response = kSampleWebViewPages; | 160 response = kSampleWebViewPages; |
157 else | 161 } else { |
158 NOTREACHED(); | 162 NOTREACHED(); |
| 163 return; |
| 164 } |
159 } else { | 165 } else { |
160 NOTREACHED(); | 166 NOTREACHED(); |
| 167 return; |
161 } | 168 } |
162 | 169 |
163 base::MessageLoop::current()->PostTask( FROM_HERE, | 170 base::MessageLoop::current()->PostTask( FROM_HERE, |
164 base::Bind(&MockDeviceImpl::RunCommandCallback, | 171 base::Bind(&MockDeviceImpl::RunCommandCallback, |
165 this, callback, 0, response)); | 172 this, callback, 0, response)); |
166 } | 173 } |
167 | 174 |
168 virtual void HttpUpgrade(const std::string& la_name, | 175 virtual void HttpUpgrade(const std::string& la_name, |
169 const std::string& request, | 176 const std::string& request, |
170 const SocketCallback& callback) { | 177 const SocketCallback& callback) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 adb_bridge->set_device_providers(providers); | 290 adb_bridge->set_device_providers(providers); |
284 | 291 |
285 if (!adb_bridge) { | 292 if (!adb_bridge) { |
286 FAIL() << "Failed to get DevToolsAdbBridge."; | 293 FAIL() << "Failed to get DevToolsAdbBridge."; |
287 } | 294 } |
288 | 295 |
289 adb_bridge->AddListener(this); | 296 adb_bridge->AddListener(this); |
290 | 297 |
291 runner_->Run(); | 298 runner_->Run(); |
292 } | 299 } |
OLD | NEW |