Chromium Code Reviews| 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 void Wait(); | 37 void Wait(); |
| 38 | 38 |
| 39 // Start/stop watching newly created WebContents. | 39 // Start/stop watching newly created WebContents. |
| 40 void StartWatchingNewWebContents(); | 40 void StartWatchingNewWebContents(); |
| 41 void StopWatchingNewWebContents(); | 41 void StopWatchingNewWebContents(); |
| 42 | 42 |
| 43 const GURL& last_navigation_url() const { return last_navigation_url_; } | 43 const GURL& last_navigation_url() const { return last_navigation_url_; } |
| 44 | 44 |
| 45 int last_navigation_succeeded() const { return last_navigation_succeeded_; } | 45 int last_navigation_succeeded() const { return last_navigation_succeeded_; } |
| 46 | 46 |
| 47 int navigations_failed() const { return navigations_failed_; } | |
| 48 | |
| 47 protected: | 49 protected: |
| 48 // Register this TestNavigationObserver as an observer of the |web_contents|. | 50 // Register this TestNavigationObserver as an observer of the |web_contents|. |
| 49 void RegisterAsObserver(WebContents* web_contents); | 51 void RegisterAsObserver(WebContents* web_contents); |
| 50 | 52 |
| 51 private: | 53 private: |
| 52 class TestWebContentsObserver; | 54 class TestWebContentsObserver; |
| 53 | 55 |
| 54 // Callbacks for WebContents-related events. | 56 // Callbacks for WebContents-related events. |
| 55 void OnWebContentsCreated(WebContents* web_contents); | 57 void OnWebContentsCreated(WebContents* web_contents); |
| 56 void OnWebContentsDestroyed(TestWebContentsObserver* observer, | 58 void OnWebContentsDestroyed(TestWebContentsObserver* observer, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 76 | 78 |
| 77 // If true the navigation has started. | 79 // If true the navigation has started. |
| 78 bool navigation_started_; | 80 bool navigation_started_; |
| 79 | 81 |
| 80 // The number of navigations that have been completed. | 82 // The number of navigations that have been completed. |
| 81 int navigations_completed_; | 83 int navigations_completed_; |
| 82 | 84 |
| 83 // The number of navigations to wait for. | 85 // The number of navigations to wait for. |
| 84 int number_of_navigations_; | 86 int number_of_navigations_; |
| 85 | 87 |
| 88 // The number of navigations that failed. | |
| 89 int navigations_failed_; | |
|
clamy
2015/04/10 14:04:49
I had to track the number of navigations that fail
Charlie Reis
2015/04/10 22:54:44
Can you check the page type of the committed Navig
clamy
2015/04/14 11:56:25
Done.
| |
| 90 | |
| 86 // The url of the navigation that last committed. | 91 // The url of the navigation that last committed. |
| 87 GURL last_navigation_url_; | 92 GURL last_navigation_url_; |
| 88 | 93 |
| 89 // True if the last navigation succeeded. | 94 // True if the last navigation succeeded. |
| 90 bool last_navigation_succeeded_; | 95 bool last_navigation_succeeded_; |
| 91 | 96 |
| 92 // The MessageLoopRunner used to spin the message loop. | 97 // The MessageLoopRunner used to spin the message loop. |
| 93 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 98 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 94 | 99 |
| 95 // Callback invoked on WebContents creation. | 100 // Callback invoked on WebContents creation. |
| 96 base::Callback<void(WebContents*)> web_contents_created_callback_; | 101 base::Callback<void(WebContents*)> web_contents_created_callback_; |
| 97 | 102 |
| 98 // Living TestWebContentsObservers created by this observer. | 103 // Living TestWebContentsObservers created by this observer. |
| 99 std::set<TestWebContentsObserver*> web_contents_observers_; | 104 std::set<TestWebContentsObserver*> web_contents_observers_; |
| 100 | 105 |
| 101 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); | 106 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); |
| 102 }; | 107 }; |
| 103 | 108 |
| 104 } // namespace content | 109 } // namespace content |
| 105 | 110 |
| 106 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ | 111 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ |
| OLD | NEW |