Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc

Issue 278173005: Removing listening for repaints (OnUpdateRect) from OverscrollNavigationOverlay. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding load listening back to support in-page navigations properly. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg); 49 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg);
50 } 50 }
51 51
52 void PerformBackNavigationViaSliderCallbacks() { 52 void PerformBackNavigationViaSliderCallbacks() {
53 // Sets slide direction to SLIDE_BACK, sets screenshot from NavEntry at 53 // Sets slide direction to SLIDE_BACK, sets screenshot from NavEntry at
54 // offset -1 on layer_delegate_. 54 // offset -1 on layer_delegate_.
55 delete GetOverlay()->CreateBackLayer(); 55 delete GetOverlay()->CreateBackLayer();
56 // Performs BACK navigation, sets image from layer_delegate_ on 56 // Performs BACK navigation, sets image from layer_delegate_ on
57 // image_delegate_. 57 // image_delegate_.
58 GetOverlay()->OnWindowSlideCompleting(); 58 GetOverlay()->OnWindowSlideCompleting();
59 GetOverlay()->OnWindowSlideCompleted(); 59 GetOverlay()->OnWindowSlideCompleted(scoped_ptr<ui::Layer>());
60 } 60 }
61 61
62 protected: 62 protected:
63 // RenderViewHostImplTestHarness: 63 // RenderViewHostImplTestHarness:
64 virtual void SetUp() OVERRIDE { 64 virtual void SetUp() OVERRIDE {
65 RenderViewHostImplTestHarness::SetUp(); 65 RenderViewHostImplTestHarness::SetUp();
66 66
67 const GURL first("https://www.google.com"); 67 const GURL first("https://www.google.com");
68 contents()->NavigateAndCommit(first); 68 contents()->NavigateAndCommit(first);
69 EXPECT_TRUE(controller().GetVisibleEntry()); 69 EXPECT_TRUE(controller().GetVisibleEntry());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 private: 119 private:
120 scoped_ptr<OverscrollNavigationOverlay> overlay_; 120 scoped_ptr<OverscrollNavigationOverlay> overlay_;
121 121
122 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlayTest); 122 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlayTest);
123 }; 123 };
124 124
125 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_NoImage) { 125 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_NoImage) {
126 ReceivePaintUpdate(); 126 ReceivePaintUpdate();
127 EXPECT_TRUE(GetOverlay()->received_paint_update_); 127 EXPECT_TRUE(GetOverlay()->received_paint_update_);
128 EXPECT_FALSE(GetOverlay()->loading_complete_); 128 EXPECT_FALSE(GetOverlay()->loading_complete_);
129
130 EXPECT_TRUE(GetOverlay()->received_paint_update_);
131 EXPECT_FALSE(GetOverlay()->loading_complete_);
132 // The paint update will hide the overlay. 129 // The paint update will hide the overlay.
133 EXPECT_FALSE(GetOverlay()->web_contents()); 130 EXPECT_FALSE(GetOverlay()->web_contents());
134 } 131 }
135 132
136 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_WithImage) { 133 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_WithImage) {
137 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 134 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot());
138 135
139 ReceivePaintUpdate(); 136 ReceivePaintUpdate();
140 EXPECT_TRUE(GetOverlay()->received_paint_update_); 137 EXPECT_TRUE(GetOverlay()->received_paint_update_);
141 EXPECT_FALSE(GetOverlay()->loading_complete_); 138 EXPECT_FALSE(GetOverlay()->loading_complete_);
142 // The paint update will hide the overlay. 139 // The paint update will hide the overlay.
143 EXPECT_FALSE(GetOverlay()->web_contents()); 140 EXPECT_FALSE(GetOverlay()->web_contents());
144 } 141 }
145 142
146 TEST_F(OverscrollNavigationOverlayTest, PaintUpdateWithoutNonEmptyPaint) { 143 TEST_F(OverscrollNavigationOverlayTest, LoadUpdateWithoutNonEmptyPaint) {
147 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 144 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot());
148 process()->sink().ClearMessages(); 145 process()->sink().ClearMessages();
149 146
150 // The page load is complete, but the overlay should still be visible, because
151 // there hasn't been any paint update.
152 // This should also send a repaint request to the renderer, so that the
153 // renderer repaints the contents.
154 contents()->TestSetIsLoading(false); 147 contents()->TestSetIsLoading(false);
148 EXPECT_TRUE(GetOverlay()->loading_complete_);
155 EXPECT_FALSE(GetOverlay()->received_paint_update_); 149 EXPECT_FALSE(GetOverlay()->received_paint_update_);
156 EXPECT_TRUE(GetOverlay()->loading_complete_); 150 // The page load should hide the overlay.
157 EXPECT_TRUE(GetOverlay()->web_contents());
158 EXPECT_TRUE(process()->sink().GetFirstMessageMatching(ViewMsg_Repaint::ID));
159
160 // Receive a repaint ack update. This should hide the overlay.
161 ViewHostMsg_UpdateRect_Params params;
162 memset(&params, 0, sizeof(params));
163 params.view_size = gfx::Size(10, 10);
164 params.flags = ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
165 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params);
166 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect);
167 EXPECT_TRUE(GetOverlay()->received_paint_update_);
168 EXPECT_FALSE(GetOverlay()->web_contents()); 151 EXPECT_FALSE(GetOverlay()->web_contents());
169 } 152 }
170 153
171 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) { 154 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) {
172 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 155 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot());
173 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); 156 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1));
174 157
175 PerformBackNavigationViaSliderCallbacks(); 158 PerformBackNavigationViaSliderCallbacks();
176 // Screenshot was set on NavEntry at offset -1. 159 // Screenshot was set on NavEntry at offset -1.
177 EXPECT_TRUE(GetOverlay()->image_delegate_->has_image()); 160 EXPECT_TRUE(GetOverlay()->image_delegate_->has_image());
178 EXPECT_FALSE(GetOverlay()->received_paint_update_); 161 EXPECT_FALSE(GetOverlay()->received_paint_update_);
179 162
180 ReceivePaintUpdate(); 163 ReceivePaintUpdate();
181 // Paint updates until the navigation is committed represent updates 164 // Paint updates until the navigation is committed represent updates
182 // for the previous page, so they shouldn't affect the flag. 165 // for the previous page, so they shouldn't affect the flag.
183 EXPECT_FALSE(GetOverlay()->received_paint_update_); 166 EXPECT_FALSE(GetOverlay()->received_paint_update_);
184 167
185 contents()->CommitPendingNavigation(); 168 contents()->CommitPendingNavigation();
186 ReceivePaintUpdate(); 169 ReceivePaintUpdate();
187 // Navigation was committed and the paint update was received - the flag 170 // Navigation was committed and the paint update was received - the flag
188 // should now be updated. 171 // should now be updated.
189 EXPECT_TRUE(GetOverlay()->received_paint_update_); 172 EXPECT_TRUE(GetOverlay()->received_paint_update_);
190 173
191 EXPECT_FALSE(GetOverlay()->web_contents()); 174 EXPECT_FALSE(GetOverlay()->web_contents());
192 } 175 }
193 176
194 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_LoadingUpdate) { 177 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_LoadingUpdate) {
195 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 178 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot());
196 179
197 contents()->TestSetIsLoading(false);
198 EXPECT_TRUE(GetOverlay()->loading_complete_);
199
200 PerformBackNavigationViaSliderCallbacks(); 180 PerformBackNavigationViaSliderCallbacks();
201 // No screenshot was set on NavEntry at offset -1. 181 // No screenshot was set on NavEntry at offset -1.
202 EXPECT_FALSE(GetOverlay()->image_delegate_->has_image()); 182 EXPECT_FALSE(GetOverlay()->image_delegate_->has_image());
203 // Navigation was started, so the loading status flag should be reset. 183 // Navigation was started, so the loading status flag should be reset.
204 EXPECT_FALSE(GetOverlay()->loading_complete_); 184 EXPECT_FALSE(GetOverlay()->loading_complete_);
205 185
206 // Load updates until the navigation is committed represent updates for the 186 // Load updates until the navigation is committed represent updates for the
207 // previous page, so they shouldn't affect the flag. 187 // previous page, so they shouldn't affect the flag.
208 contents()->TestSetIsLoading(true); 188 contents()->TestSetIsLoading(true);
209 contents()->TestSetIsLoading(false); 189 contents()->TestSetIsLoading(false);
210 EXPECT_FALSE(GetOverlay()->loading_complete_); 190 EXPECT_FALSE(GetOverlay()->loading_complete_);
211 191
212 contents()->CommitPendingNavigation(); 192 contents()->CommitPendingNavigation();
213 contents()->TestSetIsLoading(true); 193 contents()->TestSetIsLoading(true);
214 contents()->TestSetIsLoading(false); 194 contents()->TestSetIsLoading(false);
215 // Navigation was committed and the load update was received - the flag 195 // Navigation was committed and the load update was received - the flag
216 // should now be updated. 196 // should now be updated.
217 EXPECT_TRUE(GetOverlay()->loading_complete_); 197 EXPECT_TRUE(GetOverlay()->loading_complete_);
218 198
219 EXPECT_TRUE(GetOverlay()->web_contents());
220 ReceivePaintUpdate();
221 EXPECT_FALSE(GetOverlay()->web_contents()); 199 EXPECT_FALSE(GetOverlay()->web_contents());
222 } 200 }
223 201
224 } // namespace content 202 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698