| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/run_loop.h" |
| 6 #include "cc/input/selection.h" | 7 #include "cc/input/selection.h" |
| 7 #include "cc/ipc/traits_test_service.mojom.h" | 8 #include "cc/ipc/traits_test_service.mojom.h" |
| 8 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
| 9 #include "cc/quads/debug_border_draw_quad.h" | 10 #include "cc/quads/debug_border_draw_quad.h" |
| 10 #include "cc/quads/render_pass.h" | 11 #include "cc/quads/render_pass.h" |
| 11 #include "cc/quads/render_pass_draw_quad.h" | 12 #include "cc/quads/render_pass_draw_quad.h" |
| 12 #include "cc/quads/solid_color_draw_quad.h" | 13 #include "cc/quads/solid_color_draw_quad.h" |
| 13 #include "cc/quads/stream_video_draw_quad.h" | 14 #include "cc/quads/stream_video_draw_quad.h" |
| 14 #include "cc/quads/surface_draw_quad.h" | 15 #include "cc/quads/surface_draw_quad.h" |
| 15 #include "cc/quads/texture_draw_quad.h" | 16 #include "cc/quads/texture_draw_quad.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const ReturnedResource& r, | 85 const ReturnedResource& r, |
| 85 const EchoReturnedResourceCallback& callback) override { | 86 const EchoReturnedResourceCallback& callback) override { |
| 86 callback.Run(r); | 87 callback.Run(r); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void EchoSelection(const Selection<gfx::SelectionBound>& s, | 90 void EchoSelection(const Selection<gfx::SelectionBound>& s, |
| 90 const EchoSelectionCallback& callback) override { | 91 const EchoSelectionCallback& callback) override { |
| 91 callback.Run(s); | 92 callback.Run(s); |
| 92 } | 93 } |
| 93 | 94 |
| 95 void EchoSingleReleaseCallback( |
| 96 std::unique_ptr<SingleReleaseCallback> s, |
| 97 const EchoSingleReleaseCallbackCallback& callback) override { |
| 98 callback.Run(std::move(s)); |
| 99 } |
| 100 |
| 94 void EchoSharedQuadState( | 101 void EchoSharedQuadState( |
| 95 const SharedQuadState& s, | 102 const SharedQuadState& s, |
| 96 const EchoSharedQuadStateCallback& callback) override { | 103 const EchoSharedQuadStateCallback& callback) override { |
| 97 callback.Run(s); | 104 callback.Run(s); |
| 98 } | 105 } |
| 99 | 106 |
| 100 void EchoSurfaceId(const SurfaceId& s, | 107 void EchoSurfaceId(const SurfaceId& s, |
| 101 const EchoSurfaceIdCallback& callback) override { | 108 const EchoSurfaceIdCallback& callback) override { |
| 102 callback.Run(s); | 109 callback.Run(s); |
| 103 } | 110 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 122 void EchoTransferableResource( | 129 void EchoTransferableResource( |
| 123 const TransferableResource& t, | 130 const TransferableResource& t, |
| 124 const EchoTransferableResourceCallback& callback) override { | 131 const EchoTransferableResourceCallback& callback) override { |
| 125 callback.Run(t); | 132 callback.Run(t); |
| 126 } | 133 } |
| 127 | 134 |
| 128 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 135 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
| 129 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); | 136 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); |
| 130 }; | 137 }; |
| 131 | 138 |
| 139 class TextureMailboxReleaserImpl : public mojom::TextureMailboxReleaser { |
| 140 public: |
| 141 TextureMailboxReleaserImpl(mojom::TextureMailboxReleaserRequest request, |
| 142 base::Closure quit_closure) |
| 143 : quit_closure_(quit_closure), binding_(this, std::move(request)) {} |
| 144 |
| 145 bool is_called() { return is_called_; } |
| 146 |
| 147 // mojom::TextureMailboxReleaser implementation: |
| 148 void Release(const gpu::SyncToken& sync_token, bool is_lost) override { |
| 149 is_called_ = true; |
| 150 quit_closure_.Run(); |
| 151 } |
| 152 |
| 153 private: |
| 154 bool is_called_ = false; |
| 155 base::Closure quit_closure_; |
| 156 mojo::Binding<mojom::TextureMailboxReleaser> binding_; |
| 157 }; |
| 158 |
| 132 void StubCopyOutputRequestCallback(std::unique_ptr<CopyOutputResult> result) {} | 159 void StubCopyOutputRequestCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 133 | 160 |
| 134 void StubCopyOutputResultCallback(const gpu::SyncToken& sync_token, | 161 void StubCopyOutputResultCallback(const gpu::SyncToken& sync_token, |
| 135 bool is_lost) {} | 162 bool is_lost) {} |
| 136 | 163 |
| 137 } // namespace | 164 } // namespace |
| 138 | 165 |
| 139 TEST_F(StructTraitsTest, BeginFrameArgs) { | 166 TEST_F(StructTraitsTest, BeginFrameArgs) { |
| 140 const base::TimeTicks frame_time = base::TimeTicks::Now(); | 167 const base::TimeTicks frame_time = base::TimeTicks::Now(); |
| 141 const base::TimeTicks deadline = base::TimeTicks::Now(); | 168 const base::TimeTicks deadline = base::TimeTicks::Now(); |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 input.is_empty_text_form_control = is_empty_text_form_control; | 881 input.is_empty_text_form_control = is_empty_text_form_control; |
| 855 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 882 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 856 Selection<gfx::SelectionBound> output; | 883 Selection<gfx::SelectionBound> output; |
| 857 proxy->EchoSelection(input, &output); | 884 proxy->EchoSelection(input, &output); |
| 858 EXPECT_EQ(start, output.start); | 885 EXPECT_EQ(start, output.start); |
| 859 EXPECT_EQ(end, output.end); | 886 EXPECT_EQ(end, output.end); |
| 860 EXPECT_EQ(is_editable, output.is_editable); | 887 EXPECT_EQ(is_editable, output.is_editable); |
| 861 EXPECT_EQ(is_empty_text_form_control, output.is_empty_text_form_control); | 888 EXPECT_EQ(is_empty_text_form_control, output.is_empty_text_form_control); |
| 862 } | 889 } |
| 863 | 890 |
| 891 TEST_F(StructTraitsTest, SingleReleaseCallback) { |
| 892 base::RunLoop run_loop; |
| 893 mojom::TextureMailboxReleaserPtr releaser; |
| 894 TextureMailboxReleaserImpl impl(MakeRequest(&releaser), |
| 895 run_loop.QuitClosure()); |
| 896 auto input = SingleReleaseCallback::Create(std::move(releaser)); |
| 897 |
| 898 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 899 std::unique_ptr<SingleReleaseCallback> output; |
| 900 proxy->EchoSingleReleaseCallback(std::move(input), &output); |
| 901 |
| 902 EXPECT_FALSE(impl.is_called()); |
| 903 output->Run(gpu::SyncToken(), true); |
| 904 run_loop.Run(); |
| 905 EXPECT_TRUE(impl.is_called()); |
| 906 } |
| 907 |
| 864 TEST_F(StructTraitsTest, SurfaceId) { | 908 TEST_F(StructTraitsTest, SurfaceId) { |
| 865 static constexpr FrameSinkId frame_sink_id(1337, 1234); | 909 static constexpr FrameSinkId frame_sink_id(1337, 1234); |
| 866 static LocalSurfaceId local_surface_id(0xfbadbeef, | 910 static LocalSurfaceId local_surface_id(0xfbadbeef, |
| 867 base::UnguessableToken::Create()); | 911 base::UnguessableToken::Create()); |
| 868 SurfaceId input(frame_sink_id, local_surface_id); | 912 SurfaceId input(frame_sink_id, local_surface_id); |
| 869 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 913 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 870 SurfaceId output; | 914 SurfaceId output; |
| 871 proxy->EchoSurfaceId(input, &output); | 915 proxy->EchoSurfaceId(input, &output); |
| 872 EXPECT_EQ(frame_sink_id, output.frame_sink_id()); | 916 EXPECT_EQ(frame_sink_id, output.frame_sink_id()); |
| 873 EXPECT_EQ(local_surface_id, output.local_surface_id()); | 917 EXPECT_EQ(local_surface_id, output.local_surface_id()); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 EXPECT_EQ(u_plane_resource_id, out_quad->u_plane_resource_id()); | 1126 EXPECT_EQ(u_plane_resource_id, out_quad->u_plane_resource_id()); |
| 1083 EXPECT_EQ(v_plane_resource_id, out_quad->v_plane_resource_id()); | 1127 EXPECT_EQ(v_plane_resource_id, out_quad->v_plane_resource_id()); |
| 1084 EXPECT_EQ(a_plane_resource_id, out_quad->a_plane_resource_id()); | 1128 EXPECT_EQ(a_plane_resource_id, out_quad->a_plane_resource_id()); |
| 1085 EXPECT_EQ(color_space, out_quad->color_space); | 1129 EXPECT_EQ(color_space, out_quad->color_space); |
| 1086 EXPECT_EQ(resource_offset, out_quad->resource_offset); | 1130 EXPECT_EQ(resource_offset, out_quad->resource_offset); |
| 1087 EXPECT_EQ(resource_multiplier, out_quad->resource_multiplier); | 1131 EXPECT_EQ(resource_multiplier, out_quad->resource_multiplier); |
| 1088 EXPECT_EQ(bits_per_channel, out_quad->bits_per_channel); | 1132 EXPECT_EQ(bits_per_channel, out_quad->bits_per_channel); |
| 1089 } | 1133 } |
| 1090 | 1134 |
| 1091 } // namespace cc | 1135 } // namespace cc |
| OLD | NEW |