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_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const std::string& value); | 189 const std::string& value); |
190 | 190 |
191 // Watches title changes on a WebContents, blocking until an expected title is | 191 // Watches title changes on a WebContents, blocking until an expected title is |
192 // set. | 192 // set. |
193 class TitleWatcher : public WebContentsObserver { | 193 class TitleWatcher : public WebContentsObserver { |
194 public: | 194 public: |
195 // |web_contents| must be non-NULL and needs to stay alive for the | 195 // |web_contents| must be non-NULL and needs to stay alive for the |
196 // entire lifetime of |this|. |expected_title| is the title that |this| | 196 // entire lifetime of |this|. |expected_title| is the title that |this| |
197 // will wait for. | 197 // will wait for. |
198 TitleWatcher(WebContents* web_contents, | 198 TitleWatcher(WebContents* web_contents, |
199 const string16& expected_title); | 199 const base::string16& expected_title); |
200 virtual ~TitleWatcher(); | 200 virtual ~TitleWatcher(); |
201 | 201 |
202 // Adds another title to watch for. | 202 // Adds another title to watch for. |
203 void AlsoWaitForTitle(const string16& expected_title); | 203 void AlsoWaitForTitle(const base::string16& expected_title); |
204 | 204 |
205 // Waits until the title matches either expected_title or one of the titles | 205 // Waits until the title matches either expected_title or one of the titles |
206 // added with AlsoWaitForTitle. Returns the value of the most recently | 206 // added with AlsoWaitForTitle. Returns the value of the most recently |
207 // observed matching title. | 207 // observed matching title. |
208 const string16& WaitAndGetTitle() WARN_UNUSED_RESULT; | 208 const base::string16& WaitAndGetTitle() WARN_UNUSED_RESULT; |
209 | 209 |
210 private: | 210 private: |
211 // Overridden WebContentsObserver methods. | 211 // Overridden WebContentsObserver methods. |
212 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; | 212 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; |
213 virtual void TitleWasSet(NavigationEntry* entry, bool explicit_set) OVERRIDE; | 213 virtual void TitleWasSet(NavigationEntry* entry, bool explicit_set) OVERRIDE; |
214 | 214 |
215 void TestTitle(); | 215 void TestTitle(); |
216 | 216 |
217 std::vector<string16> expected_titles_; | 217 std::vector<base::string16> expected_titles_; |
218 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 218 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
219 | 219 |
220 // The most recently observed expected title, if any. | 220 // The most recently observed expected title, if any. |
221 string16 observed_title_; | 221 base::string16 observed_title_; |
222 | 222 |
223 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); | 223 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); |
224 }; | 224 }; |
225 | 225 |
226 // Watches a WebContents and blocks until it is destroyed. | 226 // Watches a WebContents and blocks until it is destroyed. |
227 class WebContentsDestroyedWatcher : public WebContentsObserver { | 227 class WebContentsDestroyedWatcher : public WebContentsObserver { |
228 public: | 228 public: |
229 explicit WebContentsDestroyedWatcher(WebContents* web_contents); | 229 explicit WebContentsDestroyedWatcher(WebContents* web_contents); |
230 virtual ~WebContentsDestroyedWatcher(); | 230 virtual ~WebContentsDestroyedWatcher(); |
231 | 231 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 std::queue<std::string> message_queue_; | 268 std::queue<std::string> message_queue_; |
269 bool waiting_for_message_; | 269 bool waiting_for_message_; |
270 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 270 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
271 | 271 |
272 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | 272 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
273 }; | 273 }; |
274 | 274 |
275 } // namespace content | 275 } // namespace content |
276 | 276 |
277 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 277 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |