Update broken references to image assets
[chromium-blink-merge.git] / content / test / test_frame_navigation_observer.h
blob6a57e48d78f9c82f86f8bf278e5aeeb06f59f58d
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 #ifndef CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_
6 #define CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_
8 #include <set>
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/test/test_utils.h"
16 class GURL;
18 namespace content {
19 class FrameTreeNode;
20 class RenderFrameHostImpl;
21 class WebContents;
22 struct LoadCommittedDetails;
24 // For content_browsertests, which run on the UI thread, run a second
25 // MessageLoop and quit when the navigation in a specific frame completes
26 // loading.
27 class TestFrameNavigationObserver : public WebContentsObserver {
28 public:
29 // Create and register a new TestFrameNavigationObserver which will track
30 // navigations performed in the specified |node| of the frame tree.
31 TestFrameNavigationObserver(FrameTreeNode* node, int number_of_navigations);
32 // As above but waits for one navigation.
33 explicit TestFrameNavigationObserver(FrameTreeNode* node);
35 ~TestFrameNavigationObserver() override;
37 // Runs a nested message loop and blocks until the expected number of
38 // navigations are complete.
39 void Wait();
41 private:
42 // WebContentsObserver
43 void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
44 const GURL& validated_url,
45 bool is_error_page,
46 bool is_iframe_srcdoc) override;
47 void DidCommitProvisionalLoadForFrame(
48 RenderFrameHost* render_frame_host,
49 const GURL& url,
50 ui::PageTransition transition_type) override;
52 // The id of the FrameTreeNode in which navigations are peformed.
53 int frame_tree_node_id_;
55 // If true the navigation has started.
56 bool navigation_started_;
58 // The number of navigations that have been completed.
59 int navigations_completed_;
61 // The number of navigations to wait for.
62 int number_of_navigations_;
64 // The MessageLoopRunner used to spin the message loop.
65 scoped_refptr<MessageLoopRunner> message_loop_runner_;
67 DISALLOW_COPY_AND_ASSIGN(TestFrameNavigationObserver);
70 } // namespace content
72 #endif // CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_