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

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

Issue 2478583005: Browser tests for starting a drag-and-drop out of an OOPIF. (Closed)
Patch Set: Rebasing... Created 4 years, 1 month 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/test/BUILD.gn » ('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/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"
11 #include "content/browser/frame_host/navigation_entry_impl.h" 11 #include "content/browser/frame_host/navigation_entry_impl.h"
12 #include "content/browser/frame_host/render_frame_host_impl.h" 12 #include "content/browser/frame_host/render_frame_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 14 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 namespace {
21
22 RenderFrameHostImpl* ToRenderFrameHostImpl(const ToRenderFrameHost& frame) {
23 return static_cast<RenderFrameHostImpl*>(frame.render_frame_host());
24 }
25
26 } // namespace
27
20 TestFrameNavigationObserver::TestFrameNavigationObserver( 28 TestFrameNavigationObserver::TestFrameNavigationObserver(
21 FrameTreeNode* node) 29 const ToRenderFrameHost& adapter)
22 : WebContentsObserver( 30 : WebContentsObserver(
23 node->current_frame_host()->delegate()->GetAsWebContents()), 31 ToRenderFrameHostImpl(adapter)->delegate()->GetAsWebContents()),
24 frame_tree_node_id_(node->frame_tree_node_id()), 32 frame_tree_node_id_(ToRenderFrameHostImpl(adapter)->GetFrameTreeNodeId()),
25 navigation_started_(false), 33 navigation_started_(false),
26 has_committed_(false), 34 has_committed_(false),
27 wait_for_commit_(false), 35 wait_for_commit_(false),
28 message_loop_runner_(new MessageLoopRunner) { 36 message_loop_runner_(new MessageLoopRunner) {
37 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 } 38 }
30 39
31 TestFrameNavigationObserver::~TestFrameNavigationObserver() { 40 TestFrameNavigationObserver::~TestFrameNavigationObserver() {}
32 }
33 41
34 void TestFrameNavigationObserver::Wait() { 42 void TestFrameNavigationObserver::Wait() {
43 DCHECK_CURRENTLY_ON(BrowserThread::UI);
35 wait_for_commit_ = false; 44 wait_for_commit_ = false;
36 message_loop_runner_->Run(); 45 message_loop_runner_->Run();
37 } 46 }
38 47
39 void TestFrameNavigationObserver::WaitForCommit() { 48 void TestFrameNavigationObserver::WaitForCommit() {
49 DCHECK_CURRENTLY_ON(BrowserThread::UI);
50
40 if (has_committed_) 51 if (has_committed_)
41 return; 52 return;
42 53
43 wait_for_commit_ = true; 54 wait_for_commit_ = true;
44 message_loop_runner_->Run(); 55 message_loop_runner_->Run();
45 } 56 }
46 57
47 void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame( 58 void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame(
48 RenderFrameHost* render_frame_host, 59 RenderFrameHost* render_frame_host,
49 const GURL& validated_url, 60 const GURL& validated_url,
(...skipping 26 matching lines...) Expand all
76 87
77 void TestFrameNavigationObserver::DidStopLoading() { 88 void TestFrameNavigationObserver::DidStopLoading() {
78 if (!navigation_started_) 89 if (!navigation_started_)
79 return; 90 return;
80 91
81 navigation_started_ = false; 92 navigation_started_ = false;
82 message_loop_runner_->Quit(); 93 message_loop_runner_->Quit();
83 } 94 }
84 95
85 } // namespace content 96 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_frame_navigation_observer.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698