[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / test / test_frame_navigation_observer.cc
blobb9404ba57709e1efacc060b26b90197416d0ccb5
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.
5 #include "content/test/test_frame_navigation_observer.h"
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"
18 namespace content {
20 TestFrameNavigationObserver::TestFrameNavigationObserver(
21 FrameTreeNode* node,
22 int number_of_navigations)
23 : WebContentsObserver(
24 node->current_frame_host()->delegate()->GetAsWebContents()),
25 frame_tree_node_id_(node->frame_tree_node_id()),
26 navigation_started_(false),
27 navigations_completed_(0),
28 number_of_navigations_(number_of_navigations),
29 message_loop_runner_(new MessageLoopRunner) {
32 TestFrameNavigationObserver::TestFrameNavigationObserver(
33 FrameTreeNode* node)
34 : WebContentsObserver(
35 node->current_frame_host()->delegate()->GetAsWebContents()),
36 frame_tree_node_id_(node->frame_tree_node_id()),
37 navigation_started_(false),
38 navigations_completed_(0),
39 number_of_navigations_(1),
40 message_loop_runner_(new MessageLoopRunner) {
43 TestFrameNavigationObserver::~TestFrameNavigationObserver() {
46 void TestFrameNavigationObserver::Wait() {
47 message_loop_runner_->Run();
50 void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame(
51 RenderFrameHost* render_frame_host,
52 const GURL& validated_url,
53 bool is_error_page,
54 bool is_iframe_srcdoc) {
55 RenderFrameHostImpl* rfh =
56 static_cast<RenderFrameHostImpl*>(render_frame_host);
57 if (rfh->frame_tree_node()->frame_tree_node_id() == frame_tree_node_id_)
58 navigation_started_ = true;
61 void TestFrameNavigationObserver::DidNavigateAnyFrame(
62 const LoadCommittedDetails& details,
63 const FrameNavigateParams& params) {
64 if (!navigation_started_)
65 return;
67 ++navigations_completed_;
68 if (navigations_completed_ == number_of_navigations_) {
69 navigation_started_ = false;
70 message_loop_runner_->Quit();
74 } // namespace content