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

Side by Side Diff: cc/surfaces/compositor_frame_sink_support_unittest.cc

Issue 2720803002: Pass returned resources to DidReceiveCompositorFrameAck (Closed)
Patch Set: c Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/surfaces/compositor_frame_sink_support.h" 5 #include "cc/surfaces/compositor_frame_sink_support.h"
6 6
7 #include "base/debug/stack_trace.h" 7 #include "base/debug/stack_trace.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/surfaces/compositor_frame_sink_support_client.h" 10 #include "cc/surfaces/compositor_frame_sink_support_client.h"
11 #include "cc/surfaces/frame_sink_id.h" 11 #include "cc/surfaces/frame_sink_id.h"
12 #include "cc/surfaces/surface_id.h" 12 #include "cc/surfaces/surface_id.h"
13 #include "cc/surfaces/surface_manager.h" 13 #include "cc/surfaces/surface_manager.h"
14 #include "cc/test/begin_frame_args_test.h" 14 #include "cc/test/begin_frame_args_test.h"
15 #include "cc/test/fake_external_begin_frame_source.h" 15 #include "cc/test/fake_external_begin_frame_source.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 using testing::UnorderedElementsAre; 19 using testing::UnorderedElementsAre;
20 using testing::IsEmpty; 20 using testing::IsEmpty;
21 using testing::SizeIs; 21 using testing::SizeIs;
22 using testing::Invoke; 22 using testing::Invoke;
23 using testing::_; 23 using testing::_;
24 using testing::InSequence; 24 using testing::Eq;
25 25
26 namespace cc { 26 namespace cc {
27 namespace test { 27 namespace test {
28 namespace { 28 namespace {
29 29
30 constexpr FrameSinkId kDisplayFrameSink(2, 0); 30 constexpr FrameSinkId kDisplayFrameSink(2, 0);
31 constexpr FrameSinkId kParentFrameSink(3, 0); 31 constexpr FrameSinkId kParentFrameSink(3, 0);
32 constexpr FrameSinkId kChildFrameSink1(65563, 0); 32 constexpr FrameSinkId kChildFrameSink1(65563, 0);
33 constexpr FrameSinkId kChildFrameSink2(65564, 0); 33 constexpr FrameSinkId kChildFrameSink2(65564, 0);
34 constexpr FrameSinkId kArbitraryFrameSink(1337, 7331); 34 constexpr FrameSinkId kArbitraryFrameSink(1337, 7331);
35 35
36 class MockCompositorFrameSinkSupportClient 36 class MockCompositorFrameSinkSupportClient
37 : public CompositorFrameSinkSupportClient { 37 : public CompositorFrameSinkSupportClient {
38 public: 38 public:
39 MockCompositorFrameSinkSupportClient() { 39 MockCompositorFrameSinkSupportClient() {
40 ON_CALL(*this, ReclaimResources(_)) 40 ON_CALL(*this, ReclaimResources(_))
41 .WillByDefault(Invoke( 41 .WillByDefault(Invoke(
42 this, 42 this,
43 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); 43 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal));
44 ON_CALL(*this, DidReceiveCompositorFrameAck(_))
45 .WillByDefault(Invoke(
46 this,
47 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal));
44 } 48 }
45 49
46 ReturnedResourceArray& last_returned_resources() { 50 ReturnedResourceArray& last_returned_resources() {
47 return last_returned_resources_; 51 return last_returned_resources_;
48 } 52 }
49 53
50 // CompositorFrameSinkSupportClient implementation. 54 // CompositorFrameSinkSupportClient implementation.
51 MOCK_METHOD0(DidReceiveCompositorFrameAck, void()); 55 MOCK_METHOD1(DidReceiveCompositorFrameAck,
56 void(const ReturnedResourceArray&));
52 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); 57 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&));
53 MOCK_METHOD1(ReclaimResources, void(const ReturnedResourceArray&)); 58 MOCK_METHOD1(ReclaimResources, void(const ReturnedResourceArray&));
54 MOCK_METHOD2(WillDrawSurface, void(const LocalSurfaceId&, const gfx::Rect&)); 59 MOCK_METHOD2(WillDrawSurface, void(const LocalSurfaceId&, const gfx::Rect&));
55 60
56 private: 61 private:
57 void ReclaimResourcesInternal(const ReturnedResourceArray& resources) { 62 void ReclaimResourcesInternal(const ReturnedResourceArray& resources) {
58 last_returned_resources_ = resources; 63 last_returned_resources_ = resources;
59 } 64 }
60 65
61 ReturnedResourceArray last_returned_resources_; 66 ReturnedResourceArray last_returned_resources_;
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 // Check that the support forwards the BeginFrameAck attached 1002 // Check that the support forwards the BeginFrameAck attached
998 // to a CompositorFrame to the BeginFrameSource. 1003 // to a CompositorFrame to the BeginFrameSource.
999 BeginFrameAck ack2(0, 2, 2, true); 1004 BeginFrameAck ack2(0, 2, 2, true);
1000 CompositorFrame frame = MakeCompositorFrame(); 1005 CompositorFrame frame = MakeCompositorFrame();
1001 frame.metadata.begin_frame_ack = ack2; 1006 frame.metadata.begin_frame_ack = ack2;
1002 display_support().SubmitCompositorFrame(display_id.local_surface_id(), 1007 display_support().SubmitCompositorFrame(display_id.local_surface_id(),
1003 std::move(frame)); 1008 std::move(frame));
1004 EXPECT_EQ(ack2, begin_frame_source()->LastAckForObserver(&display_support())); 1009 EXPECT_EQ(ack2, begin_frame_source()->LastAckForObserver(&display_support()));
1005 } 1010 }
1006 1011
1007 // Checks whether the resources are returned before we send an ack. 1012 // Checks that resources and ack are sent together if possible.
1008 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesBeforeAck) { 1013 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesWithAck) {
1009 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 1014 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
1010 TransferableResource resource; 1015 TransferableResource resource;
1011 resource.id = 1234; 1016 resource.id = 1234;
1012 parent_support().SubmitCompositorFrame( 1017 parent_support().SubmitCompositorFrame(
1013 parent_id.local_surface_id(), 1018 parent_id.local_surface_id(),
1014 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); 1019 MakeCompositorFrameWithResources(empty_surface_ids(), {resource}));
1015 { 1020 ReturnedResourceArray returned_resources;
1016 InSequence x; 1021 TransferableResource::ReturnResources({resource}, &returned_resources);
1017 EXPECT_CALL(support_client_, ReclaimResources(_)); 1022 EXPECT_CALL(support_client_, ReclaimResources(_)).Times(0);
1018 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck()); 1023 EXPECT_CALL(support_client_,
1019 } 1024 DidReceiveCompositorFrameAck(Eq(returned_resources)));
1020 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 1025 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1021 MakeCompositorFrame()); 1026 MakeCompositorFrame());
1022 } 1027 }
1023 1028
1024 // Verifies that if a surface is marked destroyed and a new frame arrives for 1029 // Verifies that if a surface is marked destroyed and a new frame arrives for
1025 // it, it will be recovered. 1030 // it, it will be recovered.
1026 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { 1031 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) {
1027 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 1032 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
1028 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); 1033 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3);
1029 1034
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 EXPECT_FALSE(dependency_tracker().has_deadline()); 1242 EXPECT_FALSE(dependency_tracker().has_deadline());
1238 EXPECT_FALSE(display_surface()->HasPendingFrame()); 1243 EXPECT_FALSE(display_surface()->HasPendingFrame());
1239 EXPECT_TRUE(display_surface()->HasActiveFrame()); 1244 EXPECT_TRUE(display_surface()->HasActiveFrame());
1240 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); 1245 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty());
1241 EXPECT_THAT(GetChildReferences(display_id), 1246 EXPECT_THAT(GetChildReferences(display_id),
1242 UnorderedElementsAre(parent_id1, parent_id2)); 1247 UnorderedElementsAre(parent_id1, parent_id2));
1243 } 1248 }
1244 1249
1245 } // namespace test 1250 } // namespace test
1246 } // namespace cc 1251 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698