summaryrefslogtreecommitdiffstats
path: root/cc/trees/layer_tree_host_impl_unittest.cc
diff options
context:
space:
mode:
authorjaydasika <jaydasika@chromium.org>2015-12-09 15:52:46 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-09 23:54:22 +0000
commitcb93d1c0ff96e8d2610c95f6a1a2986293960774 (patch)
tree5408806b98364fe647127e0b3a975ebc971d51d3 /cc/trees/layer_tree_host_impl_unittest.cc
parent01749fbb1216c45883397ef4f8ae3b8e90500a24 (diff)
downloadchromium_src-cb93d1c0ff96e8d2610c95f6a1a2986293960774.zip
chromium_src-cb93d1c0ff96e8d2610c95f6a1a2986293960774.tar.gz
chromium_src-cb93d1c0ff96e8d2610c95f6a1a2986293960774.tar.bz2
Jitter Measurement
Adds code to measure jitter in web pages. The jitter measure used is proportional to displacement from the fixed point and the size of layer that jitters. BUG=542813 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1181263003 Cr-Commit-Position: refs/heads/master@{#364222}
Diffstat (limited to 'cc/trees/layer_tree_host_impl_unittest.cc')
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 3dd4fb9..ca513c0 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -9282,5 +9282,54 @@ TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) {
EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f));
}
+TEST_F(LayerTreeHostImplTest, JitterTest) {
+ host_impl_->SetViewportSize(gfx::Size(100, 100));
+
+ host_impl_->CreatePendingTree();
+ CreateScrollAndContentsLayers(host_impl_->pending_tree(),
+ gfx::Size(100, 100));
+
+ host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
+ host_impl_->pending_tree()->BuildPropertyTreesForTesting();
+ const int scroll = 5;
+ int accumulated_scroll = 0;
+ for (int i = 0; i < host_impl_->pending_tree()->kFixedPointHitsThreshold + 1;
+ ++i) {
+ host_impl_->ActivateSyncTree();
+ host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::GESTURE);
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, scroll));
+ accumulated_scroll += scroll;
+ host_impl_->ScrollEnd();
+ host_impl_->active_tree()->UpdateDrawProperties(false);
+
+ host_impl_->CreatePendingTree();
+ host_impl_->pending_tree()->set_source_frame_number(i + 1);
+ LayerImpl* content_layer = host_impl_->pending_tree()
+ ->OuterViewportScrollLayer()
+ ->children()[0]
+ .get();
+ // The scroll done on the active tree is undone on the pending tree.
+ gfx::Transform translate;
+ translate.Translate(0, accumulated_scroll);
+ content_layer->SetTransform(translate);
+
+ LayerTreeImpl* pending_tree = host_impl_->pending_tree();
+ pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
+ pending_tree->property_trees()->needs_rebuild = true;
+ pending_tree->BuildPropertyTreesForTesting();
+ pending_tree->set_needs_update_draw_properties();
+ pending_tree->UpdateDrawProperties(false);
+ LayerImpl* last_scrolled_layer = pending_tree->LayerById(
+ host_impl_->active_tree()->LastScrolledLayerId());
+ float jitter =
+ LayerTreeHostCommon::CalculateFrameJitter(last_scrolled_layer);
+ // There should not be any jitter measured till we hit the fixed point hits
+ // threshold.
+ float expected_jitter =
+ (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
+ EXPECT_EQ(jitter, expected_jitter);
+ }
+}
+
} // namespace
} // namespace cc