Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 | 327 |
| 328 bool ElementSelectedCommand::DoesGet() { | 328 bool ElementSelectedCommand::DoesGet() { |
| 329 return true; | 329 return true; |
| 330 } | 330 } |
| 331 | 331 |
| 332 bool ElementSelectedCommand::DoesPost() { | 332 bool ElementSelectedCommand::DoesPost() { |
| 333 return true; | 333 return true; |
| 334 } | 334 } |
| 335 | 335 |
| 336 void ElementSelectedCommand::ExecuteGet(Response* const response) { | 336 void ElementSelectedCommand::ExecuteGet(Response* const response) { |
| 337 ListValue args; | 337 bool is_selected; |
| 338 args.Append(element.ToValue()); | 338 Error* error =session_->IsOptionElementSelected( |
|
Huyen
2011/08/08 21:05:21
add space after "="
| |
| 339 | 339 session_->current_target(), element, &is_selected); |
| 340 std::string script = base::StringPrintf( | |
| 341 "return (%s).apply(null, arguments);", atoms::IS_SELECTED); | |
| 342 | |
| 343 Value* result = NULL; | |
| 344 Error* error = session_->ExecuteScript(script, &args, &result); | |
| 345 if (error) { | 340 if (error) { |
| 346 response->SetError(error); | 341 response->SetError(error); |
| 347 return; | 342 return; |
| 348 } | 343 } |
| 349 response->SetValue(result); | 344 response->SetValue(Value::CreateBooleanValue(is_selected)); |
| 350 } | 345 } |
| 351 | 346 |
| 352 void ElementSelectedCommand::ExecutePost(Response* const response) { | 347 void ElementSelectedCommand::ExecutePost(Response* const response) { |
| 353 Error* error = session_->SelectOptionElement( | 348 Error* error = session_->SetOptionElementSelected( |
| 354 session_->current_target(), element); | 349 session_->current_target(), element, true); |
| 355 if (error) { | 350 if (error) { |
| 356 response->SetError(error); | 351 response->SetError(error); |
| 357 return; | 352 return; |
| 358 } | 353 } |
| 359 } | 354 } |
| 360 | 355 |
| 361 ///////////////////// ElementSizeCommand //////////////////// | 356 ///////////////////// ElementSizeCommand //////////////////// |
| 362 | 357 |
| 363 ElementSizeCommand::ElementSizeCommand( | 358 ElementSizeCommand::ElementSizeCommand( |
| 364 const std::vector<std::string>& path_segments, | 359 const std::vector<std::string>& path_segments, |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 return; | 626 return; |
| 632 } | 627 } |
| 633 if (!result->IsType(Value::TYPE_STRING)) { | 628 if (!result->IsType(Value::TYPE_STRING)) { |
| 634 response->SetError(new Error(kUnknownError, "Result is not string type")); | 629 response->SetError(new Error(kUnknownError, "Result is not string type")); |
| 635 return; | 630 return; |
| 636 } | 631 } |
| 637 response->SetValue(result.release()); | 632 response->SetValue(result.release()); |
| 638 } | 633 } |
| 639 | 634 |
| 640 } // namespace webdriver | 635 } // namespace webdriver |
| OLD | NEW |