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 #ifndef CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | |
9 | |
8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/public/browser/notification_details.h" | |
12 #include "content/public/browser/notification_observer.h" | |
13 #include "content/public/browser/notification_registrar.h" | |
14 #include "content/public/browser/notification_source.h" | |
9 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
10 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
11 | 17 |
12 class FilePath; | 18 class FilePath; |
13 | 19 |
14 namespace gfx { | 20 namespace gfx { |
15 class Rect; | 21 class Rect; |
16 } | 22 } |
17 | 23 |
18 // A collections of functions designed for use with content_browsertests. | 24 // A collections of functions designed for use with content_browsertests. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 68 |
63 private: | 69 private: |
64 void ShellCreated(Shell* shell); | 70 void ShellCreated(Shell* shell); |
65 | 71 |
66 Shell* shell_; | 72 Shell* shell_; |
67 scoped_refptr<MessageLoopRunner> runner_; | 73 scoped_refptr<MessageLoopRunner> runner_; |
68 | 74 |
69 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); | 75 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); |
70 }; | 76 }; |
71 | 77 |
78 // Watches for responses from the DOMAutomationController and keeps them in a | |
jam
2012/09/21 20:39:39
this is a duplicate of the same class in ui_test_u
| |
79 // queue. Useful for waiting for a message to be received. | |
80 class DOMMessageQueue : public content::NotificationObserver { | |
81 public: | |
82 // Constructs a DOMMessageQueue and begins listening for messages from the | |
83 // DOMAutomationController. Do not construct this until the browser has | |
84 // started. | |
85 DOMMessageQueue(); | |
86 virtual ~DOMMessageQueue(); | |
87 | |
88 // Removes all messages in the message queue. | |
89 void ClearQueue(); | |
90 | |
91 // Wait for the next message to arrive. |message| will be set to the next | |
92 // message, if not null. Returns true on success. | |
93 bool WaitForMessage(std::string* message) WARN_UNUSED_RESULT; | |
94 | |
95 // Overridden content::NotificationObserver methods. | |
96 virtual void Observe(int type, | |
97 const content::NotificationSource& source, | |
98 const content::NotificationDetails& details) OVERRIDE; | |
99 | |
100 private: | |
101 content::NotificationRegistrar registrar_; | |
102 std::queue<std::string> message_queue_; | |
103 bool waiting_for_message_; | |
104 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | |
105 | |
106 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | |
107 }; | |
108 | |
72 #if defined OS_MACOSX | 109 #if defined OS_MACOSX |
73 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); | 110 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); |
74 #endif | 111 #endif |
75 | 112 |
76 } // namespace content | 113 } // namespace content |
77 | 114 |
78 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 115 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
OLD | NEW |