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

Side by Side Diff: chrome/test/webdriver/commands/screenshot_command.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/test/webdriver/commands/screenshot_command.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/base64.h"
11 #include "base/values.h"
12 #include "chrome/test/webdriver/commands/response.h"
13 #include "chrome/test/webdriver/error_codes.h"
14 #include "chrome/test/webdriver/session.h"
15
16 namespace webdriver {
17
18 ScreenshotCommand::ScreenshotCommand(const std::vector<std::string>& ps,
19 const DictionaryValue* const parameters)
20 : WebDriverCommand(ps, parameters) {}
21
22 ScreenshotCommand::~ScreenshotCommand() {}
23
24 bool ScreenshotCommand::DoesGet() {
25 return true;
26 }
27
28 void ScreenshotCommand::ExecuteGet(Response* const response) {
29 std::string raw_bytes;
30 if (!session_->GetScreenShot(&raw_bytes)) {
31 SET_WEBDRIVER_ERROR(response, "Screenshot of current page failed",
32 kInternalServerError);
33 return;
34 }
35
36 // Convert the raw binary data to base 64 encoding for webdriver.
37 std::string base64_screenshot;
38 if (!base::Base64Encode(raw_bytes, &base64_screenshot)) {
39 SET_WEBDRIVER_ERROR(response, "Encoding the PNG to base64 format failed",
40 kInternalServerError);
41 return;
42 }
43
44 response->SetValue(new StringValue(base64_screenshot));
45 response->SetStatus(kSuccess);
46 }
47
48 } // namespace webdriver
49
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/screenshot_command.h ('k') | chrome/test/webdriver/commands/webdriver_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698