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

Side by Side 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: fixed nit 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/webdriver/commands/response.h" 5 #include "chrome/test/webdriver/commands/response.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 Value* out = NULL; 46 Value* out = NULL;
47 LOG_IF(WARNING, !data_.Get(kValueKey, &out)) 47 LOG_IF(WARNING, !data_.Get(kValueKey, &out))
48 << "Accessing unset response value."; // Should never happen. 48 << "Accessing unset response value."; // Should never happen.
49 return out; 49 return out;
50 } 50 }
51 51
52 void Response::SetValue(Value* value) { 52 void Response::SetValue(Value* value) {
53 data_.Set(kValueKey, value); 53 data_.Set(kValueKey, value);
54 } 54 }
55 55
56 void Response::SetError(ErrorCode error_code, const std::string& message, 56 void Response::SetError(ErrorCode error_code,
57 const std::string& file, int line) { 57 const std::string& message,
58 const std::string& file,
59 int line,
60 const std::string& screenshot) {
58 DictionaryValue* error = new DictionaryValue; 61 DictionaryValue* error = new DictionaryValue;
59 error->SetString(kMessageKey, message); 62 error->SetString(kMessageKey, message);
60 error->SetString(kStackTraceFileNameKey, file); 63 error->SetString(kStackTraceFileNameKey, file);
61 error->SetInteger(kStackTraceLineNumberKey, line); 64 error->SetInteger(kStackTraceLineNumberKey, line);
62 65
66 if (!screenshot.empty()) {
67 error->SetString(kScreenKey, screenshot);
68 }
69
63 SetStatus(error_code); 70 SetStatus(error_code);
64 SetValue(error); 71 SetValue(error);
65 } 72 }
66 73
67 void Response::SetField(const std::string& key, Value* value) { 74 void Response::SetField(const std::string& key, Value* value) {
68 data_.Set(key, value); 75 data_.Set(key, value);
69 } 76 }
70 77
71 std::string Response::ToJSON() const { 78 std::string Response::ToJSON() const {
72 std::string json; 79 std::string json;
73 base::JSONWriter::Write(&data_, false, &json); 80 base::JSONWriter::Write(&data_, false, &json);
74 return json; 81 return json;
75 } 82 }
76 83
77 } // namespace webdriver 84 } // namespace webdriver
78 85
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698