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

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

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 years, 4 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
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 std::string script = "return arguments[0]['value']"; 462 std::string script = "return arguments[0]['value']";
463 args.Append(element.ToValue()); 463 args.Append(element.ToValue());
464 464
465 Error* error = 465 Error* error =
466 session_->ExecuteScript(script, &args, &unscoped_result); 466 session_->ExecuteScript(script, &args, &unscoped_result);
467 scoped_ptr<Value> result(unscoped_result); 467 scoped_ptr<Value> result(unscoped_result);
468 if (error) { 468 if (error) {
469 response->SetError(error); 469 response->SetError(error);
470 return; 470 return;
471 } 471 }
472 if (!result->IsType(Value::TYPE_STRING) && 472 if (!result->IsString() && !result->IsNull()) {
473 !result->IsType(Value::TYPE_NULL)) {
474 response->SetError(new Error( 473 response->SetError(new Error(
475 kUnknownError, "Result is not string or null type")); 474 kUnknownError, "Result is not string or null type"));
476 return; 475 return;
477 } 476 }
478 response->SetValue(result.release()); 477 response->SetValue(result.release());
479 } 478 }
480 479
481 void ElementValueCommand::ExecutePost(Response* const response) { 480 void ElementValueCommand::ExecutePost(Response* const response) {
482 bool is_input = false; 481 bool is_input = false;
483 Error* error = HasAttributeWithLowerCaseValueASCII("tagName", "input", 482 Error* error = HasAttributeWithLowerCaseValueASCII("tagName", "input",
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 std::string script = base::StringPrintf( 616 std::string script = base::StringPrintf(
618 "return (%s).apply(null, arguments);", atoms::GET_TEXT); 617 "return (%s).apply(null, arguments);", atoms::GET_TEXT);
619 618
620 Error* error = session_->ExecuteScript(script, &args, 619 Error* error = session_->ExecuteScript(script, &args,
621 &unscoped_result); 620 &unscoped_result);
622 scoped_ptr<Value> result(unscoped_result); 621 scoped_ptr<Value> result(unscoped_result);
623 if (error) { 622 if (error) {
624 response->SetError(error); 623 response->SetError(error);
625 return; 624 return;
626 } 625 }
627 if (!result->IsType(Value::TYPE_STRING)) { 626 if (!result->IsString()) {
628 response->SetError(new Error(kUnknownError, "Result is not string type")); 627 response->SetError(new Error(kUnknownError, "Result is not string type"));
629 return; 628 return;
630 } 629 }
631 response->SetValue(result.release()); 630 response->SetValue(result.release());
632 } 631 }
633 632
634 } // namespace webdriver 633 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/set_timeout_commands_unittest.cc ('k') | chrome/test/webdriver/webdriver_basic_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698