OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/test/webdriver/commands/speed_command.h" | 8 #include "chrome/test/webdriver/commands/speed_command.h" |
9 | 9 |
10 namespace webdriver { | 10 namespace webdriver { |
11 | 11 |
| 12 SpeedCommand::SpeedCommand(const std::vector<std::string>& path_segments, |
| 13 const DictionaryValue* const parameters) |
| 14 : WebDriverCommand(path_segments, parameters), |
| 15 speed_(Session::kMedium) { |
| 16 } |
| 17 |
| 18 SpeedCommand::~SpeedCommand() {} |
| 19 |
12 bool SpeedCommand::Init(Response* const response) { | 20 bool SpeedCommand::Init(Response* const response) { |
13 std::string speed; | 21 std::string speed; |
14 | 22 |
15 if (!WebDriverCommand::Init(response)) { | 23 if (!WebDriverCommand::Init(response)) { |
16 SET_WEBDRIVER_ERROR(response, "Failure on Init for setting speed", | 24 SET_WEBDRIVER_ERROR(response, "Failure on Init for setting speed", |
17 kInternalServerError); | 25 kInternalServerError); |
18 return false; | 26 return false; |
19 } | 27 } |
20 | 28 |
21 // The speed parameter must be passed in as SLOW, MEDIUM, or FAST. | 29 // The speed parameter must be passed in as SLOW, MEDIUM, or FAST. |
(...skipping 15 matching lines...) Expand all Loading... |
37 speed_ = Session::kFast; | 45 speed_ = Session::kFast; |
38 } else { | 46 } else { |
39 // If the speed is invalid throw and error in the POST response. | 47 // If the speed is invalid throw and error in the POST response. |
40 LOG(INFO) << "Requested an unknown speed: " << speed; | 48 LOG(INFO) << "Requested an unknown speed: " << speed; |
41 speed_ = Session::kUnknown; | 49 speed_ = Session::kUnknown; |
42 } | 50 } |
43 | 51 |
44 return true; | 52 return true; |
45 } | 53 } |
46 | 54 |
| 55 bool SpeedCommand::DoesGet() { |
| 56 return true; |
| 57 } |
| 58 |
| 59 bool SpeedCommand::DoesPost() { |
| 60 return true; |
| 61 } |
| 62 |
47 void SpeedCommand::ExecuteGet(Response* const response) { | 63 void SpeedCommand::ExecuteGet(Response* const response) { |
48 switch (session_->speed()) { | 64 switch (session_->speed()) { |
49 case Session::kSlow: | 65 case Session::kSlow: |
50 response->set_value(new StringValue("SLOW")); | 66 response->set_value(new StringValue("SLOW")); |
51 response->set_status(kSuccess); | 67 response->set_status(kSuccess); |
52 break; | 68 break; |
53 | 69 |
54 case Session::kMedium: | 70 case Session::kMedium: |
55 response->set_value(new StringValue("MEDIUM")); | 71 response->set_value(new StringValue("MEDIUM")); |
56 response->set_status(kSuccess); | 72 response->set_status(kSuccess); |
(...skipping 18 matching lines...) Expand all Loading... |
75 SET_WEBDRIVER_ERROR(response, "Invalid speed requested", | 91 SET_WEBDRIVER_ERROR(response, "Invalid speed requested", |
76 kInternalServerError); | 92 kInternalServerError); |
77 return; | 93 return; |
78 } | 94 } |
79 | 95 |
80 session_->set_speed(speed_); | 96 session_->set_speed(speed_); |
81 response->set_value(new StringValue("success")); | 97 response->set_value(new StringValue("success")); |
82 response->set_status(kSuccess); | 98 response->set_status(kSuccess); |
83 } | 99 } |
84 | 100 |
| 101 bool SpeedCommand::RequiresValidTab() { |
| 102 return true; |
| 103 } |
| 104 |
85 } // namespace webdriver | 105 } // namespace webdriver |
86 | 106 |
OLD | NEW |