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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
993 SnapshotTaker taker; | 993 SnapshotTaker taker; |
994 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); | 994 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); |
995 } | 995 } |
996 | 996 |
997 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { | 997 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { |
998 DCHECK(bitmap); | 998 DCHECK(bitmap); |
999 SnapshotTaker taker; | 999 SnapshotTaker taker; |
1000 return taker.TakeEntirePageSnapshot(rvh, bitmap); | 1000 return taker.TakeEntirePageSnapshot(rvh, bitmap); |
1001 } | 1001 } |
1002 | 1002 |
1003 TitleWatcher::TitleWatcher(TabContents* tab_contents, | |
1004 const string16& expected_title) | |
1005 : expected_tab_(tab_contents), | |
1006 expected_title_(expected_title), | |
1007 title_observed_(false), | |
1008 quit_loop_on_observation_(false) { | |
1009 EXPECT_TRUE(tab_contents != NULL); | |
1010 notification_registrar_.Add(this, | |
1011 NotificationType::TAB_CONTENTS_TITLE_UPDATED, | |
1012 Source<TabContents>(tab_contents)); | |
1013 } | |
1014 | |
1015 TitleWatcher::~TitleWatcher() { | |
1016 } | |
1017 | |
1018 bool TitleWatcher::WaitForTitleChange() { | |
1019 if (title_observed_) | |
1020 return true; | |
1021 quit_loop_on_observation_ = true; | |
1022 ui_test_utils::RunMessageLoop(); | |
1023 return title_observed_; | |
1024 } | |
1025 | |
1026 void TitleWatcher::Observe(NotificationType type, | |
1027 const NotificationSource& source, | |
1028 const NotificationDetails& details) OVERRIDE { | |
1029 if (type != NotificationType::TAB_CONTENTS_TITLE_UPDATED) | |
1030 return; | |
1031 | |
1032 TabContents* source_contents = Source<TabContents>(source).ptr(); | |
1033 ASSERT_EQ(expected_tab_, source_contents); | |
1034 if (source_contents->GetTitle() != expected_title_) | |
1035 return; | |
1036 | |
1037 title_observed_ = true; | |
1038 if (quit_loop_on_observation_) | |
1039 MessageLoopForUI::current()->Quit(); | |
1040 } | |
1041 | |
Paweł Hajdan Jr.
2011/06/09 20:08:27
nit: Remove redundant empty line.
cbentzel
2011/06/10 00:41:31
Done.
| |
1042 | |
1003 } // namespace ui_test_utils | 1043 } // namespace ui_test_utils |
OLD | NEW |