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

Side by Side Diff: content/public/test/test_navigation_observer.h

Issue 436603002: Enable Screen Orientation integration tests for Chrome OS and Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reduce_flakiness
Patch Set: fix android Created 6 years, 4 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ 5 #ifndef CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_
6 #define CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 14
15 namespace content { 15 namespace content {
16 class WebContents; 16 class WebContents;
17 struct LoadCommittedDetails; 17 struct LoadCommittedDetails;
18 18
19 // For browser_tests, which run on the UI thread, run a second 19 // For browser_tests, which run on the UI thread, run a second
20 // MessageLoop and quit when the navigation completes loading. 20 // MessageLoop and quit when the navigation completes loading.
21 class TestNavigationObserver { 21 class TestNavigationObserver {
22 public: 22 public:
23 enum FirstPaint {
24 FirstPaintRequired,
25 FirstPaintNotRequired
26 };
27
23 // Create and register a new TestNavigationObserver against the 28 // Create and register a new TestNavigationObserver against the
24 // |web_contents|. 29 // |web_contents|.
25 TestNavigationObserver(WebContents* web_contents, 30 TestNavigationObserver(WebContents* web_contents,
31 int number_of_navigations,
32 FirstPaint first_paint);
33 // Like above but doesn't wait for the first paint after the navigations.
34 TestNavigationObserver(WebContents* web_contents,
26 int number_of_navigations); 35 int number_of_navigations);
27 // Like above but waits for one navigation. 36 // Like above but waits for one navigation.
28 explicit TestNavigationObserver(WebContents* web_contents); 37 explicit TestNavigationObserver(WebContents* web_contents);
29 38
30 virtual ~TestNavigationObserver(); 39 virtual ~TestNavigationObserver();
31 40
32 // Runs a nested message loop and blocks until the expected number of 41 // Runs a nested message loop and blocks until the expected number of
33 // navigations are complete. 42 // navigations are complete.
34 void Wait(); 43 void Wait();
35 44
45 // Runs a nested message loop and blocks until the expected
46
36 // Start/stop watching newly created WebContents. 47 // Start/stop watching newly created WebContents.
37 void StartWatchingNewWebContents(); 48 void StartWatchingNewWebContents();
38 void StopWatchingNewWebContents(); 49 void StopWatchingNewWebContents();
39 50
40 protected: 51 protected:
41 // Register this TestNavigationObserver as an observer of the |web_contents|. 52 // Register this TestNavigationObserver as an observer of the |web_contents|.
42 void RegisterAsObserver(WebContents* web_contents); 53 void RegisterAsObserver(WebContents* web_contents);
43 54
44 private: 55 private:
45 class TestWebContentsObserver; 56 class TestWebContentsObserver;
46 57
47 // Callbacks for WebContents-related events. 58 // Callbacks for WebContents-related events.
48 void OnWebContentsCreated(WebContents* web_contents); 59 void OnWebContentsCreated(WebContents* web_contents);
49 void OnWebContentsDestroyed(TestWebContentsObserver* observer, 60 void OnWebContentsDestroyed(TestWebContentsObserver* observer,
50 WebContents* web_contents); 61 WebContents* web_contents);
51 void OnNavigationEntryCommitted( 62 void OnNavigationEntryCommitted(
52 TestWebContentsObserver* observer, 63 TestWebContentsObserver* observer,
53 WebContents* web_contents, 64 WebContents* web_contents,
54 const LoadCommittedDetails& load_details); 65 const LoadCommittedDetails& load_details);
55 void OnDidAttachInterstitialPage(WebContents* web_contents); 66 void OnDidAttachInterstitialPage(WebContents* web_contents);
56 void OnDidStartLoading(WebContents* web_contents); 67 void OnDidStartLoading(WebContents* web_contents);
57 void OnDidStopLoading(WebContents* web_contents); 68 void OnDidStopLoading(WebContents* web_contents);
69 void OnDidFirstVisuallyNonEmptyPaint(WebContents* web_contents);
58 70
59 // If true the navigation has started. 71 // If true the navigation has started.
60 bool navigation_started_; 72 bool navigation_started_;
61 73
62 // The number of navigations that have been completed. 74 // The number of navigations that have been completed.
63 int navigations_completed_; 75 int navigations_completed_;
64 76
65 // The number of navigations to wait for. 77 // The number of navigations to wait for.
66 int number_of_navigations_; 78 int number_of_navigations_;
67 79
80 // Whether we want to wait for first paint after navigations.
81 FirstPaint first_paint_;
82
68 // The MessageLoopRunner used to spin the message loop. 83 // The MessageLoopRunner used to spin the message loop.
69 scoped_refptr<MessageLoopRunner> message_loop_runner_; 84 scoped_refptr<MessageLoopRunner> message_loop_runner_;
70 85
71 // Callback invoked on WebContents creation. 86 // Callback invoked on WebContents creation.
72 base::Callback<void(WebContents*)> web_contents_created_callback_; 87 base::Callback<void(WebContents*)> web_contents_created_callback_;
73 88
74 // Living TestWebContentsObservers created by this observer. 89 // Living TestWebContentsObservers created by this observer.
75 std::set<TestWebContentsObserver*> web_contents_observers_; 90 std::set<TestWebContentsObserver*> web_contents_observers_;
76 91
77 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); 92 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver);
78 }; 93 };
79 94
80 } // namespace content 95 } // namespace content
81 96
82 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ 97 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_
OLDNEW
« no previous file with comments | « content/public/test/browser_test_base.cc ('k') | content/public/test/test_navigation_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698