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

Unified Diff: chrome/test/webdriver/utility_functions.cc

Issue 7108037: Revert 88492 - In chromedriver, add /log url to get the contents of the chromedriver log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/webdriver/utility_functions.h ('k') | chrome/test/webdriver/webdriver_logging.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/utility_functions.cc
===================================================================
--- chrome/test/webdriver/utility_functions.cc (revision 88495)
+++ chrome/test/webdriver/utility_functions.cc (working copy)
@@ -4,13 +4,76 @@
#include "chrome/test/webdriver/utility_functions.h"
+#include <string.h>
+#include <wchar.h>
+#include <algorithm>
+#include <sstream>
+
#include "base/basictypes.h"
#include "base/format_macros.h"
+#include "base/json/json_reader.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "base/rand_util.h"
#include "base/stringprintf.h"
namespace webdriver {
+std::string print_valuetype(Value::ValueType e) {
+ switch (e) {
+ case Value::TYPE_NULL:
+ return "NULL ";
+ case Value::TYPE_BOOLEAN:
+ return "BOOL";
+ case Value::TYPE_INTEGER:
+ return "INT";
+ case Value::TYPE_DOUBLE:
+ return "DOUBLE";
+ case Value::TYPE_STRING:
+ return "STRING";
+ case Value::TYPE_BINARY:
+ return "BIN";
+ case Value::TYPE_DICTIONARY:
+ return "DICT";
+ case Value::TYPE_LIST:
+ return "LIST";
+ default:
+ return "ERROR";
+ }
+}
+
+void CheckValueType(const Value::ValueType expected,
+ const Value* const actual) {
+ DCHECK(actual != NULL) << "Expected value to be non-NULL";
+ DCHECK(expected == actual->GetType())
+ << "Expected " << print_valuetype(expected)
+ << ", but was " << print_valuetype(actual->GetType());
+}
+
+bool ParseJSONDictionary(const std::string& json, DictionaryValue** dict,
+ std::string* error) {
+ int error_code = 0;
+ Value* params =
+ base::JSONReader::ReadAndReturnError(json, true, &error_code, error);
+ if (error_code != 0) {
+ VLOG(1) << "Could not parse JSON object, " << *error;
+ if (params)
+ delete params;
+ return false;
+ }
+
+ if (!params || params->GetType() != Value::TYPE_DICTIONARY) {
+ *error = "Data passed in URL must be of type dictionary.";
+ VLOG(1) << "Invalid type to parse";
+ if (params)
+ delete params;
+ return false;
+ }
+
+ *dict = static_cast<DictionaryValue*>(params);
+ return true;
+}
+
std::string GenerateRandomID() {
uint64 msb = base::RandUint64();
uint64 lsb = base::RandUint64();
« no previous file with comments | « chrome/test/webdriver/utility_functions.h ('k') | chrome/test/webdriver/webdriver_logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698