| 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(); |
| 256 main_test_rfh()->SendNavigate( | 257 main_test_rfh()->SendNavigate( |
| 257 1, contents()->GetController().GetPendingEntry()->GetURL()); | 258 0, pending->GetUniqueID(), false, pending->GetURL()); |
| 258 EXPECT_EQ(contents()->GetURL(), third()); | 259 EXPECT_EQ(contents()->GetURL(), third()); |
| 259 } | 260 } |
| 260 | 261 |
| 261 // Tests that an overscroll navigation that receives a paint update actually | 262 // Tests that an overscroll navigation that receives a paint update actually |
| 262 // stops observing. | 263 // stops observing. |
| 263 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { | 264 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { |
| 264 PerformBackNavigationViaSliderCallbacks(); | 265 PerformBackNavigationViaSliderCallbacks(); |
| 265 ReceivePaintUpdate(); | 266 ReceivePaintUpdate(); |
| 266 | 267 |
| 267 // Paint updates until the navigation is committed typically represent updates | 268 // Paint updates until the navigation is committed typically represent updates |
| 268 // for the previous page, so we should still be observing. | 269 // for the previous page, so we should still be observing. |
| 269 EXPECT_TRUE(GetOverlay()->web_contents()); | 270 EXPECT_TRUE(GetOverlay()->web_contents()); |
| 270 | 271 |
| 272 NavigationEntry* pending = contents()->GetController().GetPendingEntry(); |
| 271 main_test_rfh()->SendNavigate( | 273 main_test_rfh()->SendNavigate( |
| 272 1, contents()->GetController().GetPendingEntry()->GetURL()); | 274 0, pending->GetUniqueID(), false, pending->GetURL()); |
| 273 ReceivePaintUpdate(); | 275 ReceivePaintUpdate(); |
| 274 | 276 |
| 275 // Navigation was committed and the paint update was received - we should no | 277 // Navigation was committed and the paint update was received - we should no |
| 276 // longer be observing. | 278 // longer be observing. |
| 277 EXPECT_FALSE(GetOverlay()->web_contents()); | 279 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 278 EXPECT_EQ(contents()->GetURL(), third()); | 280 EXPECT_EQ(contents()->GetURL(), third()); |
| 279 } | 281 } |
| 280 | 282 |
| 281 // Tests that an overscroll navigation that receives a loading update actually | 283 // Tests that an overscroll navigation that receives a loading update actually |
| 282 // stops observing. | 284 // stops observing. |
| 283 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) { | 285 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) { |
| 284 PerformBackNavigationViaSliderCallbacks(); | 286 PerformBackNavigationViaSliderCallbacks(); |
| 285 EXPECT_TRUE(GetOverlay()->web_contents()); | 287 EXPECT_TRUE(GetOverlay()->web_contents()); |
| 286 // DidStopLoading for any navigation should always reset the load flag and | 288 // DidStopLoading for any navigation should always reset the load flag and |
| 287 // dismiss the overlay even if the pending navigation wasn't committed - | 289 // dismiss the overlay even if the pending navigation wasn't committed - |
| 288 // this is a "safety net" in case we mis-identify the destination webpage | 290 // this is a "safety net" in case we mis-identify the destination webpage |
| 289 // (which can happen if a new navigation is performed while while a GestureNav | 291 // (which can happen if a new navigation is performed while while a GestureNav |
| 290 // navigation is in progress). | 292 // navigation is in progress). |
| 291 contents()->TestSetIsLoading(true); | 293 contents()->TestSetIsLoading(true); |
| 292 contents()->TestSetIsLoading(false); | 294 contents()->TestSetIsLoading(false); |
| 293 EXPECT_FALSE(GetOverlay()->web_contents()); | 295 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 296 NavigationEntry* pending = contents()->GetController().GetPendingEntry(); |
| 294 main_test_rfh()->SendNavigate( | 297 main_test_rfh()->SendNavigate( |
| 295 1, contents()->GetController().GetPendingEntry()->GetURL()); | 298 0, pending->GetUniqueID(), false, pending->GetURL()); |
| 296 EXPECT_EQ(contents()->GetURL(), third()); | 299 EXPECT_EQ(contents()->GetURL(), third()); |
| 297 } | 300 } |
| 298 | 301 |
| 299 // Tests that swapping the overlay window at the end of a gesture caused by the | 302 // Tests that swapping the overlay window at the end of a gesture caused by the |
| 300 // start of a new overscroll does not crash and the events still reach the new | 303 // start of a new overscroll does not crash and the events still reach the new |
| 301 // overlay window. | 304 // overlay window. |
| 302 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) { | 305 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) { |
| 303 PerformBackNavigationViaSliderCallbacks(); | 306 PerformBackNavigationViaSliderCallbacks(); |
| 304 aura::Window* first_overlay_window = GetOverlay()->window_.get(); | 307 aura::Window* first_overlay_window = GetOverlay()->window_.get(); |
| 305 EXPECT_TRUE(GetOverlay()->web_contents()); | 308 EXPECT_TRUE(GetOverlay()->web_contents()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 EXPECT_TRUE(GetOverlay()->window_.get()); | 373 EXPECT_TRUE(GetOverlay()->window_.get()); |
| 371 | 374 |
| 372 // Load the page. | 375 // Load the page. |
| 373 contents()->CommitPendingNavigation(); | 376 contents()->CommitPendingNavigation(); |
| 374 ReceivePaintUpdate(); | 377 ReceivePaintUpdate(); |
| 375 EXPECT_FALSE(GetOverlay()->window_.get()); | 378 EXPECT_FALSE(GetOverlay()->window_.get()); |
| 376 EXPECT_EQ(contents()->GetURL(), first()); | 379 EXPECT_EQ(contents()->GetURL(), first()); |
| 377 } | 380 } |
| 378 | 381 |
| 379 } // namespace content | 382 } // namespace content |
| OLD | NEW |