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

Side by Side Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 307653005: Update source frame number even when commits abort (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 6 years, 6 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 | Annotate | Revision Log
« cc/trees/layer_tree_host.cc ('K') | « cc/trees/layer_tree_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXPECT_EQ(1, num_impl_scrolls_); 234 EXPECT_EQ(1, num_impl_scrolls_);
235 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); 235 EXPECT_EQ(1, layer_tree_host()->source_frame_number());
236 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), 236 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(),
237 initial_scroll_ + impl_scroll_); 237 initial_scroll_ + impl_scroll_);
238 EXPECT_EQ(impl_scale_, layer_tree_host()->page_scale_factor()); 238 EXPECT_EQ(impl_scale_, layer_tree_host()->page_scale_factor());
239 PostSetNeedsRedrawToMainThread(); 239 PostSetNeedsRedrawToMainThread();
240 break; 240 break;
241 case 3: 241 case 3:
242 // This commit will not be aborted because of the scroll change. 242 // This commit will not be aborted because of the scroll change.
243 EXPECT_EQ(2, num_impl_scrolls_); 243 EXPECT_EQ(2, num_impl_scrolls_);
244 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); 244 // The source frame number still increases even with the abort.
enne (OOO) 2014/05/29 19:29:58 Hey look, we already had tests, and I just had to
245 EXPECT_EQ(2, layer_tree_host()->source_frame_number());
245 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), 246 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(),
246 initial_scroll_ + impl_scroll_ + impl_scroll_); 247 initial_scroll_ + impl_scroll_ + impl_scroll_);
247 EXPECT_EQ(impl_scale_ * impl_scale_, 248 EXPECT_EQ(impl_scale_ * impl_scale_,
248 layer_tree_host()->page_scale_factor()); 249 layer_tree_host()->page_scale_factor());
249 root_scroll_layer->SetScrollOffset(root_scroll_layer->scroll_offset() + 250 root_scroll_layer->SetScrollOffset(root_scroll_layer->scroll_offset() +
250 second_main_scroll_); 251 second_main_scroll_);
251 break; 252 break;
252 case 4: 253 case 4:
253 // This commit will also be aborted. 254 // This commit will also be aborted.
254 EXPECT_EQ(3, num_impl_scrolls_); 255 EXPECT_EQ(3, num_impl_scrolls_);
255 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); 256 EXPECT_EQ(3, layer_tree_host()->source_frame_number());
256 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), 257 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(),
257 initial_scroll_ + impl_scroll_ + impl_scroll_ + 258 initial_scroll_ + impl_scroll_ + impl_scroll_ +
258 impl_scroll_ + second_main_scroll_); 259 impl_scroll_ + second_main_scroll_);
259 // End the test by drawing to verify this commit is also aborted. 260 // End the test by drawing to verify this commit is also aborted.
260 PostSetNeedsRedrawToMainThread(); 261 PostSetNeedsRedrawToMainThread();
261 break; 262 break;
262 } 263 }
263 } 264 }
264 265
265 virtual void DidBeginMainFrame() OVERRIDE { num_did_begin_main_frames_++; } 266 virtual void DidBeginMainFrame() OVERRIDE { num_did_begin_main_frames_++; }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 initial_scroll_ + impl_scroll_); 305 initial_scroll_ + impl_scroll_);
305 306
306 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta()); 307 EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta());
307 EXPECT_EQ(impl_scale_, impl->active_tree()->total_page_scale_factor()); 308 EXPECT_EQ(impl_scale_, impl->active_tree()->total_page_scale_factor());
308 impl->active_tree()->SetPageScaleDelta(impl_scale_); 309 impl->active_tree()->SetPageScaleDelta(impl_scale_);
309 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta()); 310 EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta());
310 EXPECT_EQ(impl_scale_ * impl_scale_, 311 EXPECT_EQ(impl_scale_ * impl_scale_,
311 impl->active_tree()->total_page_scale_factor()); 312 impl->active_tree()->total_page_scale_factor());
312 313
313 impl->SetNeedsCommit(); 314 impl->SetNeedsCommit();
314 } else if (impl->active_tree()->source_frame_number() == 1 && 315 } else if (impl->active_tree()->source_frame_number() == 1) {
316 // Commit for source frame 1 is aborted.
317 NOTREACHED();
318 } else if (impl->active_tree()->source_frame_number() == 2 &&
315 impl->SourceAnimationFrameNumber() == 3) { 319 impl->SourceAnimationFrameNumber() == 3) {
316 // Third draw after the second full commit. 320 // Third draw after the second full commit.
317 EXPECT_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); 321 EXPECT_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d());
318 root_scroll_layer->ScrollBy(impl_scroll_); 322 root_scroll_layer->ScrollBy(impl_scroll_);
319 impl->SetNeedsCommit(); 323 impl->SetNeedsCommit();
320 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); 324 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_);
321 EXPECT_VECTOR_EQ( 325 EXPECT_VECTOR_EQ(
322 root_scroll_layer->scroll_offset(), 326 root_scroll_layer->scroll_offset(),
323 initial_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_); 327 initial_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_);
324 } else if (impl->active_tree()->source_frame_number() == 1 && 328 } else if (impl->active_tree()->source_frame_number() == 2 &&
325 impl->SourceAnimationFrameNumber() == 4) { 329 impl->SourceAnimationFrameNumber() == 4) {
326 // Final draw after the second aborted commit. 330 // Final draw after the second aborted commit.
327 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); 331 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d());
328 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), 332 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(),
329 initial_scroll_ + impl_scroll_ + impl_scroll_ + 333 initial_scroll_ + impl_scroll_ + impl_scroll_ +
330 impl_scroll_ + second_main_scroll_); 334 impl_scroll_ + second_main_scroll_);
331 EndTest(); 335 EndTest();
336 } else {
337 // Commit for source frame 3 is aborted.
338 NOTREACHED();
332 } 339 }
333 } 340 }
334 341
335 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 342 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
336 float scale) OVERRIDE { 343 float scale) OVERRIDE {
337 num_impl_scrolls_++; 344 num_impl_scrolls_++;
338 } 345 }
339 346
340 virtual void AfterTest() OVERRIDE { 347 virtual void AfterTest() OVERRIDE {
341 EXPECT_EQ(3, num_impl_scrolls_); 348 EXPECT_EQ(3, num_impl_scrolls_);
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 RunTest(true, false, false); 1235 RunTest(true, false, false);
1229 } 1236 }
1230 1237
1231 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1238 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1232 scroll_destroy_whole_tree_ = true; 1239 scroll_destroy_whole_tree_ = true;
1233 RunTest(true, false, false); 1240 RunTest(true, false, false);
1234 } 1241 }
1235 1242
1236 } // namespace 1243 } // namespace
1237 } // namespace cc 1244 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host.cc ('K') | « cc/trees/layer_tree_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698