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

Side by Side Diff: chrome/test/chromedriver/capabilities.cc

Issue 14263024: Logging API in chromedriver2. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/test/chromedriver/capabilities.h" 5 #include "chrome/test/chromedriver/capabilities.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (!android_package_value->GetAsString(&capabilities->android_package) || 194 if (!android_package_value->GetAsString(&capabilities->android_package) ||
195 capabilities->android_package.empty()) { 195 capabilities->android_package.empty()) {
196 return Status(kUnknownError, 196 return Status(kUnknownError,
197 "'androidPackage' must be a non-empty string"); 197 "'androidPackage' must be a non-empty string");
198 } 198 }
199 } 199 }
200 } 200 }
201 return Status(kOk); 201 return Status(kOk);
202 } 202 }
203 203
204 Status ParseLoggingPrefs(const base::DictionaryValue& desired_caps,
205 Capabilities* capabilities) {
206 const base::Value* logging_prefs = NULL;
207 if (desired_caps.Get("loggingPrefs", &logging_prefs)) {
208 const base::DictionaryValue* logging_prefs_dict = NULL;
209 if (!logging_prefs->GetAsDictionary(&logging_prefs_dict)) {
210 return Status(kUnknownError, "'loggingPrefs' must be a dictionary");
211 }
212 // TODO(klm): verify log types.
213 // TODO(klm): verify log levels.
214 capabilities->logging_prefs.reset(logging_prefs_dict->DeepCopy());
215 }
216 return Status(kOk);
217 }
218
204 } // namespace 219 } // namespace
205 220
206 Capabilities::Capabilities() : command(CommandLine::NO_PROGRAM) {} 221 Capabilities::Capabilities() : command(CommandLine::NO_PROGRAM) {}
207 222
208 Capabilities::~Capabilities() {} 223 Capabilities::~Capabilities() {}
209 224
210 bool Capabilities::IsAndroid() const { 225 bool Capabilities::IsAndroid() const {
211 return !android_package.empty(); 226 return !android_package.empty();
212 } 227 }
213 228
214 Status Capabilities::Parse(const base::DictionaryValue& desired_caps) { 229 Status Capabilities::Parse(const base::DictionaryValue& desired_caps) {
215 Status status = ParseAndroidChromeCapabilities(desired_caps, this); 230 Status status = ParseLoggingPrefs(desired_caps, this);
231 if (status.IsError())
232 return status;
233 status = ParseAndroidChromeCapabilities(desired_caps, this);
216 if (status.IsError()) 234 if (status.IsError())
217 return status; 235 return status;
218 if (IsAndroid()) 236 if (IsAndroid())
219 return Status(kOk); 237 return Status(kOk);
220 238
221 std::map<std::string, Parser> parser_map; 239 std::map<std::string, Parser> parser_map;
222 parser_map["proxy"] = base::Bind(&ParseProxy); 240 parser_map["proxy"] = base::Bind(&ParseProxy);
223 parser_map["chromeOptions"] = base::Bind(&ParseDesktopChromeOption); 241 parser_map["chromeOptions"] = base::Bind(&ParseDesktopChromeOption);
224 for (std::map<std::string, Parser>::iterator it = parser_map.begin(); 242 for (std::map<std::string, Parser>::iterator it = parser_map.begin();
225 it != parser_map.end(); ++it) { 243 it != parser_map.end(); ++it) {
226 const base::Value* capability = NULL; 244 const base::Value* capability = NULL;
227 if (desired_caps.Get(it->first, &capability)) { 245 if (desired_caps.Get(it->first, &capability)) {
228 status = it->second.Run(*capability, this); 246 status = it->second.Run(*capability, this);
229 if (status.IsError()) 247 if (status.IsError())
230 return status; 248 return status;
231 } 249 }
232 } 250 }
233 return Status(kOk); 251 return Status(kOk);
234 } 252 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/capabilities.h ('k') | chrome/test/chromedriver/capabilities_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698