| 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_TEST_NAVIGATION_OBSERVER_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ |
| 6 #define CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 15 #include "ui/base/page_transition_types.h" | 15 #include "ui/base/page_transition_types.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class RenderFrameHost; | 19 class RenderFrameHost; |
| 20 class WebContents; | 20 class WebContents; |
| 21 struct LoadCommittedDetails; | 21 struct LoadCommittedDetails; |
| 22 | 22 |
| 23 // For browser_tests, which run on the UI thread, run a second | 23 // For browser_tests, which run on the UI thread, run a second |
| 24 // MessageLoop and quit when the navigation completes loading. | 24 // MessageLoop and quit when the navigation completes loading. |
| 25 class TestNavigationObserver { | 25 class TestNavigationObserver { |
| 26 public: | 26 public: |
| 27 // Create and register a new TestNavigationObserver against the | 27 // Create and register a new TestNavigationObserver against the |
| 28 // |web_contents|. | 28 // |web_contents|. |
| 29 TestNavigationObserver(WebContents* web_contents, | 29 TestNavigationObserver(WebContents* web_contents, |
| 30 int number_of_navigations); | 30 int number_of_navigations, |
| 31 MessageLoopRunner::QuitMode quit_mode = |
| 32 MessageLoopRunner::QuitMode::IMMEDIATE); |
| 31 // Like above but waits for one navigation. | 33 // Like above but waits for one navigation. |
| 32 explicit TestNavigationObserver(WebContents* web_contents); | 34 explicit TestNavigationObserver(WebContents* web_contents, |
| 35 MessageLoopRunner::QuitMode quit_mode = |
| 36 MessageLoopRunner::QuitMode::IMMEDIATE); |
| 33 | 37 |
| 34 virtual ~TestNavigationObserver(); | 38 virtual ~TestNavigationObserver(); |
| 35 | 39 |
| 36 // Runs a nested message loop and blocks until the expected number of | 40 // Runs a nested message loop and blocks until the expected number of |
| 37 // navigations are complete. | 41 // navigations are complete. |
| 38 void Wait(); | 42 void Wait(); |
| 39 | 43 |
| 40 // Start/stop watching newly created WebContents. | 44 // Start/stop watching newly created WebContents. |
| 41 void StartWatchingNewWebContents(); | 45 void StartWatchingNewWebContents(); |
| 42 void StopWatchingNewWebContents(); | 46 void StopWatchingNewWebContents(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 101 |
| 98 // Living TestWebContentsObservers created by this observer. | 102 // Living TestWebContentsObservers created by this observer. |
| 99 std::set<std::unique_ptr<TestWebContentsObserver>> web_contents_observers_; | 103 std::set<std::unique_ptr<TestWebContentsObserver>> web_contents_observers_; |
| 100 | 104 |
| 101 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); | 105 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); |
| 102 }; | 106 }; |
| 103 | 107 |
| 104 } // namespace content | 108 } // namespace content |
| 105 | 109 |
| 106 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ | 110 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ |
| OLD | NEW |