Chromium Code Reviews| Index: chrome/test/webdriver/commands/response.cc |
| diff --git a/chrome/test/webdriver/commands/response.cc b/chrome/test/webdriver/commands/response.cc |
| index d25675472c4b27ad217114c5c336856c615c85d2..a9358f776670acf1759866d56c7a63c2b009c786 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" |
| @@ -64,6 +65,32 @@ 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."; |
| + error->SetString(kScreenKey, ""); |
|
kkania
2011/03/22 21:08:56
I think it might be better to just not set kScreen
Joe
2011/03/22 22:08:19
Done.
|
| + } else { |
| + error->SetString(kScreenKey, base64_png); |
| + } |
| + |
| + SetStatus(error_code); |
| + SetValue(error); |
| +} |
| + |
| + |
| void Response::SetField(const std::string& key, Value* value) { |
| data_.Set(key, value); |
| } |