| 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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 BrowserThread::PostTask( | 533 BrowserThread::PostTask( |
| 534 BrowserThread::IO, FROM_HERE, | 534 BrowserThread::IO, FROM_HERE, |
| 535 base::Bind(&SetCookieOnIOThread, url, value, | 535 base::Bind(&SetCookieOnIOThread, url, value, |
| 536 make_scoped_refptr(context_getter), &event, &result)); | 536 make_scoped_refptr(context_getter), &event, &result)); |
| 537 event.Wait(); | 537 event.Wait(); |
| 538 return result; | 538 return result; |
| 539 } | 539 } |
| 540 | 540 |
| 541 TitleWatcher::TitleWatcher(WebContents* web_contents, | 541 TitleWatcher::TitleWatcher(WebContents* web_contents, |
| 542 const string16& expected_title) | 542 const base::string16& expected_title) |
| 543 : WebContentsObserver(web_contents), | 543 : WebContentsObserver(web_contents), |
| 544 message_loop_runner_(new MessageLoopRunner) { | 544 message_loop_runner_(new MessageLoopRunner) { |
| 545 EXPECT_TRUE(web_contents != NULL); | 545 EXPECT_TRUE(web_contents != NULL); |
| 546 expected_titles_.push_back(expected_title); | 546 expected_titles_.push_back(expected_title); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void TitleWatcher::AlsoWaitForTitle(const string16& expected_title) { | 549 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { |
| 550 expected_titles_.push_back(expected_title); | 550 expected_titles_.push_back(expected_title); |
| 551 } | 551 } |
| 552 | 552 |
| 553 TitleWatcher::~TitleWatcher() { | 553 TitleWatcher::~TitleWatcher() { |
| 554 } | 554 } |
| 555 | 555 |
| 556 const string16& TitleWatcher::WaitAndGetTitle() { | 556 const base::string16& TitleWatcher::WaitAndGetTitle() { |
| 557 message_loop_runner_->Run(); | 557 message_loop_runner_->Run(); |
| 558 return observed_title_; | 558 return observed_title_; |
| 559 } | 559 } |
| 560 | 560 |
| 561 void TitleWatcher::DidStopLoading(RenderViewHost* render_view_host) { | 561 void TitleWatcher::DidStopLoading(RenderViewHost* render_view_host) { |
| 562 // When navigating through the history, the restored NavigationEntry's title | 562 // When navigating through the history, the restored NavigationEntry's title |
| 563 // will be used. If the entry ends up having the same title after we return | 563 // will be used. If the entry ends up having the same title after we return |
| 564 // to it, as will usually be the case, then WebContentsObserver::TitleSet | 564 // to it, as will usually be the case, then WebContentsObserver::TitleSet |
| 565 // will then be suppressed, since the NavigationEntry's title hasn't changed. | 565 // will then be suppressed, since the NavigationEntry's title hasn't changed. |
| 566 TestTitle(); | 566 TestTitle(); |
| 567 } | 567 } |
| 568 | 568 |
| 569 void TitleWatcher::TitleWasSet(NavigationEntry* entry, bool explicit_set) { | 569 void TitleWatcher::TitleWasSet(NavigationEntry* entry, bool explicit_set) { |
| 570 TestTitle(); | 570 TestTitle(); |
| 571 } | 571 } |
| 572 | 572 |
| 573 void TitleWatcher::TestTitle() { | 573 void TitleWatcher::TestTitle() { |
| 574 std::vector<string16>::const_iterator it = | 574 std::vector<base::string16>::const_iterator it = |
| 575 std::find(expected_titles_.begin(), | 575 std::find(expected_titles_.begin(), |
| 576 expected_titles_.end(), | 576 expected_titles_.end(), |
| 577 web_contents()->GetTitle()); | 577 web_contents()->GetTitle()); |
| 578 if (it == expected_titles_.end()) | 578 if (it == expected_titles_.end()) |
| 579 return; | 579 return; |
| 580 | 580 |
| 581 observed_title_ = *it; | 581 observed_title_ = *it; |
| 582 message_loop_runner_->Quit(); | 582 message_loop_runner_->Quit(); |
| 583 } | 583 } |
| 584 | 584 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 // The queue should not be empty, unless we were quit because of a timeout. | 634 // The queue should not be empty, unless we were quit because of a timeout. |
| 635 if (message_queue_.empty()) | 635 if (message_queue_.empty()) |
| 636 return false; | 636 return false; |
| 637 if (message) | 637 if (message) |
| 638 *message = message_queue_.front(); | 638 *message = message_queue_.front(); |
| 639 message_queue_.pop(); | 639 message_queue_.pop(); |
| 640 return true; | 640 return true; |
| 641 } | 641 } |
| 642 | 642 |
| 643 } // namespace content | 643 } // namespace content |
| OLD | NEW |