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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 a_bitmap.getSize()) == 0; 67 a_bitmap.getSize()) == 0;
68 } 68 }
69 69
70 class MockScreenshotManager : public content::NavigationEntryScreenshotManager { 70 class MockScreenshotManager : public content::NavigationEntryScreenshotManager {
71 public: 71 public:
72 explicit MockScreenshotManager(content::NavigationControllerImpl* owner) 72 explicit MockScreenshotManager(content::NavigationControllerImpl* owner)
73 : content::NavigationEntryScreenshotManager(owner), 73 : content::NavigationEntryScreenshotManager(owner),
74 encoding_screenshot_in_progress_(false) { 74 encoding_screenshot_in_progress_(false) {
75 } 75 }
76 76
77 virtual ~MockScreenshotManager() { 77 ~MockScreenshotManager() override {}
78 }
79 78
80 void TakeScreenshotFor(content::NavigationEntryImpl* entry) { 79 void TakeScreenshotFor(content::NavigationEntryImpl* entry) {
81 SkBitmap bitmap; 80 SkBitmap bitmap;
82 bitmap.allocPixels(SkImageInfo::Make( 81 bitmap.allocPixels(SkImageInfo::Make(
83 1, 1, kAlpha_8_SkColorType, kPremul_SkAlphaType)); 82 1, 1, kAlpha_8_SkColorType, kPremul_SkAlphaType));
84 bitmap.eraseARGB(0, 0, 0, 0); 83 bitmap.eraseARGB(0, 0, 0, 0);
85 encoding_screenshot_in_progress_ = true; 84 encoding_screenshot_in_progress_ = true;
86 OnScreenshotTaken(entry->GetUniqueID(), true, bitmap); 85 OnScreenshotTaken(entry->GetUniqueID(), true, bitmap);
87 WaitUntilScreenshotIsReady(); 86 WaitUntilScreenshotIsReady();
88 } 87 }
89 88
90 int GetScreenshotCount() { 89 int GetScreenshotCount() {
91 return content::NavigationEntryScreenshotManager::GetScreenshotCount(); 90 return content::NavigationEntryScreenshotManager::GetScreenshotCount();
92 } 91 }
93 92
94 void WaitUntilScreenshotIsReady() { 93 void WaitUntilScreenshotIsReady() {
95 if (!encoding_screenshot_in_progress_) 94 if (!encoding_screenshot_in_progress_)
96 return; 95 return;
97 message_loop_runner_ = new content::MessageLoopRunner; 96 message_loop_runner_ = new content::MessageLoopRunner;
98 message_loop_runner_->Run(); 97 message_loop_runner_->Run();
99 } 98 }
100 99
101 private: 100 private:
102 // Overridden from content::NavigationEntryScreenshotManager: 101 // Overridden from content::NavigationEntryScreenshotManager:
103 virtual void TakeScreenshotImpl( 102 void TakeScreenshotImpl(content::RenderViewHost* host,
104 content::RenderViewHost* host, 103 content::NavigationEntryImpl* entry) override {}
105 content::NavigationEntryImpl* entry) override {
106 }
107 104
108 virtual void OnScreenshotSet(content::NavigationEntryImpl* entry) override { 105 void OnScreenshotSet(content::NavigationEntryImpl* entry) override {
109 encoding_screenshot_in_progress_ = false; 106 encoding_screenshot_in_progress_ = false;
110 NavigationEntryScreenshotManager::OnScreenshotSet(entry); 107 NavigationEntryScreenshotManager::OnScreenshotSet(entry);
111 if (message_loop_runner_.get()) 108 if (message_loop_runner_.get())
112 message_loop_runner_->Quit(); 109 message_loop_runner_->Quit();
113 } 110 }
114 111
115 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 112 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
116 bool encoding_screenshot_in_progress_; 113 bool encoding_screenshot_in_progress_;
117 114
118 DISALLOW_COPY_AND_ASSIGN(MockScreenshotManager); 115 DISALLOW_COPY_AND_ASSIGN(MockScreenshotManager);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 186 }
190 187
191 virtual void SetUp() override { 188 virtual void SetUp() override {
192 RenderViewHostImplTestHarness::SetUp(); 189 RenderViewHostImplTestHarness::SetUp();
193 WebContents* web_contents = RenderViewHostImplTestHarness::web_contents(); 190 WebContents* web_contents = RenderViewHostImplTestHarness::web_contents();
194 ASSERT_TRUE(web_contents); // The WebContents should be created by now. 191 ASSERT_TRUE(web_contents); // The WebContents should be created by now.
195 WebContentsObserver::Observe(web_contents); 192 WebContentsObserver::Observe(web_contents);
196 } 193 }
197 194
198 // WebContentsObserver: 195 // WebContentsObserver:
199 virtual void DidStartNavigationToPendingEntry( 196 void DidStartNavigationToPendingEntry(
200 const GURL& url, 197 const GURL& url,
201 NavigationController::ReloadType reload_type) override { 198 NavigationController::ReloadType reload_type) override {
202 navigated_url_ = url; 199 navigated_url_ = url;
203 } 200 }
204 201
205 virtual void NavigationEntryCommitted( 202 void NavigationEntryCommitted(
206 const LoadCommittedDetails& load_details) override { 203 const LoadCommittedDetails& load_details) override {
207 navigation_entry_committed_counter_++; 204 navigation_entry_committed_counter_++;
208 } 205 }
209 206
210 const GURL& navigated_url() const { 207 const GURL& navigated_url() const {
211 return navigated_url_; 208 return navigated_url_;
212 } 209 }
213 210
214 NavigationControllerImpl& controller_impl() { 211 NavigationControllerImpl& controller_impl() {
215 return static_cast<NavigationControllerImpl&>(controller()); 212 return static_cast<NavigationControllerImpl&>(controller());
(...skipping 24 matching lines...) Expand all
240 237
241 int navigation_state_change_count() { 238 int navigation_state_change_count() {
242 return navigation_state_change_count_; 239 return navigation_state_change_count_;
243 } 240 }
244 241
245 int repost_form_warning_count() { 242 int repost_form_warning_count() {
246 return repost_form_warning_count_; 243 return repost_form_warning_count_;
247 } 244 }
248 245
249 // Keep track of whether the tab has notified us of a navigation state change. 246 // Keep track of whether the tab has notified us of a navigation state change.
250 virtual void NavigationStateChanged(const WebContents* source, 247 void NavigationStateChanged(const WebContents* source,
251 InvalidateTypes changed_flags) override { 248 InvalidateTypes changed_flags) override {
252 navigation_state_change_count_++; 249 navigation_state_change_count_++;
253 } 250 }
254 251
255 virtual void ShowRepostFormWarningDialog(WebContents* source) override { 252 void ShowRepostFormWarningDialog(WebContents* source) override {
256 repost_form_warning_count_++; 253 repost_form_warning_count_++;
257 } 254 }
258 255
259 private: 256 private:
260 // The number of times NavigationStateChanged has been called. 257 // The number of times NavigationStateChanged has been called.
261 int navigation_state_change_count_; 258 int navigation_state_change_count_;
262 259
263 // The number of times ShowRepostFormWarningDialog() was called. 260 // The number of times ShowRepostFormWarningDialog() was called.
264 int repost_form_warning_count_; 261 int repost_form_warning_count_;
265 }; 262 };
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 // NotificationObserver implementation used in verifying we've received the 2282 // NotificationObserver implementation used in verifying we've received the
2286 // NOTIFICATION_NAV_LIST_PRUNED method. 2283 // NOTIFICATION_NAV_LIST_PRUNED method.
2287 class PrunedListener : public NotificationObserver { 2284 class PrunedListener : public NotificationObserver {
2288 public: 2285 public:
2289 explicit PrunedListener(NavigationControllerImpl* controller) 2286 explicit PrunedListener(NavigationControllerImpl* controller)
2290 : notification_count_(0) { 2287 : notification_count_(0) {
2291 registrar_.Add(this, NOTIFICATION_NAV_LIST_PRUNED, 2288 registrar_.Add(this, NOTIFICATION_NAV_LIST_PRUNED,
2292 Source<NavigationController>(controller)); 2289 Source<NavigationController>(controller));
2293 } 2290 }
2294 2291
2295 virtual void Observe(int type, 2292 void Observe(int type,
2296 const NotificationSource& source, 2293 const NotificationSource& source,
2297 const NotificationDetails& details) override { 2294 const NotificationDetails& details) override {
2298 if (type == NOTIFICATION_NAV_LIST_PRUNED) { 2295 if (type == NOTIFICATION_NAV_LIST_PRUNED) {
2299 notification_count_++; 2296 notification_count_++;
2300 details_ = *(Details<PrunedDetails>(details).ptr()); 2297 details_ = *(Details<PrunedDetails>(details).ptr());
2301 } 2298 }
2302 } 2299 }
2303 2300
2304 // Number of times NAV_LIST_PRUNED has been observed. 2301 // Number of times NAV_LIST_PRUNED has been observed.
2305 int notification_count_; 2302 int notification_count_;
2306 2303
2307 // Details from the last NAV_LIST_PRUNED. 2304 // Details from the last NAV_LIST_PRUNED.
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 params.post_id = -1; 4351 params.post_id = -1;
4355 contents()->GetMainFrame()->SendNavigateWithParams(&params); 4352 contents()->GetMainFrame()->SendNavigateWithParams(&params);
4356 4353
4357 // Now reload. replaceState overrides the POST, so we should not show a 4354 // Now reload. replaceState overrides the POST, so we should not show a
4358 // repost warning dialog. 4355 // repost warning dialog.
4359 controller_impl().Reload(true); 4356 controller_impl().Reload(true);
4360 EXPECT_EQ(0, delegate->repost_form_warning_count()); 4357 EXPECT_EQ(0, delegate->repost_form_warning_count());
4361 } 4358 }
4362 4359
4363 } // namespace content 4360 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.h ('k') | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698