OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_TEST_MOCK_COMPOSITOR_FRAME_SINK_SUPPORT_CLIENT_H_ |
| 6 #define CC_TEST_MOCK_COMPOSITOR_FRAME_SINK_SUPPORT_CLIENT_H_ |
| 7 |
| 8 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
| 10 #include "cc/test/compositor_frame_helpers.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 using testing::Invoke; |
| 15 using testing::_; |
| 16 |
| 17 namespace cc { |
| 18 namespace test { |
| 19 |
| 20 class MockCompositorFrameSinkSupportClient |
| 21 : public CompositorFrameSinkSupportClient { |
| 22 public: |
| 23 explicit MockCompositorFrameSinkSupportClient( |
| 24 bool create_surface_during_eviction); |
| 25 ~MockCompositorFrameSinkSupportClient() override; |
| 26 |
| 27 void set_support(CompositorFrameSinkSupport* support) { support_ = support; } |
| 28 |
| 29 ReturnedResourceArray& last_returned_resources() { |
| 30 return last_returned_resources_; |
| 31 } |
| 32 |
| 33 // CompositorFrameSinkSupportClient implementation. |
| 34 MOCK_METHOD1(DidReceiveCompositorFrameAck, |
| 35 void(const ReturnedResourceArray&)); |
| 36 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); |
| 37 MOCK_METHOD1(ReclaimResources, void(const ReturnedResourceArray&)); |
| 38 MOCK_METHOD2(WillDrawSurface, void(const LocalSurfaceId&, const gfx::Rect&)); |
| 39 |
| 40 private: |
| 41 void ReclaimResourcesInternal(const ReturnedResourceArray& resources) { |
| 42 last_returned_resources_ = resources; |
| 43 } |
| 44 |
| 45 void CreateSurfaceDrawCallback(const ReturnedResourceArray& resources) { |
| 46 last_returned_resources_ = resources; |
| 47 LocalSurfaceId new_id(7, base::UnguessableToken::Create()); |
| 48 ASSERT_TRUE(support_); |
| 49 ON_CALL(*this, DidReceiveCompositorFrameAck(_)) |
| 50 .WillByDefault(Invoke( |
| 51 this, |
| 52 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); |
| 53 support_->SubmitCompositorFrame(new_id, MakeCompositorFrame()); |
| 54 support_->EvictFrame(); |
| 55 } |
| 56 |
| 57 ReturnedResourceArray last_returned_resources_; |
| 58 CompositorFrameSinkSupport* support_ = nullptr; |
| 59 }; |
| 60 |
| 61 } // namespace test |
| 62 } // namespace cc |
| 63 |
| 64 #endif // CC_TEST_MOCK_COMPOSITOR_FRAME_SINK_SUPPORT_CLIENT_H_ |
OLD | NEW |