| 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/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
| 10 #include "content/public/browser/web_contents_view.h" | 10 #include "content/public/browser/web_contents_view.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Turn on compositing. | 77 // Turn on compositing. |
| 78 ViewHostMsg_DidActivateAcceleratedCompositing msg( | 78 ViewHostMsg_DidActivateAcceleratedCompositing msg( |
| 79 test_rvh()->GetRoutingID(), true); | 79 test_rvh()->GetRoutingID(), true); |
| 80 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg); | 80 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg); |
| 81 | 81 |
| 82 // Receive a paint update. This is necessary to make sure the size is set | 82 // Receive a paint update. This is necessary to make sure the size is set |
| 83 // correctly in RenderWidgetHostImpl. | 83 // correctly in RenderWidgetHostImpl. |
| 84 ViewHostMsg_UpdateRect_Params params; | 84 ViewHostMsg_UpdateRect_Params params; |
| 85 memset(¶ms, 0, sizeof(params)); | 85 memset(¶ms, 0, sizeof(params)); |
| 86 params.view_size = gfx::Size(10, 10); | 86 params.view_size = gfx::Size(10, 10); |
| 87 params.bitmap_rect = gfx::Rect(params.view_size); | |
| 88 params.scroll_rect = gfx::Rect(); | |
| 89 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params); | 87 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params); |
| 90 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect); | 88 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect); |
| 91 | 89 |
| 92 // Reset pending flags for size/paint. | 90 // Reset pending flags for size/paint. |
| 93 test_rvh()->ResetSizeAndRepaintPendingFlags(); | 91 test_rvh()->ResetSizeAndRepaintPendingFlags(); |
| 94 | 92 |
| 95 // Create the overlay, and set the contents of the overlay window. | 93 // Create the overlay, and set the contents of the overlay window. |
| 96 overlay_.reset(new OverscrollNavigationOverlay(contents())); | 94 overlay_.reset(new OverscrollNavigationOverlay(contents())); |
| 97 ImageWindowDelegate* image_delegate = new ImageWindowDelegate(); | 95 ImageWindowDelegate* image_delegate = new ImageWindowDelegate(); |
| 98 scoped_ptr<aura::Window> overlay_window( | 96 scoped_ptr<aura::Window> overlay_window( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 contents()->TestSetIsLoading(false); | 155 contents()->TestSetIsLoading(false); |
| 158 EXPECT_FALSE(GetOverlay()->received_paint_update_); | 156 EXPECT_FALSE(GetOverlay()->received_paint_update_); |
| 159 EXPECT_TRUE(GetOverlay()->loading_complete_); | 157 EXPECT_TRUE(GetOverlay()->loading_complete_); |
| 160 EXPECT_TRUE(GetOverlay()->web_contents()); | 158 EXPECT_TRUE(GetOverlay()->web_contents()); |
| 161 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(ViewMsg_Repaint::ID)); | 159 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(ViewMsg_Repaint::ID)); |
| 162 | 160 |
| 163 // Receive a repaint ack update. This should hide the overlay. | 161 // Receive a repaint ack update. This should hide the overlay. |
| 164 ViewHostMsg_UpdateRect_Params params; | 162 ViewHostMsg_UpdateRect_Params params; |
| 165 memset(¶ms, 0, sizeof(params)); | 163 memset(¶ms, 0, sizeof(params)); |
| 166 params.view_size = gfx::Size(10, 10); | 164 params.view_size = gfx::Size(10, 10); |
| 167 params.bitmap_rect = gfx::Rect(params.view_size); | |
| 168 params.scroll_rect = gfx::Rect(); | |
| 169 params.flags = ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; | 165 params.flags = ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; |
| 170 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params); | 166 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params); |
| 171 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect); | 167 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect); |
| 172 EXPECT_TRUE(GetOverlay()->received_paint_update_); | 168 EXPECT_TRUE(GetOverlay()->received_paint_update_); |
| 173 EXPECT_FALSE(GetOverlay()->web_contents()); | 169 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 174 } | 170 } |
| 175 | 171 |
| 176 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) { | 172 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) { |
| 177 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); | 173 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); |
| 178 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); | 174 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // Navigation was committed and the load update was received - the flag | 216 // Navigation was committed and the load update was received - the flag |
| 221 // should now be updated. | 217 // should now be updated. |
| 222 EXPECT_TRUE(GetOverlay()->loading_complete_); | 218 EXPECT_TRUE(GetOverlay()->loading_complete_); |
| 223 | 219 |
| 224 EXPECT_TRUE(GetOverlay()->web_contents()); | 220 EXPECT_TRUE(GetOverlay()->web_contents()); |
| 225 ReceivePaintUpdate(); | 221 ReceivePaintUpdate(); |
| 226 EXPECT_FALSE(GetOverlay()->web_contents()); | 222 EXPECT_FALSE(GetOverlay()->web_contents()); |
| 227 } | 223 } |
| 228 | 224 |
| 229 } // namespace content | 225 } // namespace content |
| OLD | NEW |