| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/process/process.h" | 17 #include "base/process/process.h" |
| 18 #include "base/run_loop.h" |
| 18 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 20 #include "cc/output/compositor_frame.h" | 21 #include "cc/output/compositor_frame.h" |
| 21 #include "content/public/browser/browser_message_filter.h" | 22 #include "content/public/browser/browser_message_filter.h" |
| 22 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/render_process_host_observer.h" | 25 #include "content/public/browser/render_process_host_observer.h" |
| 25 #include "content/public/browser/web_contents_delegate.h" | 26 #include "content/public/browser/web_contents_delegate.h" |
| 26 #include "content/public/browser/web_contents_observer.h" | 27 #include "content/public/browser/web_contents_observer.h" |
| 27 #include "content/public/common/page_type.h" | 28 #include "content/public/common/page_type.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 gfx::Point point); | 340 gfx::Point point); |
| 340 // | 341 // |
| 341 // Waits until the cc::Surface associated with a guest/cross-process-iframe | 342 // Waits until the cc::Surface associated with a guest/cross-process-iframe |
| 342 // has been drawn for the first time. Once this method returns it should be | 343 // has been drawn for the first time. Once this method returns it should be |
| 343 // safe to assume that events sent to the top-level RenderWidgetHostView can | 344 // safe to assume that events sent to the top-level RenderWidgetHostView can |
| 344 // be expected to properly hit-test to this surface, if appropriate. | 345 // be expected to properly hit-test to this surface, if appropriate. |
| 345 void WaitForGuestSurfaceReady(content::WebContents* web_contents); | 346 void WaitForGuestSurfaceReady(content::WebContents* web_contents); |
| 346 | 347 |
| 347 #endif | 348 #endif |
| 348 | 349 |
| 349 // Watches title changes on a WebContents, blocking until an expected title is | 350 // Watches title changes on a WebContents, blocking until a title is set. |
| 350 // set. | 351 // Can wait unitl a specific expected title appears. |
| 351 class TitleWatcher : public WebContentsObserver { | 352 class TitleWatcher : public WebContentsObserver { |
| 352 public: | 353 public: |
| 353 // |web_contents| must be non-NULL and needs to stay alive for the | 354 // |web_contents| must be non-NULL and needs to stay alive for the |
| 355 // entire lifetime of |this|. Will wait for any (non-empty) title unless |
| 356 // |AlsoWaitForTitle| is called before waiting. |
| 357 explicit TitleWatcher(WebContents* web_contents); |
| 358 |
| 359 // |web_contents| must be non-NULL and needs to stay alive for the |
| 354 // entire lifetime of |this|. |expected_title| is the title that |this| | 360 // entire lifetime of |this|. |expected_title| is the title that |this| |
| 355 // will wait for. | 361 // will wait for. |
| 356 TitleWatcher(WebContents* web_contents, | 362 TitleWatcher(WebContents* web_contents, |
| 357 const base::string16& expected_title); | 363 const base::string16& expected_title); |
| 358 ~TitleWatcher() override; | 364 ~TitleWatcher() override; |
| 359 | 365 |
| 360 // Adds another title to watch for. | 366 // Adds another title to watch for. |
| 361 void AlsoWaitForTitle(const base::string16& expected_title); | 367 void AlsoWaitForTitle(const base::string16& expected_title); |
| 362 | 368 |
| 363 // Waits until the title matches either expected_title or one of the titles | 369 // Waits until the title matches either expected_title or one of the titles |
| 364 // added with AlsoWaitForTitle. Returns the value of the most recently | 370 // added with AlsoWaitForTitle. Returns the value of the most recently |
| 365 // observed matching title. | 371 // observed matching title. |
| 366 const base::string16& WaitAndGetTitle() WARN_UNUSED_RESULT; | 372 const base::string16& WaitAndGetTitle() WARN_UNUSED_RESULT; |
| 367 | 373 |
| 368 private: | 374 private: |
| 369 // Overridden WebContentsObserver methods. | 375 // Overridden WebContentsObserver methods. |
| 370 void DidStopLoading() override; | 376 void DidStopLoading() override; |
| 371 void TitleWasSet(NavigationEntry* entry, bool explicit_set) override; | 377 void TitleWasSet(NavigationEntry* entry, bool explicit_set) override; |
| 372 | 378 |
| 373 void TestTitle(); | 379 void TestTitle(); |
| 374 | 380 |
| 375 std::vector<base::string16> expected_titles_; | 381 std::vector<base::string16> expected_titles_; |
| 376 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 382 base::RunLoop run_loop_; |
| 377 | 383 |
| 378 // The most recently observed expected title, if any. | 384 // The most recently observed expected title, if any. |
| 379 base::string16 observed_title_; | 385 base::string16 observed_title_; |
| 380 | 386 |
| 381 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); | 387 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); |
| 382 }; | 388 }; |
| 383 | 389 |
| 384 // Watches a RenderProcessHost and waits for specified destruction events. | 390 // Watches a RenderProcessHost and waits for specified destruction events. |
| 385 class RenderProcessHostWatcher : public RenderProcessHostObserver { | 391 class RenderProcessHostWatcher : public RenderProcessHostObserver { |
| 386 public: | 392 public: |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 | 761 |
| 756 private: | 762 private: |
| 757 PwnMessageHelper(); // Not instantiable. | 763 PwnMessageHelper(); // Not instantiable. |
| 758 | 764 |
| 759 DISALLOW_COPY_AND_ASSIGN(PwnMessageHelper); | 765 DISALLOW_COPY_AND_ASSIGN(PwnMessageHelper); |
| 760 }; | 766 }; |
| 761 | 767 |
| 762 } // namespace content | 768 } // namespace content |
| 763 | 769 |
| 764 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 770 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| OLD | NEW |