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

Side by Side Diff: content/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/test/test_frame_navigation_observer.h ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/test/test_frame_navigation_observer.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h"
10 #include "base/stl_util.h"
11 #include "content/browser/frame_host/navigation_entry_impl.h"
12 #include "content/browser/frame_host/render_frame_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/public/browser/web_contents_observer.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace content {
19
20 TestFrameNavigationObserver::TestFrameNavigationObserver(
21 FrameTreeNode* node)
22 : WebContentsObserver(
23 node->current_frame_host()->delegate()->GetAsWebContents()),
24 frame_tree_node_id_(node->frame_tree_node_id()),
25 navigation_started_(false),
26 has_committed_(false),
27 wait_for_commit_(false),
28 message_loop_runner_(new MessageLoopRunner) {
29 }
30
31 TestFrameNavigationObserver::~TestFrameNavigationObserver() {
32 }
33
34 void TestFrameNavigationObserver::Wait() {
35 wait_for_commit_ = false;
36 message_loop_runner_->Run();
37 }
38
39 void TestFrameNavigationObserver::WaitForCommit() {
40 if (has_committed_)
41 return;
42
43 wait_for_commit_ = true;
44 message_loop_runner_->Run();
45 }
46
47 void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame(
48 RenderFrameHost* render_frame_host,
49 const GURL& validated_url,
50 bool is_error_page,
51 bool is_iframe_srcdoc) {
52 RenderFrameHostImpl* rfh =
53 static_cast<RenderFrameHostImpl*>(render_frame_host);
54 if (rfh->frame_tree_node()->frame_tree_node_id() == frame_tree_node_id_) {
55 navigation_started_ = true;
56 has_committed_ = false;
57 }
58 }
59
60 void TestFrameNavigationObserver::DidCommitProvisionalLoadForFrame(
61 RenderFrameHost* render_frame_host,
62 const GURL& url,
63 ui::PageTransition transition_type) {
64 if (!navigation_started_)
65 return;
66
67 RenderFrameHostImpl* rfh =
68 static_cast<RenderFrameHostImpl*>(render_frame_host);
69 if (rfh->frame_tree_node()->frame_tree_node_id() != frame_tree_node_id_)
70 return;
71
72 has_committed_ = true;
73 if (wait_for_commit_)
74 message_loop_runner_->Quit();
75 }
76
77 void TestFrameNavigationObserver::DidStopLoading() {
78 if (!navigation_started_)
79 return;
80
81 navigation_started_ = false;
82 message_loop_runner_->Quit();
83 }
84
85 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_frame_navigation_observer.h ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698