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 "base/run_loop.h" |
7 #include "cc/ipc/traits_test_service.mojom.h" | 7 #include "cc/ipc/traits_test_service.mojom.h" |
8 #include "cc/quads/render_pass_id.h" | 8 #include "cc/quads/render_pass_id.h" |
9 #include "mojo/public/cpp/bindings/binding_set.h" | 9 #include "mojo/public/cpp/bindings/binding_set.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
17 public: | 17 public: |
18 StructTraitsTest() {} | 18 StructTraitsTest() {} |
19 | 19 |
20 protected: | 20 protected: |
21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { | 21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { |
22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | 22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
23 } | 23 } |
24 | 24 |
25 private: | 25 private: |
26 // TraitsTestService: | 26 // TraitsTestService: |
| 27 void EchoBeginFrameArgs(const BeginFrameArgs& b, |
| 28 const EchoBeginFrameArgsCallback& callback) override { |
| 29 callback.Run(b); |
| 30 } |
| 31 |
27 void EchoRenderPassId(const RenderPassId& r, | 32 void EchoRenderPassId(const RenderPassId& r, |
28 const EchoRenderPassIdCallback& callback) override { | 33 const EchoRenderPassIdCallback& callback) override { |
29 callback.Run(r); | 34 callback.Run(r); |
30 } | 35 } |
31 | 36 |
32 void EchoReturnedResource( | 37 void EchoReturnedResource( |
33 const ReturnedResource& r, | 38 const ReturnedResource& r, |
34 const EchoReturnedResourceCallback& callback) override { | 39 const EchoReturnedResourceCallback& callback) override { |
35 callback.Run(r); | 40 callback.Run(r); |
36 } | 41 } |
37 | 42 |
38 void EchoSurfaceId(const SurfaceId& s, | 43 void EchoSurfaceId(const SurfaceId& s, |
39 const EchoSurfaceIdCallback& callback) override { | 44 const EchoSurfaceIdCallback& callback) override { |
40 callback.Run(s); | 45 callback.Run(s); |
41 } | 46 } |
42 | 47 |
43 void EchoTransferableResource( | 48 void EchoTransferableResource( |
44 const TransferableResource& t, | 49 const TransferableResource& t, |
45 const EchoTransferableResourceCallback& callback) override { | 50 const EchoTransferableResourceCallback& callback) override { |
46 callback.Run(t); | 51 callback.Run(t); |
47 } | 52 } |
48 | 53 |
49 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 54 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
50 }; | 55 }; |
51 | 56 |
52 } // namespace | 57 } // namespace |
53 | 58 |
| 59 TEST_F(StructTraitsTest, BeginFrameArgs) { |
| 60 const base::TimeTicks frame_time = base::TimeTicks::Now(); |
| 61 const base::TimeTicks deadline = base::TimeTicks::Now(); |
| 62 const base::TimeDelta interval = base::TimeDelta::FromMilliseconds(1337); |
| 63 const BeginFrameArgs::BeginFrameArgsType type = BeginFrameArgs::NORMAL; |
| 64 const bool on_critical_path = true; |
| 65 BeginFrameArgs input; |
| 66 input.frame_time = frame_time; |
| 67 input.deadline = deadline; |
| 68 input.interval = interval; |
| 69 input.type = type; |
| 70 input.on_critical_path = on_critical_path; |
| 71 base::RunLoop loop; |
| 72 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 73 proxy->EchoBeginFrameArgs( |
| 74 input, [frame_time, deadline, interval, type, on_critical_path, |
| 75 &loop](const BeginFrameArgs& pass) { |
| 76 EXPECT_EQ(frame_time, pass.frame_time); |
| 77 EXPECT_EQ(deadline, pass.deadline); |
| 78 EXPECT_EQ(interval, pass.interval); |
| 79 EXPECT_EQ(type, pass.type); |
| 80 EXPECT_EQ(on_critical_path, pass.on_critical_path); |
| 81 loop.Quit(); |
| 82 }); |
| 83 loop.Run(); |
| 84 } |
| 85 |
54 TEST_F(StructTraitsTest, RenderPassId) { | 86 TEST_F(StructTraitsTest, RenderPassId) { |
55 const int layer_id = 1337; | 87 const int layer_id = 1337; |
56 const uint32_t index = 0xdeadbeef; | 88 const uint32_t index = 0xdeadbeef; |
57 RenderPassId input(layer_id, index); | 89 RenderPassId input(layer_id, index); |
58 base::RunLoop loop; | 90 base::RunLoop loop; |
59 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 91 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
60 proxy->EchoRenderPassId(input, | 92 proxy->EchoRenderPassId(input, |
61 [layer_id, index, &loop](const RenderPassId& pass) { | 93 [layer_id, index, &loop](const RenderPassId& pass) { |
62 EXPECT_EQ(layer_id, pass.layer_id); | 94 EXPECT_EQ(layer_id, pass.layer_id); |
63 EXPECT_EQ(index, pass.index); | 95 EXPECT_EQ(index, pass.index); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 EXPECT_EQ(read_lock_fences_enabled, pass.read_lock_fences_enabled); | 198 EXPECT_EQ(read_lock_fences_enabled, pass.read_lock_fences_enabled); |
167 EXPECT_EQ(is_software, pass.is_software); | 199 EXPECT_EQ(is_software, pass.is_software); |
168 EXPECT_EQ(gpu_memory_buffer_id, pass.gpu_memory_buffer_id.id); | 200 EXPECT_EQ(gpu_memory_buffer_id, pass.gpu_memory_buffer_id.id); |
169 EXPECT_EQ(is_overlay_candidate, pass.is_overlay_candidate); | 201 EXPECT_EQ(is_overlay_candidate, pass.is_overlay_candidate); |
170 loop.Quit(); | 202 loop.Quit(); |
171 }); | 203 }); |
172 loop.Run(); | 204 loop.Run(); |
173 } | 205 } |
174 | 206 |
175 } // namespace cc | 207 } // namespace cc |
OLD | NEW |