| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_TEST_FRAME_NAVIGATION_OBSERVER_H_ | 5 #ifndef CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ |
| 6 #define CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | 6 #define CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "content/public/test/browser_test_utils.h" | 11 #include "content/public/test/browser_test_utils.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 // Helper for waiting until the navigation in a specific frame tree node (and | 15 // Helper for waiting until the navigation in a specific frame tree node (and |
| 16 // all of its subframes) has completed loading. | 16 // all of its subframes) has completed loading. |
| 17 class TestFrameNavigationObserver : public WebContentsObserver { | 17 class TestFrameNavigationObserver : public WebContentsObserver { |
| 18 public: | 18 public: |
| 19 // Create and register a new TestFrameNavigationObserver which will track | 19 // Create and register a new TestFrameNavigationObserver which will track |
| 20 // navigations performed in the frame tree node associated with |adapter|. | 20 // navigations performed in the frame tree node associated with |adapter|. |
| 21 // Note that RenderFrameHost associated with |frame| might be destroyed during | 21 // Note that RenderFrameHost associated with |frame| might be destroyed during |
| 22 // the navigation (e.g. if the content commits in a new renderer process). | 22 // the navigation (e.g. if the content commits in a new renderer process). |
| 23 explicit TestFrameNavigationObserver(const ToRenderFrameHost& adapter); | 23 explicit TestFrameNavigationObserver(const ToRenderFrameHost& adapter); |
| 24 | 24 |
| 25 ~TestFrameNavigationObserver() override; | 25 ~TestFrameNavigationObserver() override; |
| 26 | 26 |
| 27 // Runs a nested message loop and blocks until the full load has | 27 // Runs a nested run loop and blocks until the full load has |
| 28 // completed. | 28 // completed. |
| 29 void Wait(); | 29 void Wait(); |
| 30 | 30 |
| 31 // Runs a nested message loop and blocks until the navigation in the | 31 // Runs a nested run loop and blocks until the navigation in the |
| 32 // associated FrameTreeNode has committed. | 32 // associated FrameTreeNode has committed. |
| 33 void WaitForCommit(); | 33 void WaitForCommit(); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 // WebContentsObserver | 36 // WebContentsObserver |
| 37 void DidStartNavigation(NavigationHandle* navigation_handle) override; | 37 void DidStartNavigation(NavigationHandle* navigation_handle) override; |
| 38 void DidFinishNavigation(NavigationHandle* navigation_handle) override; | 38 void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
| 39 void DidStopLoading() override; | 39 void DidStopLoading() override; |
| 40 | 40 |
| 41 // The id of the FrameTreeNode in which navigations are peformed. | 41 // The id of the FrameTreeNode in which navigations are peformed. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 | 53 |
| 54 // The RunLoop used to spin the message loop. | 54 // The RunLoop used to spin the message loop. |
| 55 base::RunLoop run_loop_; | 55 base::RunLoop run_loop_; |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(TestFrameNavigationObserver); | 57 DISALLOW_COPY_AND_ASSIGN(TestFrameNavigationObserver); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace content | 60 } // namespace content |
| 61 | 61 |
| 62 #endif // CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | 62 #endif // CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ |
| OLD | NEW |