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

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

Issue 2635203002: Quit immediately in TestNavigationObserver. (Closed)
Patch Set: Add comment. 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
« no previous file with comments | « content/public/test/test_navigation_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/public/test/test_navigation_observer.h" 5 #include "content/public/test/test_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 render_frame_host, url, transition_type); 72 render_frame_host, url, transition_type);
73 } 73 }
74 74
75 TestNavigationObserver* parent_; 75 TestNavigationObserver* parent_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); 77 DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver);
78 }; 78 };
79 79
80 TestNavigationObserver::TestNavigationObserver( 80 TestNavigationObserver::TestNavigationObserver(
81 WebContents* web_contents, 81 WebContents* web_contents,
82 int number_of_navigations) 82 int number_of_navigations,
83 MessageLoopRunner::QuitMode quit_mode)
83 : navigation_started_(false), 84 : navigation_started_(false),
84 navigations_completed_(0), 85 navigations_completed_(0),
85 number_of_navigations_(number_of_navigations), 86 number_of_navigations_(number_of_navigations),
86 message_loop_runner_(new MessageLoopRunner), 87 message_loop_runner_(new MessageLoopRunner(quit_mode)),
87 web_contents_created_callback_( 88 web_contents_created_callback_(
88 base::Bind( 89 base::Bind(&TestNavigationObserver::OnWebContentsCreated,
89 &TestNavigationObserver::OnWebContentsCreated, 90 base::Unretained(this))) {
90 base::Unretained(this))) {
91 if (web_contents) 91 if (web_contents)
92 RegisterAsObserver(web_contents); 92 RegisterAsObserver(web_contents);
93 } 93 }
94 94
95 TestNavigationObserver::TestNavigationObserver( 95 TestNavigationObserver::TestNavigationObserver(
96 WebContents* web_contents) 96 WebContents* web_contents,
97 : navigation_started_(false), 97 MessageLoopRunner::QuitMode quit_mode)
98 navigations_completed_(0), 98 : TestNavigationObserver(web_contents, 1, quit_mode) {}
99 number_of_navigations_(1),
100 message_loop_runner_(new MessageLoopRunner),
101 web_contents_created_callback_(
102 base::Bind(
103 &TestNavigationObserver::OnWebContentsCreated,
104 base::Unretained(this))) {
105 if (web_contents)
106 RegisterAsObserver(web_contents);
107 }
108 99
109 TestNavigationObserver::~TestNavigationObserver() { 100 TestNavigationObserver::~TestNavigationObserver() {
110 StopWatchingNewWebContents(); 101 StopWatchingNewWebContents();
111 } 102 }
112 103
113 void TestNavigationObserver::Wait() { 104 void TestNavigationObserver::Wait() {
114 message_loop_runner_->Run(); 105 message_loop_runner_->Run();
115 } 106 }
116 107
117 void TestNavigationObserver::StartWatchingNewWebContents() { 108 void TestNavigationObserver::StartWatchingNewWebContents() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 181
191 void TestNavigationObserver::OnDidCommitProvisionalLoadForFrame( 182 void TestNavigationObserver::OnDidCommitProvisionalLoadForFrame(
192 RenderFrameHost* render_frame_host, 183 RenderFrameHost* render_frame_host,
193 const GURL& url, 184 const GURL& url,
194 ui::PageTransition transition_type) { 185 ui::PageTransition transition_type) {
195 last_navigation_url_ = url; 186 last_navigation_url_ = url;
196 last_navigation_succeeded_ = true; 187 last_navigation_succeeded_ = true;
197 } 188 }
198 189
199 } // namespace content 190 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_navigation_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698