| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 iter != BrowserList::end(); | 692 iter != BrowserList::end(); |
| 693 ++iter) { | 693 ++iter) { |
| 694 if (excluded_browsers.find(*iter) == excluded_browsers.end()) | 694 if (excluded_browsers.find(*iter) == excluded_browsers.end()) |
| 695 return *iter; | 695 return *iter; |
| 696 } | 696 } |
| 697 | 697 |
| 698 return NULL; | 698 return NULL; |
| 699 } | 699 } |
| 700 | 700 |
| 701 bool SendKeyPressSync(const Browser* browser, | 701 bool SendKeyPressSync(const Browser* browser, |
| 702 app::KeyboardCode key, | 702 ui::KeyboardCode key, |
| 703 bool control, | 703 bool control, |
| 704 bool shift, | 704 bool shift, |
| 705 bool alt, | 705 bool alt, |
| 706 bool command) { | 706 bool command) { |
| 707 base::TimeTicks start_time = base::TimeTicks::Now(); | 707 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 708 | 708 |
| 709 gfx::NativeWindow window = NULL; | 709 gfx::NativeWindow window = NULL; |
| 710 if (!GetNativeWindow(browser, &window)) | 710 if (!GetNativeWindow(browser, &window)) |
| 711 return false; | 711 return false; |
| 712 | 712 |
| 713 if (!ui_controls::SendKeyPressNotifyWhenDone( | 713 if (!ui_controls::SendKeyPressNotifyWhenDone( |
| 714 window, key, control, shift, alt, command, | 714 window, key, control, shift, alt, command, |
| 715 new MessageLoop::QuitTask())) { | 715 new MessageLoop::QuitTask())) { |
| 716 LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed"; | 716 LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed"; |
| 717 return false; | 717 return false; |
| 718 } | 718 } |
| 719 // Run the message loop. It'll stop running when either the key was received | 719 // Run the message loop. It'll stop running when either the key was received |
| 720 // or the test timed out (in which case testing::Test::HasFatalFailure should | 720 // or the test timed out (in which case testing::Test::HasFatalFailure should |
| 721 // be set). | 721 // be set). |
| 722 RunMessageLoop(); | 722 RunMessageLoop(); |
| 723 return !testing::Test::HasFatalFailure(); | 723 return !testing::Test::HasFatalFailure(); |
| 724 } | 724 } |
| 725 | 725 |
| 726 bool SendKeyPressAndWait(const Browser* browser, | 726 bool SendKeyPressAndWait(const Browser* browser, |
| 727 app::KeyboardCode key, | 727 ui::KeyboardCode key, |
| 728 bool control, | 728 bool control, |
| 729 bool shift, | 729 bool shift, |
| 730 bool alt, | 730 bool alt, |
| 731 bool command, | 731 bool command, |
| 732 NotificationType type, | 732 NotificationType type, |
| 733 const NotificationSource& source) { | 733 const NotificationSource& source) { |
| 734 WindowedNotificationObserver observer(type, source); | 734 WindowedNotificationObserver observer(type, source); |
| 735 | 735 |
| 736 if (!SendKeyPressSync(browser, key, control, shift, alt, command)) | 736 if (!SendKeyPressSync(browser, key, control, shift, alt, command)) |
| 737 return false; | 737 return false; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); | 1004 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { | 1007 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { |
| 1008 DCHECK(bitmap); | 1008 DCHECK(bitmap); |
| 1009 SnapshotTaker taker; | 1009 SnapshotTaker taker; |
| 1010 return taker.TakeEntirePageSnapshot(rvh, bitmap); | 1010 return taker.TakeEntirePageSnapshot(rvh, bitmap); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 } // namespace ui_test_utils | 1013 } // namespace ui_test_utils |
| OLD | NEW |