OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
10 #include "chrome/common/notification_registrar.h" | 10 #include "chrome/common/notification_registrar.h" |
11 #include "webkit/glue/webpreferences.h" | 11 #include "webkit/glue/webpreferences.h" |
12 | 12 |
13 class Profile; | 13 class Profile; |
14 class TestRenderViewHost; | 14 class TestRenderViewHost; |
15 | 15 |
16 // Subclass TabContents to ensure it creates TestRenderViewHosts and does | 16 // Subclass TabContents to ensure it creates TestRenderViewHosts and does |
17 // not do anything involving views. | 17 // not do anything involving views. |
18 class TestTabContents : public TabContents { | 18 class TestTabContents : public TabContents { |
19 public: | 19 public: |
20 // The render view host factory will be passed on to the | 20 // The render view host factory will be passed on to the |
21 TestTabContents(Profile* profile, SiteInstance* instance); | 21 TestTabContents(Profile* profile, SiteInstance* instance); |
22 | 22 |
23 TestRenderViewHost* pending_rvh(); | 23 TestRenderViewHost* pending_rvh() const; |
24 | 24 |
25 // State accessor. | 25 // State accessor. |
26 bool cross_navigation_pending() { | 26 bool cross_navigation_pending() { |
27 return render_manager_.cross_navigation_pending_; | 27 return render_manager_.cross_navigation_pending_; |
28 } | 28 } |
29 | 29 |
30 // Overrides TabContents::ShouldTransitionCrossSite so that we can test both | 30 // Overrides TabContents::ShouldTransitionCrossSite so that we can test both |
31 // alternatives without using command-line switches. | 31 // alternatives without using command-line switches. |
32 bool ShouldTransitionCrossSite() { return transition_cross_site; } | 32 bool ShouldTransitionCrossSite() { return transition_cross_site; } |
33 | 33 |
(...skipping 21 matching lines...) Expand all Loading... |
55 | 55 |
56 // Returns a clone of this TestTabContents. The returned object is also a | 56 // Returns a clone of this TestTabContents. The returned object is also a |
57 // TestTabContents. The caller owns the returned object. | 57 // TestTabContents. The caller owns the returned object. |
58 virtual TabContents* Clone(); | 58 virtual TabContents* Clone(); |
59 | 59 |
60 // Creates a pending navigation to the given URL with the default parameters | 60 // Creates a pending navigation to the given URL with the default parameters |
61 // and then commits the load with a page ID one larger than any seen. This | 61 // and then commits the load with a page ID one larger than any seen. This |
62 // emulates what happens on a new navigation. | 62 // emulates what happens on a new navigation. |
63 void NavigateAndCommit(const GURL& url); | 63 void NavigateAndCommit(const GURL& url); |
64 | 64 |
| 65 // Simulates the appropriate RenderView (pending if any, current otherwise) |
| 66 // sending a navigate notification for the NavigationController pending entry. |
| 67 void CommitPendingNavigation(); |
| 68 |
| 69 // Simulates the current RVH notifying that it has unloaded so that the |
| 70 // pending RVH navigation can proceed. |
| 71 // Does nothing if no cross-navigation is pending. |
| 72 void ProceedWithCrossSiteNavigation(); |
| 73 |
65 // Set by individual tests. | 74 // Set by individual tests. |
66 bool transition_cross_site; | 75 bool transition_cross_site; |
67 | 76 |
68 NotificationRegistrar registrar_; | 77 NotificationRegistrar registrar_; |
69 }; | 78 }; |
70 | 79 |
71 #endif // CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ | 80 #endif // CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ |
OLD | NEW |