OLD | NEW |
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/webelement_commands.h" | 5 #include "chrome/test/webdriver/commands/webelement_commands.h" |
6 | 6 |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/third_party/icu/icu_utf.h" | 9 #include "base/third_party/icu/icu_utf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/test/webdriver/commands/response.h" | 11 #include "chrome/test/webdriver/commands/response.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 DictionaryValue* parameters) | 148 DictionaryValue* parameters) |
149 : WebElementCommand(path_segments, parameters) {} | 149 : WebElementCommand(path_segments, parameters) {} |
150 | 150 |
151 ElementDisplayedCommand::~ElementDisplayedCommand() {} | 151 ElementDisplayedCommand::~ElementDisplayedCommand() {} |
152 | 152 |
153 bool ElementDisplayedCommand::DoesGet() { | 153 bool ElementDisplayedCommand::DoesGet() { |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 void ElementDisplayedCommand::ExecuteGet(Response* const response) { | 157 void ElementDisplayedCommand::ExecuteGet(Response* const response) { |
158 scoped_ptr<ListValue> args(new ListValue); | 158 bool is_displayed; |
159 args->Append(element.ToValue()); | 159 ErrorCode status = session_->IsElementDisplayed( |
160 | 160 session_->current_target(), element, &is_displayed); |
161 std::string script = base::StringPrintf( | 161 if (status == kSuccess) |
162 "return (%s).apply(null, arguments);", atoms::IS_DISPLAYED); | 162 response->SetValue(Value::CreateBooleanValue(is_displayed)); |
163 | |
164 Value* result = NULL; | |
165 ErrorCode status = session_->ExecuteScript(script, args.get(), &result); | |
166 response->SetStatus(status); | 163 response->SetStatus(status); |
167 response->SetValue(result); | |
168 } | 164 } |
169 | 165 |
170 ///////////////////// ElementEnabledCommand //////////////////// | 166 ///////////////////// ElementEnabledCommand //////////////////// |
171 | 167 |
172 ElementEnabledCommand::ElementEnabledCommand( | 168 ElementEnabledCommand::ElementEnabledCommand( |
173 const std::vector<std::string>& path_segments, | 169 const std::vector<std::string>& path_segments, |
174 DictionaryValue* parameters) | 170 DictionaryValue* parameters) |
175 : WebElementCommand(path_segments, parameters) {} | 171 : WebElementCommand(path_segments, parameters) {} |
176 | 172 |
177 ElementEnabledCommand::~ElementEnabledCommand() {} | 173 ElementEnabledCommand::~ElementEnabledCommand() {} |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 SET_WEBDRIVER_ERROR(response, | 530 SET_WEBDRIVER_ERROR(response, |
535 "Result is not string type", | 531 "Result is not string type", |
536 kInternalServerError); | 532 kInternalServerError); |
537 return; | 533 return; |
538 } | 534 } |
539 response->SetStatus(kSuccess); | 535 response->SetStatus(kSuccess); |
540 response->SetValue(result.release()); | 536 response->SetValue(result.release()); |
541 } | 537 } |
542 | 538 |
543 } // namespace webdriver | 539 } // namespace webdriver |
OLD | NEW |