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/ui_test_utils.h" | 5 #include "chrome/test/ui_test_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 if (waiting_for_ == source || | 882 if (waiting_for_ == source || |
883 (running_ && waiting_for_ == NotificationService::AllSources())) { | 883 (running_ && waiting_for_ == NotificationService::AllSources())) { |
884 seen_ = true; | 884 seen_ = true; |
885 if (running_) | 885 if (running_) |
886 MessageLoopForUI::current()->Quit(); | 886 MessageLoopForUI::current()->Quit(); |
887 } else { | 887 } else { |
888 sources_seen_.insert(source.map_key()); | 888 sources_seen_.insert(source.map_key()); |
889 } | 889 } |
890 } | 890 } |
891 | 891 |
| 892 TitleWatcher::TitleWatcher(TabContents* tab_contents, |
| 893 const string16& expected_title) |
| 894 : expected_tab_(tab_contents), |
| 895 expected_title_(expected_title), |
| 896 title_observed_(false), |
| 897 quit_loop_on_observation_(false) { |
| 898 EXPECT_TRUE(tab_contents != NULL); |
| 899 notification_registrar_.Add(this, |
| 900 NotificationType::TAB_CONTENTS_TITLE_UPDATED, |
| 901 Source<TabContents>(tab_contents)); |
| 902 } |
| 903 |
| 904 TitleWatcher::~TitleWatcher() { |
| 905 } |
| 906 |
| 907 bool TitleWatcher::Wait() { |
| 908 if (title_observed_) |
| 909 return true; |
| 910 quit_loop_on_observation_ = true; |
| 911 ui_test_utils::RunMessageLoop(); |
| 912 return title_observed_; |
| 913 } |
| 914 |
| 915 void TitleWatcher::Observe(NotificationType type, |
| 916 const NotificationSource& source, |
| 917 const NotificationDetails& details) { |
| 918 if (type != NotificationType::TAB_CONTENTS_TITLE_UPDATED) |
| 919 return; |
| 920 |
| 921 TabContents* source_contents = Source<TabContents>(source).ptr(); |
| 922 ASSERT_EQ(expected_tab_, source_contents); |
| 923 if (source_contents->GetTitle() != expected_title_) |
| 924 return; |
| 925 |
| 926 title_observed_ = true; |
| 927 if (quit_loop_on_observation_) |
| 928 MessageLoopForUI::current()->Quit(); |
| 929 } |
| 930 |
892 DOMMessageQueue::DOMMessageQueue() { | 931 DOMMessageQueue::DOMMessageQueue() { |
893 registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE, | 932 registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE, |
894 NotificationService::AllSources()); | 933 NotificationService::AllSources()); |
895 } | 934 } |
896 | 935 |
897 DOMMessageQueue::~DOMMessageQueue() {} | 936 DOMMessageQueue::~DOMMessageQueue() {} |
898 | 937 |
899 void DOMMessageQueue::Observe(NotificationType type, | 938 void DOMMessageQueue::Observe(NotificationType type, |
900 const NotificationSource& source, | 939 const NotificationSource& source, |
901 const NotificationDetails& details) { | 940 const NotificationDetails& details) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); | 1033 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); |
995 } | 1034 } |
996 | 1035 |
997 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { | 1036 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { |
998 DCHECK(bitmap); | 1037 DCHECK(bitmap); |
999 SnapshotTaker taker; | 1038 SnapshotTaker taker; |
1000 return taker.TakeEntirePageSnapshot(rvh, bitmap); | 1039 return taker.TakeEntirePageSnapshot(rvh, bitmap); |
1001 } | 1040 } |
1002 | 1041 |
1003 } // namespace ui_test_utils | 1042 } // namespace ui_test_utils |
OLD | NEW |