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

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

Issue 2630683003: Revert of Convert more test helpers to base::RunLoop, fix page title checks. (Closed)
Patch Set: 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_frame_navigation_observer.h ('k') | content/public/test/test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/public/test/test_frame_navigation_observer.h" 5 #include "content/public/test/test_frame_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 14 matching lines...) Expand all
25 25
26 } // namespace 26 } // namespace
27 27
28 TestFrameNavigationObserver::TestFrameNavigationObserver( 28 TestFrameNavigationObserver::TestFrameNavigationObserver(
29 const ToRenderFrameHost& adapter) 29 const ToRenderFrameHost& adapter)
30 : WebContentsObserver( 30 : WebContentsObserver(
31 ToRenderFrameHostImpl(adapter)->delegate()->GetAsWebContents()), 31 ToRenderFrameHostImpl(adapter)->delegate()->GetAsWebContents()),
32 frame_tree_node_id_(ToRenderFrameHostImpl(adapter)->GetFrameTreeNodeId()), 32 frame_tree_node_id_(ToRenderFrameHostImpl(adapter)->GetFrameTreeNodeId()),
33 navigation_started_(false), 33 navigation_started_(false),
34 has_committed_(false), 34 has_committed_(false),
35 wait_for_commit_(false) { 35 wait_for_commit_(false),
36 message_loop_runner_(
37 new MessageLoopRunner(MessageLoopRunner::QuitMode::IMMEDIATE)) {
36 DCHECK_CURRENTLY_ON(BrowserThread::UI); 38 DCHECK_CURRENTLY_ON(BrowserThread::UI);
37 } 39 }
38 40
39 TestFrameNavigationObserver::~TestFrameNavigationObserver() {} 41 TestFrameNavigationObserver::~TestFrameNavigationObserver() {}
40 42
41 void TestFrameNavigationObserver::Wait() { 43 void TestFrameNavigationObserver::Wait() {
42 DCHECK_CURRENTLY_ON(BrowserThread::UI); 44 DCHECK_CURRENTLY_ON(BrowserThread::UI);
43 wait_for_commit_ = false; 45 wait_for_commit_ = false;
44 run_loop_.Run(); 46 message_loop_runner_->Run();
45 } 47 }
46 48
47 void TestFrameNavigationObserver::WaitForCommit() { 49 void TestFrameNavigationObserver::WaitForCommit() {
48 DCHECK_CURRENTLY_ON(BrowserThread::UI); 50 DCHECK_CURRENTLY_ON(BrowserThread::UI);
49 51
50 if (has_committed_) 52 if (has_committed_)
51 return; 53 return;
52 54
53 wait_for_commit_ = true; 55 wait_for_commit_ = true;
54 run_loop_.Run(); 56 message_loop_runner_->Run();
55 } 57 }
56 58
57 void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame( 59 void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame(
58 RenderFrameHost* render_frame_host, 60 RenderFrameHost* render_frame_host,
59 const GURL& validated_url, 61 const GURL& validated_url,
60 bool is_error_page) { 62 bool is_error_page) {
61 RenderFrameHostImpl* rfh = 63 RenderFrameHostImpl* rfh =
62 static_cast<RenderFrameHostImpl*>(render_frame_host); 64 static_cast<RenderFrameHostImpl*>(render_frame_host);
63 if (rfh->frame_tree_node()->frame_tree_node_id() == frame_tree_node_id_) { 65 if (rfh->frame_tree_node()->frame_tree_node_id() == frame_tree_node_id_) {
64 navigation_started_ = true; 66 navigation_started_ = true;
65 has_committed_ = false; 67 has_committed_ = false;
66 } 68 }
67 } 69 }
68 70
69 void TestFrameNavigationObserver::DidCommitProvisionalLoadForFrame( 71 void TestFrameNavigationObserver::DidCommitProvisionalLoadForFrame(
70 RenderFrameHost* render_frame_host, 72 RenderFrameHost* render_frame_host,
71 const GURL& url, 73 const GURL& url,
72 ui::PageTransition transition_type) { 74 ui::PageTransition transition_type) {
73 if (!navigation_started_) 75 if (!navigation_started_)
74 return; 76 return;
75 77
76 RenderFrameHostImpl* rfh = 78 RenderFrameHostImpl* rfh =
77 static_cast<RenderFrameHostImpl*>(render_frame_host); 79 static_cast<RenderFrameHostImpl*>(render_frame_host);
78 if (rfh->frame_tree_node()->frame_tree_node_id() != frame_tree_node_id_) 80 if (rfh->frame_tree_node()->frame_tree_node_id() != frame_tree_node_id_)
79 return; 81 return;
80 82
81 has_committed_ = true; 83 has_committed_ = true;
82 if (wait_for_commit_) 84 if (wait_for_commit_)
83 run_loop_.Quit(); 85 message_loop_runner_->Quit();
84 } 86 }
85 87
86 void TestFrameNavigationObserver::DidStopLoading() { 88 void TestFrameNavigationObserver::DidStopLoading() {
87 if (!navigation_started_) 89 if (!navigation_started_)
88 return; 90 return;
89 91
90 navigation_started_ = false; 92 navigation_started_ = false;
91 run_loop_.Quit(); 93 message_loop_runner_->Quit();
92 } 94 }
93 95
94 } // namespace content 96 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_frame_navigation_observer.h ('k') | content/public/test/test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698