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

Unified Diff: chrome/test/webdriver/commands/response.cc

Issue 5572001: Send screenshots back to the client for debugging (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: need to push again to make sure rietveld didn't screw up Created 9 years, 9 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/commands/response.h ('k') | chrome/test/webdriver/commands/screenshot_command.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/commands/response.cc
diff --git a/chrome/test/webdriver/commands/response.cc b/chrome/test/webdriver/commands/response.cc
index 153e6b71a8234625197aa5353cf8bf8e1c64a479..bb711efa539fb4fa41e27b2c17c302c0fa4686bf 100644
--- a/chrome/test/webdriver/commands/response.cc
+++ b/chrome/test/webdriver/commands/response.cc
@@ -4,6 +4,7 @@
#include "chrome/test/webdriver/commands/response.h"
+#include "base/base64.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/values.h"
@@ -74,6 +75,31 @@ void Response::SetError(ErrorCode error_code, const std::string& message,
SetValue(error);
}
+void Response::SetError(ErrorCode error_code,
+ const std::string& message,
+ const std::string& file,
+ int line,
+ const std::string& png) {
+ DictionaryValue* error = new DictionaryValue;
+
+ error->SetString(kMessageKey, message);
+ error->SetString(kStackTraceFileNameKey, file);
+ error->SetInteger(kStackTraceLineNumberKey, line);
+ std::string base64_png;
+
+ // Convert the raw binary data to base 64 encoding for webdriver.
+ if (!base::Base64Encode(png, &base64_png)) {
+ LOG(ERROR) << "Failed to encode screenshot to base64 "
+ << "sending back an empty string instead.";
+ } else {
+ error->SetString(kScreenKey, base64_png);
+ }
+
+ SetStatus(error_code);
+ SetValue(error);
+}
+
+
void Response::SetField(const std::string& key, Value* value) {
data_.Set(key, value);
}
« no previous file with comments | « chrome/test/webdriver/commands/response.h ('k') | chrome/test/webdriver/commands/screenshot_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698