| OLD | NEW |
| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 TEST_F(OverscrollNavigationOverlayTest, CancelAfterSuccessfulNavigation) { | 246 TEST_F(OverscrollNavigationOverlayTest, CancelAfterSuccessfulNavigation) { |
| 247 PerformBackNavigationViaSliderCallbacks(); | 247 PerformBackNavigationViaSliderCallbacks(); |
| 248 scoped_ptr<aura::Window> wrapper = | 248 scoped_ptr<aura::Window> wrapper = |
| 249 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()); | 249 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()); |
| 250 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); | 250 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); |
| 251 | 251 |
| 252 GetOverlay()->OnOverscrollCancelled(); | 252 GetOverlay()->OnOverscrollCancelled(); |
| 253 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); | 253 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); |
| 254 | 254 |
| 255 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); | 255 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); |
| 256 NavigationEntry* pending = contents()->GetController().GetPendingEntry(); | |
| 257 main_test_rfh()->SendNavigate( | 256 main_test_rfh()->SendNavigate( |
| 258 0, pending->GetUniqueID(), false, pending->GetURL()); | 257 1, contents()->GetController().GetPendingEntry()->GetURL()); |
| 259 EXPECT_EQ(contents()->GetURL(), third()); | 258 EXPECT_EQ(contents()->GetURL(), third()); |
| 260 } | 259 } |
| 261 | 260 |
| 262 // Tests that an overscroll navigation that receives a paint update actually | 261 // Tests that an overscroll navigation that receives a paint update actually |
| 263 // stops observing. | 262 // stops observing. |
| 264 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { | 263 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { |
| 265 PerformBackNavigationViaSliderCallbacks(); | 264 PerformBackNavigationViaSliderCallbacks(); |
| 266 ReceivePaintUpdate(); | 265 ReceivePaintUpdate(); |
| 267 | 266 |
| 268 // Paint updates until the navigation is committed typically represent updates | 267 // Paint updates until the navigation is committed typically represent updates |
| 269 // for the previous page, so we should still be observing. | 268 // for the previous page, so we should still be observing. |
| 270 EXPECT_TRUE(GetOverlay()->web_contents()); | 269 EXPECT_TRUE(GetOverlay()->web_contents()); |
| 271 | 270 |
| 272 NavigationEntry* pending = contents()->GetController().GetPendingEntry(); | |
| 273 main_test_rfh()->SendNavigate( | 271 main_test_rfh()->SendNavigate( |
| 274 0, pending->GetUniqueID(), false, pending->GetURL()); | 272 1, contents()->GetController().GetPendingEntry()->GetURL()); |
| 275 ReceivePaintUpdate(); | 273 ReceivePaintUpdate(); |
| 276 | 274 |
| 277 // 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 |
| 278 // longer be observing. | 276 // longer be observing. |
| 279 EXPECT_FALSE(GetOverlay()->web_contents()); | 277 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 280 EXPECT_EQ(contents()->GetURL(), third()); | 278 EXPECT_EQ(contents()->GetURL(), third()); |
| 281 } | 279 } |
| 282 | 280 |
| 283 // Tests that an overscroll navigation that receives a loading update actually | 281 // Tests that an overscroll navigation that receives a loading update actually |
| 284 // stops observing. | 282 // stops observing. |
| 285 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) { | 283 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) { |
| 286 PerformBackNavigationViaSliderCallbacks(); | 284 PerformBackNavigationViaSliderCallbacks(); |
| 287 EXPECT_TRUE(GetOverlay()->web_contents()); | 285 EXPECT_TRUE(GetOverlay()->web_contents()); |
| 288 // DidStopLoading for any navigation should always reset the load flag and | 286 // DidStopLoading for any navigation should always reset the load flag and |
| 289 // dismiss the overlay even if the pending navigation wasn't committed - | 287 // dismiss the overlay even if the pending navigation wasn't committed - |
| 290 // 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 |
| 291 // (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 |
| 292 // navigation is in progress). | 290 // navigation is in progress). |
| 293 contents()->TestSetIsLoading(true); | 291 contents()->TestSetIsLoading(true); |
| 294 contents()->TestSetIsLoading(false); | 292 contents()->TestSetIsLoading(false); |
| 295 EXPECT_FALSE(GetOverlay()->web_contents()); | 293 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 296 NavigationEntry* pending = contents()->GetController().GetPendingEntry(); | |
| 297 main_test_rfh()->SendNavigate( | 294 main_test_rfh()->SendNavigate( |
| 298 0, pending->GetUniqueID(), false, pending->GetURL()); | 295 1, contents()->GetController().GetPendingEntry()->GetURL()); |
| 299 EXPECT_EQ(contents()->GetURL(), third()); | 296 EXPECT_EQ(contents()->GetURL(), third()); |
| 300 } | 297 } |
| 301 | 298 |
| 302 // 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 |
| 303 // 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 |
| 304 // overlay window. | 301 // overlay window. |
| 305 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) { | 302 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) { |
| 306 PerformBackNavigationViaSliderCallbacks(); | 303 PerformBackNavigationViaSliderCallbacks(); |
| 307 aura::Window* first_overlay_window = GetOverlay()->window_.get(); | 304 aura::Window* first_overlay_window = GetOverlay()->window_.get(); |
| 308 EXPECT_TRUE(GetOverlay()->web_contents()); | 305 EXPECT_TRUE(GetOverlay()->web_contents()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 EXPECT_TRUE(GetOverlay()->window_.get()); | 370 EXPECT_TRUE(GetOverlay()->window_.get()); |
| 374 | 371 |
| 375 // Load the page. | 372 // Load the page. |
| 376 contents()->CommitPendingNavigation(); | 373 contents()->CommitPendingNavigation(); |
| 377 ReceivePaintUpdate(); | 374 ReceivePaintUpdate(); |
| 378 EXPECT_FALSE(GetOverlay()->window_.get()); | 375 EXPECT_FALSE(GetOverlay()->window_.get()); |
| 379 EXPECT_EQ(contents()->GetURL(), first()); | 376 EXPECT_EQ(contents()->GetURL(), first()); |
| 380 } | 377 } |
| 381 | 378 |
| 382 } // namespace content | 379 } // namespace content |
| OLD | NEW |