Index: cc/trees/layer_tree_host_unittest.cc |
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
index a3c37ed627e3908fda61e47fbbaf96ee8b0425d0..548bcd535396762a4b686875ead15c52f680eedd 100644 |
--- a/cc/trees/layer_tree_host_unittest.cc |
+++ b/cc/trees/layer_tree_host_unittest.cc |
@@ -6120,6 +6120,71 @@ class LayerTreeHostTestOneActivatePerPrepareTiles : public LayerTreeHostTest { |
MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
+class LayerTreeHostTestFrameTimingRequestsSaveTimestamps |
+ : public LayerTreeHostTest { |
+ public: |
+ LayerTreeHostTestFrameTimingRequestsSaveTimestamps() |
+ : check_results_on_commit_(false) {} |
+ |
+ void SetupTree() override { |
+ scoped_refptr<FakePictureLayer> root_layer = |
+ FakePictureLayer::Create(&client_); |
+ root_layer->SetBounds(gfx::Size(200, 200)); |
+ root_layer->SetIsDrawable(true); |
+ |
+ scoped_refptr<FakePictureLayer> child_layer = |
+ FakePictureLayer::Create(&client_); |
+ child_layer->SetBounds(gfx::Size(1500, 1500)); |
+ child_layer->SetIsDrawable(true); |
+ |
+ std::vector<FrameTimingRequest> requests; |
+ requests.push_back(FrameTimingRequest(1, gfx::Rect(0, 0, 100, 100))); |
+ requests.push_back(FrameTimingRequest(2, gfx::Rect(300, 0, 100, 100))); |
+ child_layer->SetFrameTimingRequests(requests); |
+ |
+ root_layer->AddChild(child_layer); |
+ layer_tree_host()->SetRootLayer(root_layer); |
+ LayerTreeHostTest::SetupTree(); |
+ } |
+ |
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
+ |
+ void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
+ if (!check_results_on_commit_) |
+ return; |
+ |
+ // Since in reality, the events will be read by LayerTreeHost during commit, |
danakj
2015/02/02 23:57:29
Then it would be even better if you did this in Di
vmpstr
2015/02/03 00:10:41
DidCommit doesn't have a host_impl... I think this
danakj
2015/02/03 00:21:28
Poking LTHI in DidCommit would be unthreadsafe. So
vmpstr
2015/02/03 00:26:08
Done.
|
+ // we check the requests here to ensure that they are correct at the next |
+ // commit time (as opposed to checking in DrawLayers for instance). |
+ FrameTimingTracker* tracker = host_impl->frame_timing_tracker(); |
+ scoped_ptr<FrameTimingTracker::CompositeTimingSet> timing_set = |
+ tracker->GroupCountsByRectId(); |
+ EXPECT_EQ(1u, timing_set->size()); |
+ auto rect_1_it = timing_set->find(1); |
danakj
2015/02/02 23:57:29
const auto&?
vmpstr
2015/02/03 00:10:41
We typically do iterators by value. I can make an
danakj
2015/02/03 00:21:28
Hm.. ya okay nvm!
|
+ EXPECT_TRUE(rect_1_it != timing_set->end()); |
+ const auto& timing_events = rect_1_it->second; |
+ EXPECT_EQ(1u, timing_events.size()); |
+ EXPECT_EQ(host_impl->active_tree()->source_frame_number(), |
+ timing_events[0].frame_id); |
+ EXPECT_GT(timing_events[0].timestamp, base::TimeTicks()); |
+ |
+ EndTest(); |
+ } |
+ |
+ void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
+ check_results_on_commit_ = true; |
+ PostSetNeedsCommitToMainThread(); |
+ } |
+ |
+ void AfterTest() override {} |
+ |
+ private: |
+ FakeContentLayerClient client_; |
+ bool check_results_on_commit_; |
+}; |
+ |
+MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestFrameTimingRequestsSaveTimestamps); |
+ |
class LayerTreeHostTestActivationCausesPrepareTiles : public LayerTreeHostTest { |
public: |
LayerTreeHostTestActivationCausesPrepareTiles() |