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 "content/browser/frame_host/navigation_entry_impl.h" | 8 #include "content/browser/frame_host/navigation_entry_impl.h" |
8 #include "content/browser/web_contents/web_contents_view.h" | 9 #include "content/browser/web_contents/web_contents_view.h" |
9 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
10 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
12 #include "content/public/browser/overscroll_configuration.h" | |
11 #include "content/public/test/mock_render_process_host.h" | 13 #include "content/public/test/mock_render_process_host.h" |
12 #include "content/test/test_render_frame_host.h" | 14 #include "content/test/test_render_frame_host.h" |
13 #include "content/test/test_render_view_host.h" | 15 #include "content/test/test_render_view_host.h" |
14 #include "content/test/test_web_contents.h" | 16 #include "content/test/test_web_contents.h" |
15 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
16 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
17 #include "ui/aura_extra/image_window_delegate.h" | 19 #include "ui/aura_extra/image_window_delegate.h" |
20 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | |
21 #include "ui/compositor/scoped_layer_animation_settings.h" | |
22 #include "ui/compositor/test/layer_animator_test_controller.h" | |
23 #include "ui/events/gesture_detection/gesture_configuration.h" | |
24 #include "ui/events/test/event_generator.h" | |
18 #include "ui/gfx/codec/png_codec.h" | 25 #include "ui/gfx/codec/png_codec.h" |
26 #include "ui/gfx/frame_time.h" | |
19 | 27 |
20 namespace content { | 28 namespace content { |
21 | 29 |
30 // A subclass of TestWebContents that offers a fake content window. | |
31 class OverscrollTestWebContents : public TestWebContents { | |
32 public: | |
33 ~OverscrollTestWebContents() override {} | |
34 | |
35 static OverscrollTestWebContents* Create( | |
36 BrowserContext* browser_context, | |
37 SiteInstance* instance, | |
38 scoped_ptr<aura::Window> fake_native_view, | |
39 scoped_ptr<aura::Window> fake_contents_window) { | |
40 OverscrollTestWebContents* web_contents = new OverscrollTestWebContents( | |
41 browser_context, fake_native_view.Pass(), fake_contents_window.Pass()); | |
42 web_contents->Init(WebContents::CreateParams(browser_context, instance)); | |
43 web_contents->RenderFrameCreated(web_contents->GetMainFrame()); | |
44 return web_contents; | |
45 } | |
46 | |
47 gfx::NativeView GetNativeView() override { return fake_native_view_.get(); } | |
48 | |
49 gfx::NativeView GetContentNativeView() override { | |
50 return fake_contents_window_.get(); | |
51 } | |
52 | |
53 protected: | |
54 explicit OverscrollTestWebContents( | |
55 BrowserContext* browser_context, | |
56 scoped_ptr<aura::Window> fake_native_view, | |
57 scoped_ptr<aura::Window> fake_contents_window) | |
58 : TestWebContents(browser_context), | |
59 fake_native_view_(fake_native_view.Pass()), | |
60 fake_contents_window_(fake_contents_window.Pass()) {} | |
61 | |
62 private: | |
63 scoped_ptr<aura::Window> fake_native_view_; | |
64 scoped_ptr<aura::Window> fake_contents_window_; | |
65 }; | |
66 | |
22 class OverscrollNavigationOverlayTest : public RenderViewHostImplTestHarness { | 67 class OverscrollNavigationOverlayTest : public RenderViewHostImplTestHarness { |
23 public: | 68 public: |
24 OverscrollNavigationOverlayTest() {} | 69 OverscrollNavigationOverlayTest() |
70 : first_("https://www.google.com"), | |
71 second_("http://www.chromium.org"), | |
72 third_("https://www.kernel.org/"), | |
73 fourth_("https://github.com/") {} | |
74 | |
25 ~OverscrollNavigationOverlayTest() override {} | 75 ~OverscrollNavigationOverlayTest() override {} |
26 | 76 |
27 gfx::Image CreateDummyScreenshot() { | |
28 SkBitmap bitmap; | |
29 bitmap.allocN32Pixels(1, 1); | |
30 bitmap.eraseColor(SK_ColorWHITE); | |
31 return gfx::Image::CreateFrom1xBitmap(bitmap); | |
32 } | |
33 | |
34 void SetDummyScreenshotOnNavEntry(NavigationEntry* entry) { | 77 void SetDummyScreenshotOnNavEntry(NavigationEntry* entry) { |
35 SkBitmap bitmap; | 78 SkBitmap bitmap; |
36 bitmap.allocN32Pixels(1, 1); | 79 bitmap.allocN32Pixels(1, 1); |
37 bitmap.eraseColor(SK_ColorWHITE); | 80 bitmap.eraseColor(SK_ColorWHITE); |
38 std::vector<unsigned char> png_data; | 81 std::vector<unsigned char> png_data; |
39 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data); | 82 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data); |
40 scoped_refptr<base::RefCountedBytes> png_bytes = | 83 scoped_refptr<base::RefCountedBytes> png_bytes = |
41 base::RefCountedBytes::TakeVector(&png_data); | 84 base::RefCountedBytes::TakeVector(&png_data); |
42 NavigationEntryImpl* entry_impl = | 85 NavigationEntryImpl* entry_impl = |
43 NavigationEntryImpl::FromNavigationEntry(entry); | 86 NavigationEntryImpl::FromNavigationEntry(entry); |
44 entry_impl->SetScreenshotPNGData(png_bytes); | 87 entry_impl->SetScreenshotPNGData(png_bytes); |
45 } | 88 } |
46 | 89 |
47 void ReceivePaintUpdate() { | 90 void ReceivePaintUpdate() { |
48 FrameHostMsg_DidFirstVisuallyNonEmptyPaint msg( | 91 FrameHostMsg_DidFirstVisuallyNonEmptyPaint msg( |
49 main_test_rfh()->GetRoutingID()); | 92 main_test_rfh()->GetRoutingID()); |
50 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg); | 93 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg); |
51 } | 94 } |
52 | 95 |
53 void PerformBackNavigationViaSliderCallbacks() { | 96 void PerformBackNavigationViaSliderCallbacks() { |
54 // Sets slide direction to SLIDE_BACK, sets screenshot from NavEntry at | 97 // Sets slide direction to BACK, sets screenshot from NavEntry at |
55 // offset -1 on layer_delegate_. | 98 // offset -1 on layer_delegate_. |
56 delete GetOverlay()->CreateBackLayer(); | 99 scoped_ptr<aura::Window> window(GetOverlay()->CreateBackWindow()); |
57 // Performs BACK navigation, sets image from layer_delegate_ on | 100 // Performs BACK navigation, sets image from layer_delegate_ on |
58 // image_delegate_. | 101 // image_delegate_. |
59 GetOverlay()->OnWindowSlideCompleting(); | 102 GetOverlay()->OnOverscrollCompleting(); |
60 GetOverlay()->OnWindowSlideCompleted(scoped_ptr<ui::Layer>()); | 103 if (window) { |
mfomitchev
2015/04/02 22:50:37
Can we add checks for !window case as well?
Nina
2015/04/07 14:02:08
Done.
| |
104 EXPECT_TRUE(contents()->cross_navigation_pending()); | |
105 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); | |
106 } | |
107 window->SetBounds(gfx::Rect(root_window()->bounds().size())); | |
108 GetOverlay()->OnOverscrollCompleted(window.Pass()); | |
61 } | 109 } |
62 | 110 |
111 // Tests URLs. | |
112 const GURL first_; | |
113 const GURL second_; | |
114 const GURL third_; | |
115 const GURL fourth_; | |
116 | |
63 protected: | 117 protected: |
64 // RenderViewHostImplTestHarness: | 118 // RenderViewHostImplTestHarness: |
65 void SetUp() override { | 119 void SetUp() override { |
66 RenderViewHostImplTestHarness::SetUp(); | 120 RenderViewHostImplTestHarness::SetUp(); |
67 | 121 |
68 const GURL first("https://www.google.com"); | 122 // Set up the fake web contents native view. |
69 contents()->NavigateAndCommit(first); | 123 scoped_ptr<aura::Window> fake_native_view(new aura::Window(nullptr)); |
124 fake_native_view->Init(aura::WINDOW_LAYER_SOLID_COLOR); | |
125 root_window()->AddChild(fake_native_view.get()); | |
126 fake_native_view->SetBounds(gfx::Rect(root_window()->bounds().size())); | |
127 | |
128 // Set up the fake contents window. | |
129 scoped_ptr<aura::Window> fake_contents_window(new aura::Window(nullptr)); | |
130 fake_contents_window->Init(aura::WINDOW_LAYER_SOLID_COLOR); | |
131 root_window()->AddChild(fake_contents_window.get()); | |
132 fake_contents_window->SetBounds(gfx::Rect(root_window()->bounds().size())); | |
133 | |
134 // Replace the default test web contents with our custom class. | |
135 SetContents(OverscrollTestWebContents::Create( | |
136 browser_context(), SiteInstance::Create(browser_context()), | |
mfomitchev
2015/04/02 22:50:37
Nit: I am surprised git cl format did this. I thou
Nina
2015/04/07 14:02:08
Done.
| |
137 fake_native_view.Pass(), fake_contents_window.Pass())); | |
138 | |
139 contents()->NavigateAndCommit(first_); | |
70 EXPECT_TRUE(controller().GetVisibleEntry()); | 140 EXPECT_TRUE(controller().GetVisibleEntry()); |
71 EXPECT_FALSE(controller().CanGoBack()); | 141 EXPECT_FALSE(controller().CanGoBack()); |
72 | 142 |
73 const GURL second("http://www.chromium.org"); | 143 contents()->NavigateAndCommit(second_); |
74 contents()->NavigateAndCommit(second); | |
75 EXPECT_TRUE(controller().CanGoBack()); | 144 EXPECT_TRUE(controller().CanGoBack()); |
76 | 145 |
146 contents()->NavigateAndCommit(third_); | |
147 EXPECT_TRUE(controller().CanGoBack()); | |
148 | |
149 contents()->NavigateAndCommit(fourth_); | |
150 EXPECT_TRUE(controller().CanGoBack()); | |
151 EXPECT_FALSE(controller().CanGoForward()); | |
152 | |
77 // Receive a paint update. This is necessary to make sure the size is set | 153 // Receive a paint update. This is necessary to make sure the size is set |
78 // correctly in RenderWidgetHostImpl. | 154 // correctly in RenderWidgetHostImpl. |
79 ViewHostMsg_UpdateRect_Params params; | 155 ViewHostMsg_UpdateRect_Params params; |
80 memset(¶ms, 0, sizeof(params)); | 156 memset(¶ms, 0, sizeof(params)); |
81 params.view_size = gfx::Size(10, 10); | 157 params.view_size = gfx::Size(10, 10); |
82 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params); | 158 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params); |
83 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect); | 159 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect); |
84 | 160 |
85 // Reset pending flags for size/paint. | 161 // Reset pending flags for size/paint. |
86 test_rvh()->ResetSizeAndRepaintPendingFlags(); | 162 test_rvh()->ResetSizeAndRepaintPendingFlags(); |
87 | 163 |
88 // Create the overlay, and set the contents of the overlay window. | 164 // Create the overlay, and set the contents of the overlay window. |
89 overlay_.reset(new OverscrollNavigationOverlay(contents())); | 165 overlay_.reset(new OverscrollNavigationOverlay(contents(), root_window())); |
90 aura_extra::ImageWindowDelegate* image_delegate = | |
91 new aura_extra::ImageWindowDelegate(); | |
92 scoped_ptr<aura::Window> overlay_window( | |
93 aura::test::CreateTestWindowWithDelegate( | |
94 image_delegate, | |
95 0, | |
96 gfx::Rect(root_window()->bounds().size()), | |
97 root_window())); | |
98 | |
99 overlay_->SetOverlayWindow(overlay_window.Pass(), image_delegate); | |
100 overlay_->StartObserving(); | |
101 | |
102 EXPECT_TRUE(overlay_->web_contents()); | |
103 EXPECT_FALSE(overlay_->loading_complete_); | |
104 EXPECT_FALSE(overlay_->received_paint_update_); | |
105 } | 166 } |
106 | 167 |
107 void TearDown() override { | 168 void TearDown() override { |
108 overlay_.reset(); | 169 overlay_.reset(); |
109 RenderViewHostImplTestHarness::TearDown(); | 170 RenderViewHostImplTestHarness::TearDown(); |
110 } | 171 } |
111 | 172 |
112 OverscrollNavigationOverlay* GetOverlay() { | 173 OverscrollNavigationOverlay* GetOverlay() { |
113 return overlay_.get(); | 174 return overlay_.get(); |
114 } | 175 } |
115 | 176 |
116 private: | 177 private: |
117 scoped_ptr<OverscrollNavigationOverlay> overlay_; | 178 scoped_ptr<OverscrollNavigationOverlay> overlay_; |
118 | 179 |
119 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlayTest); | 180 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlayTest); |
120 }; | 181 }; |
121 | 182 |
122 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_NoImage) { | 183 // Tests that if a screenshot is available, it is set in the overlay window |
123 ReceivePaintUpdate(); | 184 // delegate. |
124 EXPECT_TRUE(GetOverlay()->received_paint_update_); | 185 TEST_F(OverscrollNavigationOverlayTest, WithScreenshot) { |
125 EXPECT_FALSE(GetOverlay()->loading_complete_); | 186 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); |
126 // The paint update will hide the overlay. | 187 PerformBackNavigationViaSliderCallbacks(); |
127 EXPECT_FALSE(GetOverlay()->web_contents()); | 188 // Screenshot was set on NavEntry at offset -1. |
189 EXPECT_TRUE(static_cast<aura_extra::ImageWindowDelegate*>( | |
190 GetOverlay()->window_->delegate())->has_image()); | |
128 } | 191 } |
129 | 192 |
130 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_WithImage) { | 193 // Tests that if a screenshot is not available, no image is set in the overlay |
131 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); | 194 // window delegate. |
132 | 195 TEST_F(OverscrollNavigationOverlayTest, WithoutScreenshot) { |
133 ReceivePaintUpdate(); | 196 PerformBackNavigationViaSliderCallbacks(); |
134 EXPECT_TRUE(GetOverlay()->received_paint_update_); | 197 // No screenshot was set on NavEntry at offset -1. |
135 EXPECT_FALSE(GetOverlay()->loading_complete_); | 198 EXPECT_FALSE(static_cast<aura_extra::ImageWindowDelegate*>( |
136 // The paint update will hide the overlay. | 199 GetOverlay()->window_->delegate())->has_image()); |
137 EXPECT_FALSE(GetOverlay()->web_contents()); | |
138 } | 200 } |
139 | 201 |
140 TEST_F(OverscrollNavigationOverlayTest, LoadUpdateWithoutNonEmptyPaint) { | 202 // Tests that if a navigation is attempted but there is nothing to navigate to, |
141 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); | 203 // we return a null window. |
142 process()->sink().ClearMessages(); | 204 TEST_F(OverscrollNavigationOverlayTest, CannotNavigate) { |
143 | 205 EXPECT_EQ(GetOverlay()->CreateFrontWindow(), nullptr); |
144 contents()->TestSetIsLoading(false); | |
145 EXPECT_TRUE(GetOverlay()->loading_complete_); | |
146 EXPECT_FALSE(GetOverlay()->received_paint_update_); | |
147 // The page load should hide the overlay. | |
148 EXPECT_FALSE(GetOverlay()->web_contents()); | |
149 } | 206 } |
150 | 207 |
151 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) { | 208 // Tests that if a navigation is cancelled, no navigation is performed and the |
152 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); | 209 // state is restored. |
153 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); | 210 TEST_F(OverscrollNavigationOverlayTest, CancelNavigation) { |
211 scoped_ptr<aura::Window> window = GetOverlay()->CreateBackWindow(); | |
212 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); | |
154 | 213 |
214 GetOverlay()->OnOverscrollCancelled(); | |
215 EXPECT_FALSE(contents()->cross_navigation_pending()); | |
216 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); | |
217 } | |
218 | |
219 // Performs two navigations. The second navigation is cancelled, tests that the | |
220 // first one worked correctly. | |
221 TEST_F(OverscrollNavigationOverlayTest, CancelAfterSuccessfulNavigation) { | |
155 PerformBackNavigationViaSliderCallbacks(); | 222 PerformBackNavigationViaSliderCallbacks(); |
156 // Screenshot was set on NavEntry at offset -1. | 223 scoped_ptr<aura::Window> wrapper = GetOverlay()->CreateBackWindow(); |
157 EXPECT_TRUE(GetOverlay()->image_delegate_->has_image()); | 224 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::BACK); |
158 EXPECT_FALSE(GetOverlay()->received_paint_update_); | |
159 | 225 |
226 GetOverlay()->OnOverscrollCancelled(); | |
227 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE); | |
228 | |
229 EXPECT_TRUE(contents()->cross_navigation_pending()); | |
230 contents()->CommitPendingNavigation(); | |
231 EXPECT_EQ(contents()->GetURL(), third_); | |
232 } | |
233 | |
234 // Tests that an overscroll navigation that receives a paint update actually | |
235 // stops observing. | |
236 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) { | |
237 PerformBackNavigationViaSliderCallbacks(); | |
160 ReceivePaintUpdate(); | 238 ReceivePaintUpdate(); |
239 | |
161 // Paint updates until the navigation is committed typically represent updates | 240 // Paint updates until the navigation is committed typically represent updates |
162 // for the previous page, so they shouldn't affect the flag. | 241 // for the previous page, so we should still be observing. |
163 EXPECT_FALSE(GetOverlay()->received_paint_update_); | 242 EXPECT_TRUE(GetOverlay()->web_contents()); |
164 | 243 |
165 contents()->CommitPendingNavigation(); | 244 contents()->CommitPendingNavigation(); |
166 ReceivePaintUpdate(); | 245 ReceivePaintUpdate(); |
167 // Navigation was committed and the paint update was received - the flag | |
168 // should now be updated. | |
169 EXPECT_TRUE(GetOverlay()->received_paint_update_); | |
170 | 246 |
247 // Navigation was committed and the paint update was received - we should no | |
248 // longer be observing. | |
171 EXPECT_FALSE(GetOverlay()->web_contents()); | 249 EXPECT_FALSE(GetOverlay()->web_contents()); |
250 EXPECT_EQ(contents()->GetURL(), third_); | |
172 } | 251 } |
173 | 252 |
174 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_LoadingUpdate) { | 253 // Tests that an overscroll navigation that receives a loading update actually |
175 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); | 254 // stops observing. |
176 | 255 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) { |
177 PerformBackNavigationViaSliderCallbacks(); | 256 PerformBackNavigationViaSliderCallbacks(); |
178 // No screenshot was set on NavEntry at offset -1. | 257 EXPECT_TRUE(GetOverlay()->web_contents()); |
179 EXPECT_FALSE(GetOverlay()->image_delegate_->has_image()); | |
180 // Navigation was started, so the loading status flag should be reset. | |
181 EXPECT_FALSE(GetOverlay()->loading_complete_); | |
182 | |
183 // DidStopLoading for any navigation should always reset the load flag and | 258 // DidStopLoading for any navigation should always reset the load flag and |
184 // dismiss the overlay even if the pending navigation wasn't committed - | 259 // dismiss the overlay even if the pending navigation wasn't committed - |
185 // this is a "safety net" in case we mis-identify the destination webpage | 260 // this is a "safety net" in case we mis-identify the destination webpage |
186 // (which can happen if a new navigation is performed while while a GestureNav | 261 // (which can happen if a new navigation is performed while while a GestureNav |
187 // navigation is in progress). | 262 // navigation is in progress). |
188 contents()->TestSetIsLoading(true); | 263 contents()->TestSetIsLoading(true); |
189 contents()->TestSetIsLoading(false); | 264 contents()->TestSetIsLoading(false); |
190 EXPECT_TRUE(GetOverlay()->loading_complete_); | 265 EXPECT_FALSE(GetOverlay()->web_contents()); |
266 contents()->CommitPendingNavigation(); | |
267 EXPECT_EQ(contents()->GetURL(), third_); | |
268 } | |
191 | 269 |
192 EXPECT_FALSE(GetOverlay()->web_contents()); | 270 // Tests that swapping the overlay window at the end of a gesture caused by the |
271 // start of a new overscroll does not crash and the events still reach the new | |
272 // overlay window. | |
273 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) { | |
274 PerformBackNavigationViaSliderCallbacks(); | |
275 aura::Window* first_overlay_window = GetOverlay()->window_.get(); | |
276 EXPECT_TRUE(GetOverlay()->web_contents()); | |
277 EXPECT_TRUE(first_overlay_window); | |
278 | |
279 // At this stage, the overlay window is covering the web contents. Configure | |
280 // the animator of the overlay window for the test. | |
281 ui::ScopedAnimationDurationScaleMode normal_duration( | |
282 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | |
283 ui::LayerAnimator* animator = GetOverlay()->window_->layer()->GetAnimator(); | |
284 animator->set_disable_timer_for_test(true); | |
285 ui::LayerAnimatorTestController test_controller(animator); | |
286 | |
287 int overscroll_complete_distance = | |
288 root_window()->bounds().size().width() * | |
289 content::GetOverscrollConfig( | |
290 content::OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE) + | |
291 ui::GestureConfiguration::GetInstance() | |
292 ->max_touch_move_in_pixels_for_click() + 1; | |
293 | |
294 // Start and complete a back navigation via a gesture. | |
295 ui::test::EventGenerator generator(root_window()); | |
296 generator.GestureScrollSequence(gfx::Point(0, 0), | |
297 gfx::Point(overscroll_complete_distance, 0), | |
298 base::TimeDelta::FromMilliseconds(10), 10); | |
mfomitchev
2015/04/02 22:50:37
nit: last 10 on a separate line
Nina
2015/04/07 14:02:08
Done.
| |
299 | |
300 ui::ScopedLayerAnimationSettings settings(animator); | |
301 test_controller.StartThreadedAnimationsIfNeeded(); | |
302 | |
303 // The overlay window should now be being animated to the edge of the screen. | |
mfomitchev
2015/04/02 22:50:37
We've removed animator->Step(), so there will be n
Nina
2015/04/07 14:02:08
TBH it really is not necessary and only complicate
| |
304 EXPECT_EQ(GetOverlay()->window_.get(), first_overlay_window); | |
305 | |
306 // The overlay window is halfway through, start another animation that will | |
307 // cancel the first one. The event that cancels the animation will go to | |
308 // the slide window, which will be used as the overlay window when the new | |
309 // overscroll starts. | |
310 int second_overscroll_start_distance = overscroll_complete_distance + 1; | |
mfomitchev
2015/04/02 22:50:37
A comment explaining why we chose such a value for
Nina
2015/04/07 14:02:08
If it was hard to write, it must be hard to read!
| |
311 generator.GestureScrollSequence( | |
312 gfx::Point(second_overscroll_start_distance, 0), | |
313 gfx::Point( | |
314 second_overscroll_start_distance + overscroll_complete_distance, 0), | |
315 base::TimeDelta::FromMilliseconds(10), 10); | |
316 EXPECT_TRUE(GetOverlay()->window_.get()); | |
317 // The overlay window should be a new window. | |
318 EXPECT_NE(GetOverlay()->window_.get(), first_overlay_window); | |
319 | |
320 // Complete the animation. | |
321 GetOverlay()->window_->layer()->GetAnimator()->StopAnimating(); | |
322 EXPECT_TRUE(GetOverlay()->window_.get()); | |
323 | |
324 // Load the page. | |
325 contents()->CommitPendingNavigation(); | |
326 ReceivePaintUpdate(); | |
327 EXPECT_FALSE(GetOverlay()->window_.get()); | |
328 EXPECT_EQ(contents()->GetURL(), first_); | |
193 } | 329 } |
194 | 330 |
195 } // namespace content | 331 } // namespace content |
OLD | NEW |