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

Side by Side Diff: content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc

Issue 1088933003: PlzNavigate: use the right helper functions in OverscrollNavigationOverlayTests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "content/browser/web_contents/aura/overscroll_navigation_overlay.h" 5 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h"
6 6
7 #include <vector> 7 #include <vector>
8 #include "content/browser/frame_host/navigation_entry_impl.h" 8 #include "content/browser/frame_host/navigation_entry_impl.h"
9 #include "content/browser/web_contents/web_contents_view.h" 9 #include "content/browser/web_contents/web_contents_view.h"
10 #include "content/common/frame_messages.h" 10 #include "content/common/frame_messages.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 void PerformBackNavigationViaSliderCallbacks() { 96 void PerformBackNavigationViaSliderCallbacks() {
97 // Sets slide direction to BACK, sets screenshot from NavEntry at 97 // Sets slide direction to BACK, sets screenshot from NavEntry at
98 // offset -1 on layer_delegate_. 98 // offset -1 on layer_delegate_.
99 scoped_ptr<aura::Window> window( 99 scoped_ptr<aura::Window> window(
100 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds())); 100 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()));
101 // Performs BACK navigation, sets image from layer_delegate_ on 101 // Performs BACK navigation, sets image from layer_delegate_ on
102 // image_delegate_. 102 // image_delegate_.
103 GetOverlay()->OnOverscrollCompleting(); 103 GetOverlay()->OnOverscrollCompleting();
104 main_test_rfh()->PrepareForCommit();
104 if (window) { 105 if (window) {
105 EXPECT_TRUE(contents()->cross_navigation_pending()); 106 EXPECT_TRUE(contents()->cross_navigation_pending());
106 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); 107 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK);
107 } else { 108 } else {
108 EXPECT_FALSE(contents()->cross_navigation_pending()); 109 EXPECT_FALSE(contents()->cross_navigation_pending());
109 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); 110 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE);
110 } 111 }
111 window->SetBounds(gfx::Rect(root_window()->bounds().size())); 112 window->SetBounds(gfx::Rect(root_window()->bounds().size()));
112 GetOverlay()->OnOverscrollCompleted(window.Pass()); 113 GetOverlay()->OnOverscrollCompleted(window.Pass());
113 } 114 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 TEST_F(OverscrollNavigationOverlayTest, CancelAfterSuccessfulNavigation) { 246 TEST_F(OverscrollNavigationOverlayTest, CancelAfterSuccessfulNavigation) {
246 PerformBackNavigationViaSliderCallbacks(); 247 PerformBackNavigationViaSliderCallbacks();
247 scoped_ptr<aura::Window> wrapper = 248 scoped_ptr<aura::Window> wrapper =
248 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()); 249 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds());
249 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); 250 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK);
250 251
251 GetOverlay()->OnOverscrollCancelled(); 252 GetOverlay()->OnOverscrollCancelled();
252 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); 253 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE);
253 254
254 EXPECT_TRUE(contents()->cross_navigation_pending()); 255 EXPECT_TRUE(contents()->cross_navigation_pending());
255 contents()->CommitPendingNavigation(); 256 main_test_rfh()->SendNavigate(
nasko 2015/04/14 16:13:35 nit: I kinda like the CommitPendingNavigation para
257 1, contents()->GetController().GetPendingEntry()->GetURL());
256 EXPECT_EQ(contents()->GetURL(), third()); 258 EXPECT_EQ(contents()->GetURL(), third());
257 } 259 }
258 260
259 // Tests that an overscroll navigation that receives a paint update actually 261 // Tests that an overscroll navigation that receives a paint update actually
260 // stops observing. 262 // stops observing.
261 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { 263 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) {
262 PerformBackNavigationViaSliderCallbacks(); 264 PerformBackNavigationViaSliderCallbacks();
263 ReceivePaintUpdate(); 265 ReceivePaintUpdate();
264 266
265 // Paint updates until the navigation is committed typically represent updates 267 // Paint updates until the navigation is committed typically represent updates
266 // for the previous page, so we should still be observing. 268 // for the previous page, so we should still be observing.
267 EXPECT_TRUE(GetOverlay()->web_contents()); 269 EXPECT_TRUE(GetOverlay()->web_contents());
268 270
269 contents()->CommitPendingNavigation(); 271 main_test_rfh()->SendNavigate(
272 1, contents()->GetController().GetPendingEntry()->GetURL());
270 ReceivePaintUpdate(); 273 ReceivePaintUpdate();
271 274
272 // Navigation was committed and the paint update was received - we should no 275 // Navigation was committed and the paint update was received - we should no
273 // longer be observing. 276 // longer be observing.
274 EXPECT_FALSE(GetOverlay()->web_contents()); 277 EXPECT_FALSE(GetOverlay()->web_contents());
275 EXPECT_EQ(contents()->GetURL(), third()); 278 EXPECT_EQ(contents()->GetURL(), third());
276 } 279 }
277 280
278 // Tests that an overscroll navigation that receives a loading update actually 281 // Tests that an overscroll navigation that receives a loading update actually
279 // stops observing. 282 // stops observing.
280 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) { 283 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) {
281 PerformBackNavigationViaSliderCallbacks(); 284 PerformBackNavigationViaSliderCallbacks();
282 EXPECT_TRUE(GetOverlay()->web_contents()); 285 EXPECT_TRUE(GetOverlay()->web_contents());
283 // DidStopLoading for any navigation should always reset the load flag and 286 // DidStopLoading for any navigation should always reset the load flag and
284 // dismiss the overlay even if the pending navigation wasn't committed - 287 // dismiss the overlay even if the pending navigation wasn't committed -
285 // this is a "safety net" in case we mis-identify the destination webpage 288 // this is a "safety net" in case we mis-identify the destination webpage
286 // (which can happen if a new navigation is performed while while a GestureNav 289 // (which can happen if a new navigation is performed while while a GestureNav
287 // navigation is in progress). 290 // navigation is in progress).
288 contents()->TestSetIsLoading(true); 291 contents()->TestSetIsLoading(true);
289 contents()->TestSetIsLoading(false); 292 contents()->TestSetIsLoading(false);
290 EXPECT_FALSE(GetOverlay()->web_contents()); 293 EXPECT_FALSE(GetOverlay()->web_contents());
291 contents()->CommitPendingNavigation(); 294 main_test_rfh()->SendNavigate(
295 1, contents()->GetController().GetPendingEntry()->GetURL());
292 EXPECT_EQ(contents()->GetURL(), third()); 296 EXPECT_EQ(contents()->GetURL(), third());
293 } 297 }
294 298
295 // Tests that swapping the overlay window at the end of a gesture caused by the 299 // Tests that swapping the overlay window at the end of a gesture caused by the
296 // start of a new overscroll does not crash and the events still reach the new 300 // start of a new overscroll does not crash and the events still reach the new
297 // overlay window. 301 // overlay window.
298 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) { 302 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) {
299 PerformBackNavigationViaSliderCallbacks(); 303 PerformBackNavigationViaSliderCallbacks();
300 aura::Window* first_overlay_window = GetOverlay()->window_.get(); 304 aura::Window* first_overlay_window = GetOverlay()->window_.get();
301 EXPECT_TRUE(GetOverlay()->web_contents()); 305 EXPECT_TRUE(GetOverlay()->web_contents());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 EXPECT_TRUE(GetOverlay()->window_.get()); 370 EXPECT_TRUE(GetOverlay()->window_.get());
367 371
368 // Load the page. 372 // Load the page.
369 contents()->CommitPendingNavigation(); 373 contents()->CommitPendingNavigation();
370 ReceivePaintUpdate(); 374 ReceivePaintUpdate();
371 EXPECT_FALSE(GetOverlay()->window_.get()); 375 EXPECT_FALSE(GetOverlay()->window_.get());
372 EXPECT_EQ(contents()->GetURL(), first()); 376 EXPECT_EQ(contents()->GetURL(), first());
373 } 377 }
374 378
375 } // namespace content 379 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698