| 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 "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 8 #include "content/browser/web_contents/aura/image_window_delegate.h" | 8 #include "content/browser/web_contents/aura/image_window_delegate.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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) { | 150 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) { |
| 151 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); | 151 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); |
| 152 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); | 152 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); |
| 153 | 153 |
| 154 PerformBackNavigationViaSliderCallbacks(); | 154 PerformBackNavigationViaSliderCallbacks(); |
| 155 // Screenshot was set on NavEntry at offset -1. | 155 // Screenshot was set on NavEntry at offset -1. |
| 156 EXPECT_TRUE(GetOverlay()->image_delegate_->has_image()); | 156 EXPECT_TRUE(GetOverlay()->image_delegate_->has_image()); |
| 157 EXPECT_FALSE(GetOverlay()->received_paint_update_); | 157 EXPECT_FALSE(GetOverlay()->received_paint_update_); |
| 158 | 158 |
| 159 ReceivePaintUpdate(); | 159 ReceivePaintUpdate(); |
| 160 // Paint updates until the navigation is committed represent updates | 160 // Paint updates until the navigation is committed typically represent updates |
| 161 // for the previous page, so they shouldn't affect the flag. | 161 // for the previous page, so they shouldn't affect the flag. |
| 162 EXPECT_FALSE(GetOverlay()->received_paint_update_); | 162 EXPECT_FALSE(GetOverlay()->received_paint_update_); |
| 163 | 163 |
| 164 contents()->CommitPendingNavigation(); | 164 contents()->CommitPendingNavigation(); |
| 165 ReceivePaintUpdate(); | 165 ReceivePaintUpdate(); |
| 166 // Navigation was committed and the paint update was received - the flag | 166 // Navigation was committed and the paint update was received - the flag |
| 167 // should now be updated. | 167 // should now be updated. |
| 168 EXPECT_TRUE(GetOverlay()->received_paint_update_); | 168 EXPECT_TRUE(GetOverlay()->received_paint_update_); |
| 169 | 169 |
| 170 EXPECT_FALSE(GetOverlay()->web_contents()); | 170 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_LoadingUpdate) { | 173 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_LoadingUpdate) { |
| 174 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); | 174 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); |
| 175 | 175 |
| 176 PerformBackNavigationViaSliderCallbacks(); | 176 PerformBackNavigationViaSliderCallbacks(); |
| 177 // No screenshot was set on NavEntry at offset -1. | 177 // No screenshot was set on NavEntry at offset -1. |
| 178 EXPECT_FALSE(GetOverlay()->image_delegate_->has_image()); | 178 EXPECT_FALSE(GetOverlay()->image_delegate_->has_image()); |
| 179 // Navigation was started, so the loading status flag should be reset. | 179 // Navigation was started, so the loading status flag should be reset. |
| 180 EXPECT_FALSE(GetOverlay()->loading_complete_); | 180 EXPECT_FALSE(GetOverlay()->loading_complete_); |
| 181 | 181 |
| 182 // Load updates until the navigation is committed represent updates for the | 182 // DidStopLoading for any navigation should always reset the load flag and |
| 183 // previous page, so they shouldn't affect the flag. | 183 // dismiss the overlay even if the pending navigation wasn't committed - |
| 184 // this is a "safety net" in case we mis-identify the destination webpage |
| 185 // (which can happen if a new navigation is performed while while a GestureNav |
| 186 // navigation is in progress). |
| 184 contents()->TestSetIsLoading(true); | 187 contents()->TestSetIsLoading(true); |
| 185 contents()->TestSetIsLoading(false); | 188 contents()->TestSetIsLoading(false); |
| 186 EXPECT_FALSE(GetOverlay()->loading_complete_); | |
| 187 | |
| 188 contents()->CommitPendingNavigation(); | |
| 189 contents()->TestSetIsLoading(true); | |
| 190 contents()->TestSetIsLoading(false); | |
| 191 // Navigation was committed and the load update was received - the flag | |
| 192 // should now be updated. | |
| 193 EXPECT_TRUE(GetOverlay()->loading_complete_); | 189 EXPECT_TRUE(GetOverlay()->loading_complete_); |
| 194 | 190 |
| 195 EXPECT_FALSE(GetOverlay()->web_contents()); | 191 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 196 } | 192 } |
| 197 | 193 |
| 198 } // namespace content | 194 } // namespace content |
| OLD | NEW |