OLD | NEW |
---|---|
(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 #ifndef CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | |
6 #define CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | |
7 | |
8 #include <set> | |
9 | |
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" | |
15 | |
16 class GURL; | |
17 | |
18 namespace content { | |
19 class RenderFrameHostImpl; | |
20 class WebContents; | |
21 struct LoadCommittedDetails; | |
22 | |
23 // For content_browsertests, which run on the UI thread, run a second | |
24 // MessageLoop and quit when the navigation in a specific frame completes | |
25 // loading. | |
26 class TestFrameNavigationObserver : public WebContentsObserver { | |
27 public: | |
28 // Create and register a new TestFrameNavigationObserver against the | |
29 // |web_contents|. | |
Charlie Reis
2014/04/24 20:37:50
nit: There's no |web_contents| parameter.
nasko
2014/04/24 22:31:12
Done.
| |
30 TestFrameNavigationObserver(RenderFrameHostImpl* render_frame_host, | |
31 int number_of_navigations); | |
32 // Like above but waits for one navigation. | |
Charlie Reis
2014/04/24 20:37:50
nit: Like -> As
nasko
2014/04/24 22:31:12
Done.
| |
33 explicit TestFrameNavigationObserver(RenderFrameHostImpl* render_frame_host); | |
34 | |
35 virtual ~TestFrameNavigationObserver(); | |
36 | |
37 // Runs a nested message loop and blocks until the expected number of | |
38 // navigations are complete. | |
39 void Wait(); | |
40 | |
41 private: | |
42 // WebContentsObserver | |
43 virtual void DidStartProvisionalLoadForFrame( | |
44 int64 frame_id, | |
45 int64 parent_frame_id, | |
46 bool is_main_frame, | |
47 const GURL& validated_url, | |
48 bool is_error_page, | |
49 bool is_iframe_srcdoc, | |
50 RenderViewHost* render_view_host) OVERRIDE; | |
51 | |
Charlie Reis
2014/04/24 20:37:50
nit: No blank line, since this is the block of Web
nasko
2014/04/24 22:31:12
Done.
| |
52 virtual void DidNavigateAnyFrame( | |
53 const LoadCommittedDetails& details, | |
54 const FrameNavigateParams& params) OVERRIDE; | |
55 | |
56 // The RenderFrameHost to navigate. | |
57 RenderFrameHostImpl* render_frame_host_; | |
58 | |
59 // If true the navigation has started. | |
60 bool navigation_started_; | |
61 | |
62 // The number of navigations that have been completed. | |
63 int navigations_completed_; | |
64 | |
65 // The number of navigations to wait for. | |
66 int number_of_navigations_; | |
67 | |
68 // The MessageLoopRunner used to spin the message loop. | |
69 scoped_refptr<MessageLoopRunner> message_loop_runner_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(TestFrameNavigationObserver); | |
72 }; | |
73 | |
74 } // namespace content | |
75 | |
76 #endif // CONTENT_TEST_TEST_FRAME_NAVIGATION_OBSERVER_H_ | |
OLD | NEW |