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

Side by Side Diff: chrome/test/webdriver/commands/set_timeout_commands.cc

Issue 23526047: Delete old chromedriver code, and remove mongoose webserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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/set_timeout_commands.h"
6
7 #include <string>
8
9 #include "base/strings/stringprintf.h"
10 #include "base/values.h"
11 #include "chrome/test/webdriver/commands/response.h"
12 #include "chrome/test/webdriver/webdriver_error.h"
13 #include "chrome/test/webdriver/webdriver_session.h"
14
15 namespace webdriver {
16
17 SetTimeoutCommand::SetTimeoutCommand(
18 const std::vector<std::string>& path_segments,
19 const DictionaryValue* const parameters) :
20 WebDriverCommand(path_segments, parameters) {}
21
22 SetTimeoutCommand::~SetTimeoutCommand() {}
23
24 bool SetTimeoutCommand::DoesPost() {
25 return true;
26 }
27
28 void SetTimeoutCommand::ExecutePost(Response* const response) {
29 // Timeout value in milliseconds
30 const char kTimeoutMsKey[] = "ms";
31
32 if (!HasParameter(kTimeoutMsKey)) {
33 response->SetError(new Error(kBadRequest, "Request missing ms parameter"));
34 return;
35 }
36
37 int ms_to_wait;
38 if (!GetIntegerParameter(kTimeoutMsKey, &ms_to_wait)) {
39 // Client may have sent us a floating point number. Since DictionaryValue
40 // will not do a down cast for us, we must explicitly check for it here.
41 // Note webdriver only supports whole milliseconds for a timeout value, so
42 // we are safe to downcast.
43 double ms;
44 if (!GetDoubleParameter(kTimeoutMsKey, &ms)) {
45 response->SetError(new Error(
46 kBadRequest, "ms parameter is not a number"));
47 return;
48 }
49 ms_to_wait = static_cast<int>(ms);
50 }
51
52 // Validate the wait time before setting it to the session.
53 if (ms_to_wait < 0) {
54 response->SetError(new Error(kBadRequest, "Timeout must be non-negative"));
55 return;
56 }
57
58 SetTimeout(ms_to_wait);
59 }
60
61 SetAsyncScriptTimeoutCommand::SetAsyncScriptTimeoutCommand(
62 const std::vector<std::string>& path_segments,
63 const DictionaryValue* const parameters)
64 : SetTimeoutCommand(path_segments, parameters) {}
65
66 SetAsyncScriptTimeoutCommand::~SetAsyncScriptTimeoutCommand() {}
67
68 void SetAsyncScriptTimeoutCommand::SetTimeout(int timeout_ms) {
69 session_->set_async_script_timeout(timeout_ms);
70 }
71
72 ImplicitWaitCommand::ImplicitWaitCommand(
73 const std::vector<std::string>& path_segments,
74 const DictionaryValue* const parameters)
75 : SetTimeoutCommand(path_segments, parameters) {}
76
77 ImplicitWaitCommand::~ImplicitWaitCommand() {}
78
79 void ImplicitWaitCommand::SetTimeout(int timeout_ms) {
80 session_->set_implicit_wait(timeout_ms);
81 }
82
83 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/set_timeout_commands.h ('k') | chrome/test/webdriver/commands/set_timeout_commands_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698