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 #ifndef CHROME_TEST_UI_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_UI_TEST_UTILS_H_ |
6 #define CHROME_TEST_UI_TEST_UTILS_H_ | 6 #define CHROME_TEST_UI_TEST_UTILS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <queue> | |
10 #include <string> | 11 #include <string> |
11 #include <set> | 12 #include <set> |
12 | 13 |
13 #include "app/keyboard_codes.h" | 14 #include "app/keyboard_codes.h" |
14 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
16 #include "base/scoped_temp_dir.h" | 17 #include "base/scoped_temp_dir.h" |
17 #include "base/string16.h" | 18 #include "base/string16.h" |
18 #include "chrome/browser/view_ids.h" | 19 #include "chrome/browser/view_ids.h" |
19 #include "chrome/common/notification_observer.h" | 20 #include "chrome/common/notification_observer.h" |
20 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
21 #include "chrome/common/notification_service.h" | 22 #include "chrome/common/notification_service.h" |
22 #include "chrome/test/automation/dom_element_proxy.h" | 23 #include "chrome/test/automation/dom_element_proxy.h" |
23 #include "gfx/native_widget_types.h" | 24 #include "gfx/native_widget_types.h" |
24 | 25 |
25 class AppModalDialog; | 26 class AppModalDialog; |
26 class BookmarkModel; | 27 class BookmarkModel; |
27 class BookmarkNode; | 28 class BookmarkNode; |
28 class Browser; | 29 class Browser; |
29 class CommandLine; | 30 class CommandLine; |
30 class DownloadManager; | 31 class DownloadManager; |
31 class ExtensionAction; | 32 class ExtensionAction; |
32 class FilePath; | 33 class FilePath; |
33 class GURL; | 34 class GURL; |
34 class MessageLoop; | 35 class MessageLoop; |
35 class NavigationController; | 36 class NavigationController; |
36 class NotificationType; | 37 class NotificationType; |
37 class Profile; | 38 class Profile; |
38 class RenderViewHost; | 39 class RenderViewHost; |
40 class RenderWidgetHost; | |
39 class ScopedTempDir; | 41 class ScopedTempDir; |
42 class SkBitmap; | |
40 class TabContents; | 43 class TabContents; |
41 class Value; | 44 class Value; |
42 | 45 |
46 namespace gfx { | |
47 class Size; | |
48 } | |
49 | |
43 // A collections of functions designed for use with InProcessBrowserTest. | 50 // A collections of functions designed for use with InProcessBrowserTest. |
44 namespace ui_test_utils { | 51 namespace ui_test_utils { |
45 | 52 |
46 // Turns on nestable tasks, runs the message loop, then resets nestable tasks | 53 // Turns on nestable tasks, runs the message loop, then resets nestable tasks |
47 // to what they were originally. Prefer this over MessageLoop::Run for in | 54 // to what they were originally. Prefer this over MessageLoop::Run for in |
48 // process browser tests that need to block until a condition is met. | 55 // process browser tests that need to block until a condition is met. |
49 void RunMessageLoop(); | 56 void RunMessageLoop(); |
50 | 57 |
51 // Turns on nestable tasks, runs all pending tasks in the message loop, | 58 // Turns on nestable tasks, runs all pending tasks in the message loop, |
52 // then resets nestable tasks to what they were originally. Prefer this | 59 // then resets nestable tasks to what they were originally. Prefer this |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 | 422 |
416 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); | 423 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); |
417 }; | 424 }; |
418 | 425 |
419 // Hide a native window. | 426 // Hide a native window. |
420 void HideNativeWindow(gfx::NativeWindow window); | 427 void HideNativeWindow(gfx::NativeWindow window); |
421 | 428 |
422 // Show and focus a native window. | 429 // Show and focus a native window. |
423 void ShowAndFocusNativeWindow(gfx::NativeWindow window); | 430 void ShowAndFocusNativeWindow(gfx::NativeWindow window); |
424 | 431 |
432 // Watches for responses from the DOMAutomationController and keeps them in a | |
433 // queue. Useful for waiting for a message to be received. | |
434 class DOMMessageQueue : public NotificationObserver { | |
435 public: | |
436 // Constructs a DOMMessageQueue and begins listening for messages from the | |
437 // DOMAutomationController. Do not construct this until the browser has | |
438 // started. | |
439 DOMMessageQueue(); | |
440 | |
441 // Wait for the next message to arrive. |message| will be set to the next | |
442 // message, if not null. Returns true on success. | |
443 bool WaitForMessage(std::string* message) WARN_UNUSED_RESULT; | |
444 | |
445 // Overridden NotificationObserver methods. | |
446 virtual void Observe(NotificationType type, | |
447 const NotificationSource& source, | |
448 const NotificationDetails& details); | |
449 | |
450 private: | |
451 NotificationRegistrar registrar_; | |
452 std::queue<std::string> message_queue_; | |
453 bool waiting_for_message_; | |
454 | |
455 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | |
456 }; | |
457 | |
458 // Takes a snapshot of the given render widget, rendered at |page_size|. The | |
459 // snapshot is set to |bitmap|. Returns true on success. | |
460 bool TakeSnapshot(RenderWidgetHost* rwh, | |
Paweł Hajdan Jr.
2010/11/11 10:33:36
nit: The name is too generic. Should it be TakeRen
kkania
2010/11/15 20:07:03
Done.
| |
461 const gfx::Size& page_size, | |
462 SkBitmap* bitmap) WARN_UNUSED_RESULT; | |
463 | |
464 // Takes a snapshot of the entire page, according to the width and height | |
465 // properties of the DOM's document. Returns true on success. DOMAutomation | |
466 // must be enabled. | |
467 bool TakeEntirePageSnapshot(RenderViewHost* rvh, | |
468 SkBitmap* bitmap) WARN_UNUSED_RESULT; | |
469 | |
425 } // namespace ui_test_utils | 470 } // namespace ui_test_utils |
426 | 471 |
427 #endif // CHROME_TEST_UI_TEST_UTILS_H_ | 472 #endif // CHROME_TEST_UI_TEST_UTILS_H_ |
OLD | NEW |