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

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

Issue 6462015: Cleanup more test code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wtf windows is this me Created 9 years, 10 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
« no previous file with comments | « chrome/test/webdriver/commands/find_element_commands.h ('k') | chrome/test/webdriver/keymap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 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/find_element_commands.h" 5 #include "chrome/test/webdriver/commands/find_element_commands.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/threading/platform_thread.h" 11 #include "base/threading/platform_thread.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "third_party/webdriver/atoms.h" 14 #include "third_party/webdriver/atoms.h"
15 #include "chrome/test/webdriver/error_codes.h" 15 #include "chrome/test/webdriver/error_codes.h"
16 #include "chrome/test/webdriver/utility_functions.h" 16 #include "chrome/test/webdriver/utility_functions.h"
17 17
18 namespace webdriver { 18 namespace webdriver {
19 19
20 FindElementCommand::FindElementCommand(
21 const std::vector<std::string>& path_segments,
22 const DictionaryValue* const parameters,
23 const bool find_one_element)
24 : WebDriverCommand(path_segments, parameters),
25 find_one_element_(find_one_element) {}
26
27 FindElementCommand::~FindElementCommand() {}
28
20 bool FindElementCommand::Init(Response* const response) { 29 bool FindElementCommand::Init(Response* const response) {
21 if (!WebDriverCommand::Init(response)) { 30 if (!WebDriverCommand::Init(response)) {
22 SET_WEBDRIVER_ERROR(response, "Failure on Init for find element", 31 SET_WEBDRIVER_ERROR(response, "Failure on Init for find element",
23 kInternalServerError); 32 kInternalServerError);
24 return false; 33 return false;
25 } 34 }
26 35
27 if (!GetStringASCIIParameter("using", &use_) || 36 if (!GetStringASCIIParameter("using", &use_) ||
28 !GetStringASCIIParameter("value", &value_)) { 37 !GetStringASCIIParameter("value", &value_)) {
29 SET_WEBDRIVER_ERROR(response, 38 SET_WEBDRIVER_ERROR(response,
(...skipping 12 matching lines...) Expand all
42 use_ = "tagName"; 51 use_ = "tagName";
43 } 52 }
44 53
45 // Searching under a custom root if the URL pattern is 54 // Searching under a custom root if the URL pattern is
46 // "/session/$session/element/$id/element(s)" 55 // "/session/$session/element/$id/element(s)"
47 root_element_id_ = GetPathVariable(4); 56 root_element_id_ = GetPathVariable(4);
48 57
49 return true; 58 return true;
50 } 59 }
51 60
61 bool FindElementCommand::DoesPost() {
62 return true;
63 }
64
52 void FindElementCommand::ExecutePost(Response* const response) { 65 void FindElementCommand::ExecutePost(Response* const response) {
53 scoped_ptr<ListValue> args(new ListValue()); 66 scoped_ptr<ListValue> args(new ListValue());
54 DictionaryValue* locator = new DictionaryValue(); 67 DictionaryValue* locator = new DictionaryValue();
55 ErrorCode error; 68 ErrorCode error;
56 std::string jscript; 69 std::string jscript;
57 Value* result = NULL; 70 Value* result = NULL;
58 bool done = false; 71 bool done = false;
59 72
60 // Set the command we are using to locate the value beging searched for. 73 // Set the command we are using to locate the value beging searched for.
61 locator->SetString(use_, value_); 74 locator->SetString(use_, value_);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 114
102 int64 elapsed_time = (base::Time::Now() - start_time).InMilliseconds(); 115 int64 elapsed_time = (base::Time::Now() - start_time).InMilliseconds();
103 done = done || elapsed_time > session_->implicit_wait(); 116 done = done || elapsed_time > session_->implicit_wait();
104 base::PlatformThread::Sleep(50); // Prevent a busy loop that eats the cpu. 117 base::PlatformThread::Sleep(50); // Prevent a busy loop that eats the cpu.
105 } 118 }
106 119
107 response->set_value(result); 120 response->set_value(result);
108 response->set_status(error); 121 response->set_status(error);
109 } 122 }
110 123
124 bool FindElementCommand::RequiresValidTab() {
125 return false;
126 }
127
111 } // namespace webdriver 128 } // namespace webdriver
112 129
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/find_element_commands.h ('k') | chrome/test/webdriver/keymap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698