OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 element2.SetString("ELEMENT", "2"); | 353 element2.SetString("ELEMENT", "2"); |
354 base::ListValue list; | 354 base::ListValue list; |
355 list.Append(element1.DeepCopy()); | 355 list.Append(element1.DeepCopy()); |
356 list.Append(element2.DeepCopy()); | 356 list.Append(element2.DeepCopy()); |
357 result_.reset(list.DeepCopy()); | 357 result_.reset(list.DeepCopy()); |
358 } | 358 } |
359 break; | 359 break; |
360 } | 360 } |
361 case kElementNotExistsQueryOnce: { | 361 case kElementNotExistsQueryOnce: { |
362 if (only_one_) | 362 if (only_one_) |
363 result_.reset(base::Value::CreateNullValue()); | 363 result_ = base::Value::CreateNullValue(); |
364 else | 364 else |
365 result_.reset(new base::ListValue()); | 365 result_.reset(new base::ListValue()); |
366 break; | 366 break; |
367 } | 367 } |
368 } | 368 } |
369 } | 369 } |
370 ~FindElementWebView() override {} | 370 ~FindElementWebView() override {} |
371 | 371 |
372 void Verify(const std::string& expected_frame, | 372 void Verify(const std::string& expected_frame, |
373 const base::ListValue* expected_args, | 373 const base::ListValue* expected_args, |
(...skipping 14 matching lines...) Expand all Loading... |
388 // Overridden from WebView: | 388 // Overridden from WebView: |
389 Status CallFunction(const std::string& frame, | 389 Status CallFunction(const std::string& frame, |
390 const std::string& function, | 390 const std::string& function, |
391 const base::ListValue& args, | 391 const base::ListValue& args, |
392 scoped_ptr<base::Value>* result) override { | 392 scoped_ptr<base::Value>* result) override { |
393 ++current_count_; | 393 ++current_count_; |
394 if (scenario_ == kElementExistsTimeout || | 394 if (scenario_ == kElementExistsTimeout || |
395 (scenario_ == kElementExistsQueryTwice && current_count_ == 1)) { | 395 (scenario_ == kElementExistsQueryTwice && current_count_ == 1)) { |
396 // Always return empty result when testing timeout. | 396 // Always return empty result when testing timeout. |
397 if (only_one_) | 397 if (only_one_) |
398 result->reset(base::Value::CreateNullValue()); | 398 *result = base::Value::CreateNullValue(); |
399 else | 399 else |
400 result->reset(new base::ListValue()); | 400 result->reset(new base::ListValue()); |
401 } else { | 401 } else { |
402 switch (scenario_) { | 402 switch (scenario_) { |
403 case kElementExistsQueryOnce: | 403 case kElementExistsQueryOnce: |
404 case kElementNotExistsQueryOnce: { | 404 case kElementNotExistsQueryOnce: { |
405 EXPECT_EQ(1, current_count_); | 405 EXPECT_EQ(1, current_count_); |
406 break; | 406 break; |
407 } | 407 } |
408 case kElementExistsQueryTwice: { | 408 case kElementExistsQueryTwice: { |
409 EXPECT_EQ(2, current_count_); | 409 EXPECT_EQ(2, current_count_); |
410 break; | 410 break; |
411 } | 411 } |
412 default: { | 412 default: { |
413 break; | 413 break; |
414 } | 414 } |
415 } | 415 } |
416 | 416 |
417 result->reset(result_->DeepCopy()); | 417 *result = result_->CreateDeepCopy(); |
418 frame_ = frame; | 418 frame_ = frame; |
419 function_ = function; | 419 function_ = function; |
420 args_.reset(args.DeepCopy()); | 420 args_ = args.CreateDeepCopy(); |
421 } | 421 } |
422 return Status(kOk); | 422 return Status(kOk); |
423 } | 423 } |
424 | 424 |
425 private: | 425 private: |
426 bool only_one_; | 426 bool only_one_; |
427 TestScenario scenario_; | 427 TestScenario scenario_; |
428 int current_count_; | 428 int current_count_; |
429 std::string frame_; | 429 std::string frame_; |
430 std::string function_; | 430 std::string function_; |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 false, | 815 false, |
816 params, | 816 params, |
817 id, | 817 id, |
818 base::Bind(&OnFailBecauseErrorNotifyingListeners, &run_loop)); | 818 base::Bind(&OnFailBecauseErrorNotifyingListeners, &run_loop)); |
819 run_loop.Run(); | 819 run_loop.Run(); |
820 | 820 |
821 thread->message_loop()->PostTask( | 821 thread->message_loop()->PostTask( |
822 FROM_HERE, | 822 FROM_HERE, |
823 base::Bind(&VerifySessionWasDeleted)); | 823 base::Bind(&VerifySessionWasDeleted)); |
824 } | 824 } |
OLD | NEW |