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