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

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

Issue 895543005: Refactor GestureNavigation to eliminate code redundancy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simple OWD tests, better ONO tests. Created 5 years, 9 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 <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"
11 #include "content/public/test/mock_render_process_host.h" 12 #include "content/public/test/mock_render_process_host.h"
12 #include "content/test/test_render_frame_host.h" 13 #include "content/test/test_render_frame_host.h"
13 #include "content/test/test_render_view_host.h" 14 #include "content/test/test_render_view_host.h"
14 #include "content/test/test_web_contents.h" 15 #include "content/test/test_web_contents.h"
15 #include "ui/aura/test/test_windows.h" 16 #include "ui/aura/test/test_windows.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/aura_extra/image_window_delegate.h" 18 #include "ui/aura_extra/image_window_delegate.h"
19 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
20 #include "ui/compositor/scoped_layer_animation_settings.h"
21 #include "ui/compositor/test/layer_animator_test_controller.h"
22 #include "ui/events/test/event_generator.h"
18 #include "ui/gfx/codec/png_codec.h" 23 #include "ui/gfx/codec/png_codec.h"
24 #include "ui/gfx/frame_time.h"
19 25
20 namespace content { 26 namespace content {
21 27
28 // A subclass of TestWebContents that offers a fake content window.
29 class OverscrollTestWebContents : public TestWebContents {
mfomitchev 2015/03/27 00:14:05 Why not just add a SetContentsNativeView method to
Nina 2015/03/27 17:52:36 This was a good suggestion, but I had to add anoth
mfomitchev 2015/03/31 22:16:31 What is the reason we need to set the "fake" nativ
Nina 2015/04/01 18:10:00 It's unique to our case AFAICT. We need a window w
mfomitchev 2015/04/02 22:50:36 Gotcha.
30 public:
31 ~OverscrollTestWebContents() override {}
32
33 static OverscrollTestWebContents* Create(
34 BrowserContext* browser_context,
35 SiteInstance* instance,
36 scoped_ptr<aura::Window> fake_contents_window) {
37 OverscrollTestWebContents* web_contents =
38 new OverscrollTestWebContents(browser_context,
39 fake_contents_window.Pass());
40 web_contents->Init(WebContents::CreateParams(browser_context, instance));
41 web_contents->RenderFrameCreated(web_contents->GetMainFrame());
42 return web_contents;
43 }
44
45 gfx::NativeView GetContentNativeView() override {
46 return fake_contents_window_.get();
47 }
48
49 protected:
50 explicit OverscrollTestWebContents(
51 BrowserContext* browser_context,
52 scoped_ptr<aura::Window> fake_contents_window)
53 : TestWebContents(browser_context),
54 fake_contents_window_(fake_contents_window.Pass()) {
55 }
56
57 private:
58 scoped_ptr<aura::Window> fake_contents_window_;
59 };
60
22 class OverscrollNavigationOverlayTest : public RenderViewHostImplTestHarness { 61 class OverscrollNavigationOverlayTest : public RenderViewHostImplTestHarness {
23 public: 62 public:
24 OverscrollNavigationOverlayTest() {} 63 OverscrollNavigationOverlayTest()
64 : first_("https://www.google.com"),
65 second_("http://www.chromium.org"),
66 third_("https://www.kernel.org/"),
67 fourth_("https://github.com/") {
68 }
69
25 ~OverscrollNavigationOverlayTest() override {} 70 ~OverscrollNavigationOverlayTest() override {}
26 71
27 gfx::Image CreateDummyScreenshot() { 72 gfx::Image CreateDummyScreenshot() {
28 SkBitmap bitmap; 73 SkBitmap bitmap;
29 bitmap.allocN32Pixels(1, 1); 74 bitmap.allocN32Pixels(1, 1);
30 bitmap.eraseColor(SK_ColorWHITE); 75 bitmap.eraseColor(SK_ColorWHITE);
31 return gfx::Image::CreateFrom1xBitmap(bitmap); 76 return gfx::Image::CreateFrom1xBitmap(bitmap);
32 } 77 }
33 78
34 void SetDummyScreenshotOnNavEntry(NavigationEntry* entry) { 79 void SetDummyScreenshotOnNavEntry(NavigationEntry* entry) {
35 SkBitmap bitmap; 80 SkBitmap bitmap;
36 bitmap.allocN32Pixels(1, 1); 81 bitmap.allocN32Pixels(1, 1);
37 bitmap.eraseColor(SK_ColorWHITE); 82 bitmap.eraseColor(SK_ColorWHITE);
38 std::vector<unsigned char> png_data; 83 std::vector<unsigned char> png_data;
39 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data); 84 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data);
40 scoped_refptr<base::RefCountedBytes> png_bytes = 85 scoped_refptr<base::RefCountedBytes> png_bytes =
41 base::RefCountedBytes::TakeVector(&png_data); 86 base::RefCountedBytes::TakeVector(&png_data);
42 NavigationEntryImpl* entry_impl = 87 NavigationEntryImpl* entry_impl =
43 NavigationEntryImpl::FromNavigationEntry(entry); 88 NavigationEntryImpl::FromNavigationEntry(entry);
44 entry_impl->SetScreenshotPNGData(png_bytes); 89 entry_impl->SetScreenshotPNGData(png_bytes);
45 } 90 }
46 91
47 void ReceivePaintUpdate() { 92 void ReceivePaintUpdate() {
48 FrameHostMsg_DidFirstVisuallyNonEmptyPaint msg( 93 FrameHostMsg_DidFirstVisuallyNonEmptyPaint msg(
49 main_test_rfh()->GetRoutingID()); 94 main_test_rfh()->GetRoutingID());
50 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg); 95 RenderViewHostTester::TestOnMessageReceived(test_rvh(), msg);
51 } 96 }
52 97
53 void PerformBackNavigationViaSliderCallbacks() { 98 void PerformBackNavigationViaSliderCallbacks() {
54 // Sets slide direction to SLIDE_BACK, sets screenshot from NavEntry at 99 // Sets slide direction to BACK, sets screenshot from NavEntry at
55 // offset -1 on layer_delegate_. 100 // offset -1 on layer_delegate_.
56 delete GetOverlay()->CreateBackLayer(); 101 scoped_ptr<aura::Window> window(GetOverlay()->CreateBackWindow());
57 // Performs BACK navigation, sets image from layer_delegate_ on 102 // Performs BACK navigation, sets image from layer_delegate_ on
58 // image_delegate_. 103 // image_delegate_.
59 GetOverlay()->OnWindowSlideCompleting(); 104 GetOverlay()->OnOverscrollCompleting();
60 GetOverlay()->OnWindowSlideCompleted(scoped_ptr<ui::Layer>()); 105 GetOverlay()->OnOverscrollCompleted(window.Pass());
61 } 106 }
62 107
108 // Tests URLs.
109 const GURL first_;
110 const GURL second_;
111 const GURL third_;
112 const GURL fourth_;
113
63 protected: 114 protected:
64 // RenderViewHostImplTestHarness: 115 // RenderViewHostImplTestHarness:
65 void SetUp() override { 116 void SetUp() override {
66 RenderViewHostImplTestHarness::SetUp(); 117 RenderViewHostImplTestHarness::SetUp();
67 118
68 const GURL first("https://www.google.com"); 119 // Set up the fake contents window.
69 contents()->NavigateAndCommit(first); 120 scoped_ptr<aura::Window> fake_contents_window(new aura::Window(nullptr));
121 fake_contents_window->Init(aura::WINDOW_LAYER_SOLID_COLOR);
122 root_window()->AddChild(fake_contents_window.get());
123 fake_contents_window->SetBounds(gfx::Rect(root_window()->bounds().size()));
124
125 // Replace the default test web contents with our custom class.
126 SetContents(OverscrollTestWebContents::Create(
127 browser_context(),
128 SiteInstance::Create(browser_context()),
129 fake_contents_window.Pass()));
130
131 contents()->NavigateAndCommit(first_);
70 EXPECT_TRUE(controller().GetVisibleEntry()); 132 EXPECT_TRUE(controller().GetVisibleEntry());
71 EXPECT_FALSE(controller().CanGoBack()); 133 EXPECT_FALSE(controller().CanGoBack());
72 134
73 const GURL second("http://www.chromium.org"); 135 contents()->NavigateAndCommit(second_);
74 contents()->NavigateAndCommit(second);
75 EXPECT_TRUE(controller().CanGoBack()); 136 EXPECT_TRUE(controller().CanGoBack());
76 137
138 contents()->NavigateAndCommit(third_);
139 EXPECT_TRUE(controller().CanGoBack());
140
141 contents()->NavigateAndCommit(fourth_);
142 EXPECT_TRUE(controller().CanGoBack());
143 EXPECT_FALSE(controller().CanGoForward());
144
77 // Receive a paint update. This is necessary to make sure the size is set 145 // Receive a paint update. This is necessary to make sure the size is set
78 // correctly in RenderWidgetHostImpl. 146 // correctly in RenderWidgetHostImpl.
79 ViewHostMsg_UpdateRect_Params params; 147 ViewHostMsg_UpdateRect_Params params;
80 memset(&params, 0, sizeof(params)); 148 memset(&params, 0, sizeof(params));
81 params.view_size = gfx::Size(10, 10); 149 params.view_size = gfx::Size(10, 10);
82 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params); 150 ViewHostMsg_UpdateRect rect(test_rvh()->GetRoutingID(), params);
83 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect); 151 RenderViewHostTester::TestOnMessageReceived(test_rvh(), rect);
84 152
85 // Reset pending flags for size/paint. 153 // Reset pending flags for size/paint.
86 test_rvh()->ResetSizeAndRepaintPendingFlags(); 154 test_rvh()->ResetSizeAndRepaintPendingFlags();
87 155
88 // Create the overlay, and set the contents of the overlay window. 156 // Create the overlay, and set the contents of the overlay window.
89 overlay_.reset(new OverscrollNavigationOverlay(contents())); 157 overlay_.reset(new OverscrollNavigationOverlay(
90 aura_extra::ImageWindowDelegate* image_delegate = 158 contents(), root_window()));
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 } 159 }
106 160
107 void TearDown() override { 161 void TearDown() override {
108 overlay_.reset(); 162 overlay_.reset();
109 RenderViewHostImplTestHarness::TearDown(); 163 RenderViewHostImplTestHarness::TearDown();
110 } 164 }
111 165
112 OverscrollNavigationOverlay* GetOverlay() { 166 OverscrollNavigationOverlay* GetOverlay() {
113 return overlay_.get(); 167 return overlay_.get();
114 } 168 }
115 169
116 private: 170 private:
117 scoped_ptr<OverscrollNavigationOverlay> overlay_; 171 scoped_ptr<OverscrollNavigationOverlay> overlay_;
118 172
119 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlayTest); 173 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlayTest);
120 }; 174 };
121 175
122 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_NoImage) { 176 // Tests that if a screenshot is available, it is set in the overlay window
123 ReceivePaintUpdate(); 177 // delegate.
124 EXPECT_TRUE(GetOverlay()->received_paint_update_); 178 TEST_F(OverscrollNavigationOverlayTest, WithScreenshot) {
125 EXPECT_FALSE(GetOverlay()->loading_complete_); 179 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1));
126 // The paint update will hide the overlay. 180 PerformBackNavigationViaSliderCallbacks();
127 EXPECT_FALSE(GetOverlay()->web_contents()); 181 // Screenshot was set on NavEntry at offset -1.
182 EXPECT_TRUE(static_cast<aura_extra::ImageWindowDelegate*>(
183 GetOverlay()->window_->delegate())->has_image());
mfomitchev 2015/03/27 00:14:05 Verify contents()->GetURL()?
Nina 2015/03/27 17:52:36 I don't think we need to re-test this (we do it la
mfomitchev 2015/03/31 22:16:31 Ok, well, maybe put the check for cross_navigation
Nina 2015/04/01 18:10:00 Done.
128 } 184 }
129 185
130 TEST_F(OverscrollNavigationOverlayTest, FirstVisuallyNonEmptyPaint_WithImage) { 186 // Tests that if a screenshot is not available, no image is set in the overlay
131 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 187 // window delegate.
132 188 TEST_F(OverscrollNavigationOverlayTest, WithoutScreenshot) {
133 ReceivePaintUpdate(); 189 PerformBackNavigationViaSliderCallbacks();
134 EXPECT_TRUE(GetOverlay()->received_paint_update_); 190 // No screenshot was set on NavEntry at offset -1.
135 EXPECT_FALSE(GetOverlay()->loading_complete_); 191 EXPECT_FALSE(static_cast<aura_extra::ImageWindowDelegate*>(
136 // The paint update will hide the overlay. 192 GetOverlay()->window_->delegate())->has_image());
mfomitchev 2015/03/27 00:14:05 Verify contents()->GetURL()?
Nina 2015/03/27 17:52:36 Ditto
mfomitchev 2015/03/31 22:16:31 same as above
137 EXPECT_FALSE(GetOverlay()->web_contents());
138 } 193 }
139 194
140 TEST_F(OverscrollNavigationOverlayTest, LoadUpdateWithoutNonEmptyPaint) { 195 // Tests that if a navigation is attempted but there is nothing to navigate to,
141 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 196 // we return a null window.
142 process()->sink().ClearMessages(); 197 TEST_F(OverscrollNavigationOverlayTest, CannotNavigate) {
143 198 EXPECT_EQ(GetOverlay()->CreateFrontWindow(), nullptr);
mfomitchev 2015/03/27 00:14:05 Verify contents()->GetURL()?
Nina 2015/03/27 17:52:36 Ditto. And in this case we are not navigating.
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 } 199 }
150 200
151 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) { 201 // Tests that if a navigation is aborted, no navigation is performed and the
152 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 202 // state is restored.
153 SetDummyScreenshotOnNavEntry(controller().GetEntryAtOffset(-1)); 203 TEST_F(OverscrollNavigationOverlayTest, AbortNavigation) {
204 scoped_ptr<aura::Window> window = GetOverlay()->CreateBackWindow();
205 EXPECT_NE(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE);
154 206
207 GetOverlay()->OnOverscrollAborted();
208 // Make sure that if we started a navigation (we shouldn't), we commit it.
209 EXPECT_FALSE(contents()->cross_navigation_pending());
mfomitchev 2015/03/27 00:14:05 Verify contents()->GetURL()?
Nina 2015/03/27 17:52:36 I really don't think we need to test this - it mea
mfomitchev 2015/03/31 22:16:31 Acknowledged.
210 }
211
212 // Tests that if a second navigation is aborted, the first one still happens.
213 TEST_F(OverscrollNavigationOverlayTest, AbortAfterSuccessfulNavigation) {
155 PerformBackNavigationViaSliderCallbacks(); 214 PerformBackNavigationViaSliderCallbacks();
156 // Screenshot was set on NavEntry at offset -1. 215 scoped_ptr<aura::Window> wrapper = GetOverlay()->CreateBackWindow();
157 EXPECT_TRUE(GetOverlay()->image_delegate_->has_image()); 216 EXPECT_NE(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE);
158 EXPECT_FALSE(GetOverlay()->received_paint_update_);
159 217
218 GetOverlay()->OnOverscrollAborted();
219 EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE);
220
221 EXPECT_TRUE(contents()->cross_navigation_pending());
222 contents()->CommitPendingNavigation();
223 EXPECT_EQ(contents()->GetURL(), third_);
224 }
225
226 // Tests that an overscroll navigation that receives a paint update actually
227 // stops observing.
228 TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) {
229 PerformBackNavigationViaSliderCallbacks();
160 ReceivePaintUpdate(); 230 ReceivePaintUpdate();
231
161 // Paint updates until the navigation is committed typically represent updates 232 // Paint updates until the navigation is committed typically represent updates
162 // for the previous page, so they shouldn't affect the flag. 233 // for the previous page, so we should still be observing.
163 EXPECT_FALSE(GetOverlay()->received_paint_update_); 234 EXPECT_TRUE(GetOverlay()->web_contents());
164 235
165 contents()->CommitPendingNavigation(); 236 contents()->CommitPendingNavigation();
166 ReceivePaintUpdate(); 237 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 238
239 // Navigation was committed and the paint update was received - we should no
240 // longer be observing.
171 EXPECT_FALSE(GetOverlay()->web_contents()); 241 EXPECT_FALSE(GetOverlay()->web_contents());
242 EXPECT_EQ(contents()->GetURL(), third_);
172 } 243 }
173 244
174 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_LoadingUpdate) { 245 // Tests that an overscroll navigation that receives a loading update actually
175 GetOverlay()->image_delegate_->SetImage(CreateDummyScreenshot()); 246 // stops observing.
176 247 TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) {
177 PerformBackNavigationViaSliderCallbacks(); 248 PerformBackNavigationViaSliderCallbacks();
178 // No screenshot was set on NavEntry at offset -1. 249 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 250 // DidStopLoading for any navigation should always reset the load flag and
184 // dismiss the overlay even if the pending navigation wasn't committed - 251 // 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 252 // this is a "safety net" in case we mis-identify the destination webpage
253 // (which can happen if a new navigation is performed while while a GestureNav
254 // navigation is in progress).
255 contents()->TestSetIsLoading(true);
256 contents()->TestSetIsLoading(false);
257 EXPECT_FALSE(GetOverlay()->web_contents());
258 contents()->CommitPendingNavigation();
259 EXPECT_EQ(contents()->GetURL(), third_);
260 }
261
262 // Tests that an overscroll gesture followed after another one before the first
263 // one finishes loading works with a paint update.
264 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_PaintUpdate) {
265 PerformBackNavigationViaSliderCallbacks();
266 EXPECT_TRUE(GetOverlay()->web_contents());
267 PerformBackNavigationViaSliderCallbacks();
268 EXPECT_TRUE(GetOverlay()->web_contents());
269 ReceivePaintUpdate();
270
271 // Paint updates until the navigation is committed typically represent updates
272 // for the previous page, so we should still be observing.
273 EXPECT_TRUE(GetOverlay()->web_contents());
274
275 contents()->CommitPendingNavigation();
276 ReceivePaintUpdate();
277
278 // Navigation was committed and the paint update was received - we should no
279 // longer be observing.
280 EXPECT_FALSE(GetOverlay()->web_contents());
281 EXPECT_EQ(contents()->GetURL(), second_);
282 }
283
284 // Tests that an overscroll gesture followed after another one before the first
285 // one finishes loading works with a loading update.
286 TEST_F(OverscrollNavigationOverlayTest, MultiNavigation_LoadingUpdate) {
287 PerformBackNavigationViaSliderCallbacks();
288 EXPECT_TRUE(GetOverlay()->web_contents());
289 PerformBackNavigationViaSliderCallbacks();
290 EXPECT_TRUE(GetOverlay()->web_contents());
291 // DidStopLoading for any navigation should always reset the load flag and
292 // dismiss the overlay even if the pending navigation wasn't committed -
293 // 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 294 // (which can happen if a new navigation is performed while while a GestureNav
187 // navigation is in progress). 295 // navigation is in progress).
188 contents()->TestSetIsLoading(true); 296 contents()->TestSetIsLoading(true);
189 contents()->TestSetIsLoading(false); 297 contents()->TestSetIsLoading(false);
190 EXPECT_TRUE(GetOverlay()->loading_complete_); 298 EXPECT_FALSE(GetOverlay()->web_contents());
299 contents()->CommitPendingNavigation();
300 EXPECT_EQ(contents()->GetURL(), second_);
301 }
191 302
192 EXPECT_FALSE(GetOverlay()->web_contents()); 303 // Tests that swapping the overlay window at the end of a gesture caused by the
304 // start of a new overscroll does not crash and the events still reach the new
305 // overlay window.
306 TEST_F(OverscrollNavigationOverlayTest, OverlayWindowSwap) {
307 PerformBackNavigationViaSliderCallbacks();
308 aura::Window* first_overlay_window = GetOverlay()->window_.get();
309 EXPECT_TRUE(GetOverlay()->web_contents());
310 EXPECT_TRUE(first_overlay_window);
311
312
313 // At this stage, the overlay window is covering the web contents. Configure
314 // the animator of the overlay window for the test.
315 ui::ScopedAnimationDurationScaleMode normal_duration(
316 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
317 ui::LayerAnimator* animator = GetOverlay()->window_->layer()->GetAnimator();
318 animator->set_disable_timer_for_test(true);
319 ui::LayerAnimatorTestController test_controller(animator);
320
321 // Start and complete a back navigation via a gesture.
322 ui::test::EventGenerator generator(root_window());
323 generator.GestureScrollSequence(
324 gfx::Point(10, 10),
325 gfx::Point(400, 10),
326 base::TimeDelta::FromMilliseconds(10),
327 10);
328
329 ui::ScopedLayerAnimationSettings settings(animator);
330 base::TimeDelta duration = settings.GetTransitionDuration();
331 test_controller.StartThreadedAnimationsIfNeeded();
332 base::TimeTicks start_time = gfx::FrameTime::Now();
333
334 // The overlay window should now be being animated to the edge of the screen.
335 animator->Step(start_time + duration / 2);
336 EXPECT_EQ(GetOverlay()->window_.get(), first_overlay_window);
337
338 // The overlay window is halfway through, start another animation that will
339 // cancel the first one. The first event that cancels the animation will go to
mfomitchev 2015/03/27 00:14:05 So this comment is incorrect, right? The events go
Nina 2015/03/27 17:52:36 Right, fixed comment.
340 // the old overlay window, which will be destroyed, and subsequent events
341 // should be routed to the new overlay window.
342 generator.GestureScrollSequence(
343 gfx::Point(10, 10),
mfomitchev 2015/03/27 00:14:05 Can we make scroll gesture begin on the old overl
Nina 2015/03/27 17:52:36 I noticed this, and modified it.
344 gfx::Point(400, 10),
345 base::TimeDelta::FromMilliseconds(10),
346 10);
347 EXPECT_TRUE(GetOverlay()->window_.get());
348 // The overlay window should be a new window.
349 EXPECT_NE(GetOverlay()->window_.get(), first_overlay_window);
350
351 // Complete the animation.
352 GetOverlay()->window_->layer()->GetAnimator()->StopAnimating();
353 EXPECT_TRUE(GetOverlay()->window_.get());
354
355 // Load the page.
356 contents()->CommitPendingNavigation();
357 ReceivePaintUpdate();
358 EXPECT_FALSE(GetOverlay()->window_.get());
359 EXPECT_EQ(contents()->GetURL(), first_);
mfomitchev 2015/03/27 00:14:05 We start with fourth_ and do two back gestures, sh
Nina 2015/03/27 17:52:36 We did three gestures, L307, L323 and L342.
mfomitchev 2015/03/31 22:16:31 Acknowledged.
193 } 360 }
194 361
195 } // namespace content 362 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698