summaryrefslogtreecommitdiffstats
path: root/chrome/test/webdriver/commands/speed_command.cc
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 15:02:33 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 15:02:33 +0000
commit2937a8c72bfd28188ccd0b3f3b54bc3303b5f537 (patch)
tree384b91fec1c7736bee9ce5e61055e84febe2fcd5 /chrome/test/webdriver/commands/speed_command.cc
parentcdca989154d270a6553c1c8e2df0122b521b49eb (diff)
downloadchromium_src-2937a8c72bfd28188ccd0b3f3b54bc3303b5f537.zip
chromium_src-2937a8c72bfd28188ccd0b3f3b54bc3303b5f537.tar.gz
chromium_src-2937a8c72bfd28188ccd0b3f3b54bc3303b5f537.tar.bz2
Refactor error handling in chromedriver. Introduce new error class containing a webdriver error code, possible error details, and a stack trace.
Also some minor cleanup of the command files. BUG=none TEST=none Review URL: http://codereview.chromium.org/7042018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/webdriver/commands/speed_command.cc')
-rw-r--r--chrome/test/webdriver/commands/speed_command.cc108
1 files changed, 0 insertions, 108 deletions
diff --git a/chrome/test/webdriver/commands/speed_command.cc b/chrome/test/webdriver/commands/speed_command.cc
deleted file mode 100644
index 9755305..0000000
--- a/chrome/test/webdriver/commands/speed_command.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/test/webdriver/commands/speed_command.h"
-
-#include <string>
-
-#include "base/utf_string_conversions.h"
-#include "chrome/test/webdriver/commands/response.h"
-
-namespace webdriver {
-
-SpeedCommand::SpeedCommand(const std::vector<std::string>& path_segments,
- const DictionaryValue* const parameters)
- : WebDriverCommand(path_segments, parameters),
- speed_(Session::kMedium) {
-}
-
-SpeedCommand::~SpeedCommand() {}
-
-bool SpeedCommand::Init(Response* const response) {
- std::string speed;
-
- if (!WebDriverCommand::Init(response)) {
- SET_WEBDRIVER_ERROR(response, "Failure on Init for setting speed",
- kInternalServerError);
- return false;
- }
-
- // The speed parameter must be passed in as SLOW, MEDIUM, or FAST.
- // The command must also be in all upper case letters.
- if (!GetStringASCIIParameter("speed", &speed)) {
- SET_WEBDRIVER_ERROR(response, "Request missing speed parameter",
- kBadRequest);
- return false;
- }
-
- if (speed.compare("SLOW") == 0) {
- LOG(INFO) << "Speed set to slow";
- speed_ = Session::kSlow;
- } else if (speed.compare("MEDIUM") == 0) {
- LOG(INFO) << "Speed set to medium";
- speed_ = Session::kMedium;
- } else if (speed.compare("FAST") == 0) {
- LOG(INFO) << "Speed set to fast" << std::endl;
- speed_ = Session::kFast;
- } else {
- // If the speed is invalid throw and error in the POST response.
- LOG(INFO) << "Requested an unknown speed: " << speed;
- speed_ = Session::kUnknown;
- }
-
- return true;
-}
-
-bool SpeedCommand::DoesGet() {
- return true;
-}
-
-bool SpeedCommand::DoesPost() {
- return true;
-}
-
-void SpeedCommand::ExecuteGet(Response* const response) {
- switch (session_->speed()) {
- case Session::kSlow:
- response->SetValue(new StringValue("SLOW"));
- response->SetStatus(kSuccess);
- break;
-
- case Session::kMedium:
- response->SetValue(new StringValue("MEDIUM"));
- response->SetStatus(kSuccess);
- break;
-
- case Session::kFast:
- response->SetValue(new StringValue("FAST"));
- response->SetStatus(kSuccess);
- break;
-
- default:
- // The speed should have never been set to unknown.
- SET_WEBDRIVER_ERROR(response, "Unknown speed set",
- kInternalServerError);
- NOTREACHED();
- break;
- }
-}
-
-void SpeedCommand::ExecutePost(Response* const response) {
- if (speed_ == Session::kUnknown) {
- SET_WEBDRIVER_ERROR(response, "Invalid speed requested",
- kInternalServerError);
- return;
- }
-
- session_->set_speed(speed_);
- response->SetValue(new StringValue("success"));
- response->SetStatus(kSuccess);
-}
-
-bool SpeedCommand::RequiresValidTab() {
- return true;
-}
-
-} // namespace webdriver
-