| 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 "chrome/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 BrowserAddedObserver::~BrowserAddedObserver() { | 602 BrowserAddedObserver::~BrowserAddedObserver() { |
| 603 } | 603 } |
| 604 | 604 |
| 605 Browser* BrowserAddedObserver::WaitForSingleNewBrowser() { | 605 Browser* BrowserAddedObserver::WaitForSingleNewBrowser() { |
| 606 notification_observer_.Wait(); | 606 notification_observer_.Wait(); |
| 607 // Ensure that only a single new browser has appeared. | 607 // Ensure that only a single new browser has appeared. |
| 608 EXPECT_EQ(original_browsers_.size() + 1, BrowserList::size()); | 608 EXPECT_EQ(original_browsers_.size() + 1, BrowserList::size()); |
| 609 return GetBrowserNotInSet(original_browsers_); | 609 return GetBrowserNotInSet(original_browsers_); |
| 610 } | 610 } |
| 611 | 611 |
| 612 DOMMessageQueue::DOMMessageQueue() : waiting_for_message_(false) { | |
| 613 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, | |
| 614 content::NotificationService::AllSources()); | |
| 615 } | |
| 616 | |
| 617 DOMMessageQueue::~DOMMessageQueue() {} | |
| 618 | |
| 619 void DOMMessageQueue::Observe(int type, | |
| 620 const content::NotificationSource& source, | |
| 621 const content::NotificationDetails& details) { | |
| 622 content::Details<DomOperationNotificationDetails> dom_op_details(details); | |
| 623 content::Source<RenderViewHost> sender(source); | |
| 624 message_queue_.push(dom_op_details->json); | |
| 625 if (waiting_for_message_) { | |
| 626 waiting_for_message_ = false; | |
| 627 message_loop_runner_->Quit(); | |
| 628 } | |
| 629 } | |
| 630 | |
| 631 void DOMMessageQueue::ClearQueue() { | |
| 632 message_queue_ = std::queue<std::string>(); | |
| 633 } | |
| 634 | |
| 635 bool DOMMessageQueue::WaitForMessage(std::string* message) { | |
| 636 if (message_queue_.empty()) { | |
| 637 waiting_for_message_ = true; | |
| 638 // This will be quit when a new message comes in. | |
| 639 message_loop_runner_ = new content::MessageLoopRunner; | |
| 640 message_loop_runner_->Run(); | |
| 641 } | |
| 642 // The queue should not be empty, unless we were quit because of a timeout. | |
| 643 if (message_queue_.empty()) | |
| 644 return false; | |
| 645 if (message) | |
| 646 *message = message_queue_.front(); | |
| 647 return true; | |
| 648 } | |
| 649 | |
| 650 // Coordinates taking snapshots of a |RenderWidget|. | 612 // Coordinates taking snapshots of a |RenderWidget|. |
| 651 class SnapshotTaker { | 613 class SnapshotTaker { |
| 652 public: | 614 public: |
| 653 SnapshotTaker() : bitmap_(NULL) {} | 615 SnapshotTaker() : bitmap_(NULL) {} |
| 654 | 616 |
| 655 bool TakeRenderWidgetSnapshot(RenderWidgetHost* rwh, | 617 bool TakeRenderWidgetSnapshot(RenderWidgetHost* rwh, |
| 656 const gfx::Size& page_size, | 618 const gfx::Size& page_size, |
| 657 const gfx::Size& desired_size, | 619 const gfx::Size& desired_size, |
| 658 SkBitmap* bitmap) WARN_UNUSED_RESULT { | 620 SkBitmap* bitmap) WARN_UNUSED_RESULT { |
| 659 bitmap_ = bitmap; | 621 bitmap_ = bitmap; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 void HistoryEnumerator::HistoryQueryComplete( | 734 void HistoryEnumerator::HistoryQueryComplete( |
| 773 const base::Closure& quit_task, | 735 const base::Closure& quit_task, |
| 774 HistoryService::Handle request_handle, | 736 HistoryService::Handle request_handle, |
| 775 history::QueryResults* results) { | 737 history::QueryResults* results) { |
| 776 for (size_t i = 0; i < results->size(); ++i) | 738 for (size_t i = 0; i < results->size(); ++i) |
| 777 urls_.push_back((*results)[i].url()); | 739 urls_.push_back((*results)[i].url()); |
| 778 quit_task.Run(); | 740 quit_task.Run(); |
| 779 } | 741 } |
| 780 | 742 |
| 781 } // namespace ui_test_utils | 743 } // namespace ui_test_utils |
| OLD | NEW |