Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: content/public/test/test_navigation_observer.h

Issue 2635203002: Quit immediately in TestNavigationObserver. (Closed)
Patch Set: Deduplicate code. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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,
nasko 2017/01/20 22:54:45 nit: Do we need for explicit anymore, as there are
Alexander Semashko 2017/01/23 19:45:39 Constructors should be explicit as long as it is p
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698