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 CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 return *details.ptr() == my_details && !testing::Test::HasFatalFailure(); | 355 return *details.ptr() == my_details && !testing::Test::HasFatalFailure(); |
356 } | 356 } |
357 | 357 |
358 // Hide a native window. | 358 // Hide a native window. |
359 void HideNativeWindow(gfx::NativeWindow window); | 359 void HideNativeWindow(gfx::NativeWindow window); |
360 | 360 |
361 // Show and focus a native window. Returns true on success. | 361 // Show and focus a native window. Returns true on success. |
362 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) WARN_UNUSED_RESULT; | 362 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) WARN_UNUSED_RESULT; |
363 | 363 |
364 // Watches for responses from the DOMAutomationController and keeps them in a | |
365 // queue. Useful for waiting for a message to be received. | |
366 class DOMMessageQueue : public content::NotificationObserver { | |
367 public: | |
368 // Constructs a DOMMessageQueue and begins listening for messages from the | |
369 // DOMAutomationController. Do not construct this until the browser has | |
370 // started. | |
371 DOMMessageQueue(); | |
372 virtual ~DOMMessageQueue(); | |
373 | |
374 // Removes all messages in the message queue. | |
375 void ClearQueue(); | |
376 | |
377 // Wait for the next message to arrive. |message| will be set to the next | |
378 // message, if not null. Returns true on success. | |
379 bool WaitForMessage(std::string* message) WARN_UNUSED_RESULT; | |
380 | |
381 // Overridden content::NotificationObserver methods. | |
382 virtual void Observe(int type, | |
383 const content::NotificationSource& source, | |
384 const content::NotificationDetails& details) OVERRIDE; | |
385 | |
386 private: | |
387 content::NotificationRegistrar registrar_; | |
388 std::queue<std::string> message_queue_; | |
389 bool waiting_for_message_; | |
390 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | |
391 | |
392 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | |
393 }; | |
394 | |
395 // Takes a snapshot of the given render widget, rendered at |page_size|. The | 364 // Takes a snapshot of the given render widget, rendered at |page_size|. The |
396 // snapshot is set to |bitmap|. Returns true on success. | 365 // snapshot is set to |bitmap|. Returns true on success. |
397 bool TakeRenderWidgetSnapshot(content::RenderWidgetHost* rwh, | 366 bool TakeRenderWidgetSnapshot(content::RenderWidgetHost* rwh, |
398 const gfx::Size& page_size, | 367 const gfx::Size& page_size, |
399 SkBitmap* bitmap) WARN_UNUSED_RESULT; | 368 SkBitmap* bitmap) WARN_UNUSED_RESULT; |
400 | 369 |
401 // Takes a snapshot of the entire page, according to the width and height | 370 // Takes a snapshot of the entire page, according to the width and height |
402 // properties of the DOM's document. Returns true on success. DOMAutomation | 371 // properties of the DOM's document. Returns true on success. DOMAutomation |
403 // must be enabled. | 372 // must be enabled. |
404 bool TakeEntirePageSnapshot(content::RenderViewHost* rvh, | 373 bool TakeEntirePageSnapshot(content::RenderViewHost* rvh, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 std::vector<GURL> urls_; | 430 std::vector<GURL> urls_; |
462 | 431 |
463 CancelableRequestConsumer consumer_; | 432 CancelableRequestConsumer consumer_; |
464 | 433 |
465 DISALLOW_COPY_AND_ASSIGN(HistoryEnumerator); | 434 DISALLOW_COPY_AND_ASSIGN(HistoryEnumerator); |
466 }; | 435 }; |
467 | 436 |
468 } // namespace ui_test_utils | 437 } // namespace ui_test_utils |
469 | 438 |
470 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 439 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
OLD | NEW |