| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 main_test_rfh()->PrepareForCommit(); |
| 105 if (window) { | 105 if (window) { |
| 106 EXPECT_TRUE(contents()->cross_navigation_pending()); | 106 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); |
| 107 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); | 107 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); |
| 108 } else { | 108 } else { |
| 109 EXPECT_FALSE(contents()->cross_navigation_pending()); | 109 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
| 110 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); | 110 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); |
| 111 } | 111 } |
| 112 window->SetBounds(gfx::Rect(root_window()->bounds().size())); | 112 window->SetBounds(gfx::Rect(root_window()->bounds().size())); |
| 113 GetOverlay()->OnOverscrollCompleted(window.Pass()); | 113 GetOverlay()->OnOverscrollCompleted(window.Pass()); |
| 114 } | 114 } |
| 115 | 115 |
| 116 gfx::Rect GetFrontSlideWindowBounds() { | 116 gfx::Rect GetFrontSlideWindowBounds() { |
| 117 gfx::Rect bounds = gfx::Rect(root_window()->bounds().size()); | 117 gfx::Rect bounds = gfx::Rect(root_window()->bounds().size()); |
| 118 bounds.Offset(root_window()->bounds().size().width(), 0); | 118 bounds.Offset(root_window()->bounds().size().width(), 0); |
| 119 return bounds; | 119 return bounds; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Tests that if a navigation is cancelled, no navigation is performed and the | 232 // Tests that if a navigation is cancelled, no navigation is performed and the |
| 233 // state is restored. | 233 // state is restored. |
| 234 TEST_F(OverscrollNavigationOverlayTest, CancelNavigation) { | 234 TEST_F(OverscrollNavigationOverlayTest, CancelNavigation) { |
| 235 scoped_ptr<aura::Window> window = | 235 scoped_ptr<aura::Window> window = |
| 236 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()); | 236 GetOverlay()->CreateBackWindow(GetBackSlideWindowBounds()); |
| 237 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); | 237 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); |
| 238 | 238 |
| 239 GetOverlay()->OnOverscrollCancelled(); | 239 GetOverlay()->OnOverscrollCancelled(); |
| 240 EXPECT_FALSE(contents()->cross_navigation_pending()); | 240 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
| 241 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); | 241 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Performs two navigations. The second navigation is cancelled, tests that the | 244 // Performs two navigations. The second navigation is cancelled, tests that the |
| 245 // first one worked correctly. | 245 // first one worked correctly. |
| 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()->cross_navigation_pending()); | 255 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); |
| 256 main_test_rfh()->SendNavigate( | 256 main_test_rfh()->SendNavigate( |
| 257 1, contents()->GetController().GetPendingEntry()->GetURL()); | 257 1, contents()->GetController().GetPendingEntry()->GetURL()); |
| 258 EXPECT_EQ(contents()->GetURL(), third()); | 258 EXPECT_EQ(contents()->GetURL(), third()); |
| 259 } | 259 } |
| 260 | 260 |
| 261 // Tests that an overscroll navigation that receives a paint update actually | 261 // Tests that an overscroll navigation that receives a paint update actually |
| 262 // stops observing. | 262 // stops observing. |
| 263 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { | 263 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { |
| 264 PerformBackNavigationViaSliderCallbacks(); | 264 PerformBackNavigationViaSliderCallbacks(); |
| 265 ReceivePaintUpdate(); | 265 ReceivePaintUpdate(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 EXPECT_TRUE(GetOverlay()->window_.get()); | 370 EXPECT_TRUE(GetOverlay()->window_.get()); |
| 371 | 371 |
| 372 // Load the page. | 372 // Load the page. |
| 373 contents()->CommitPendingNavigation(); | 373 contents()->CommitPendingNavigation(); |
| 374 ReceivePaintUpdate(); | 374 ReceivePaintUpdate(); |
| 375 EXPECT_FALSE(GetOverlay()->window_.get()); | 375 EXPECT_FALSE(GetOverlay()->window_.get()); |
| 376 EXPECT_EQ(contents()->GetURL(), first()); | 376 EXPECT_EQ(contents()->GetURL(), first()); |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace content | 379 } // namespace content |
| OLD | NEW |