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" |
(...skipping 11 matching lines...) Expand all Loading... |
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 EchoRenderPassId(const RenderPassId& r, | 27 void EchoRenderPassId(const RenderPassId& r, |
28 const EchoRenderPassIdCallback& callback) override { | 28 const EchoRenderPassIdCallback& callback) override { |
29 callback.Run(r); | 29 callback.Run(r); |
30 } | 30 } |
31 | 31 |
| 32 void EchoReturnedResource( |
| 33 const ReturnedResource& r, |
| 34 const EchoReturnedResourceCallback& callback) override { |
| 35 callback.Run(r); |
| 36 } |
| 37 |
32 void EchoSurfaceId(const SurfaceId& s, | 38 void EchoSurfaceId(const SurfaceId& s, |
33 const EchoSurfaceIdCallback& callback) override { | 39 const EchoSurfaceIdCallback& callback) override { |
34 callback.Run(s); | 40 callback.Run(s); |
35 } | 41 } |
36 | 42 |
37 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 43 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
38 }; | 44 }; |
39 | 45 |
40 } // namespace | 46 } // namespace |
41 | 47 |
42 TEST_F(StructTraitsTest, RenderPassId) { | 48 TEST_F(StructTraitsTest, RenderPassId) { |
43 const int layer_id = 1337; | 49 const int layer_id = 1337; |
44 const uint32_t index = 0xdeadbeef; | 50 const uint32_t index = 0xdeadbeef; |
45 RenderPassId input(layer_id, index); | 51 RenderPassId input(layer_id, index); |
46 base::RunLoop loop; | 52 base::RunLoop loop; |
47 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 53 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
48 proxy->EchoRenderPassId(input, | 54 proxy->EchoRenderPassId(input, |
49 [layer_id, index, &loop](const RenderPassId& pass) { | 55 [layer_id, index, &loop](const RenderPassId& pass) { |
50 EXPECT_EQ(layer_id, pass.layer_id); | 56 EXPECT_EQ(layer_id, pass.layer_id); |
51 EXPECT_EQ(index, pass.index); | 57 EXPECT_EQ(index, pass.index); |
52 loop.Quit(); | 58 loop.Quit(); |
53 }); | 59 }); |
54 loop.Run(); | 60 loop.Run(); |
55 } | 61 } |
56 | 62 |
| 63 TEST_F(StructTraitsTest, ReturnedResource) { |
| 64 const uint32_t id = 1337; |
| 65 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS; |
| 66 const int32_t extra_data_field = 0xbeefbeef; |
| 67 const gpu::CommandBufferId command_buffer_id( |
| 68 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef)); |
| 69 const uint64_t release_count = 0xdeadbeefdead; |
| 70 const gpu::SyncToken sync_token(command_buffer_namespace, extra_data_field, |
| 71 command_buffer_id, release_count); |
| 72 const int count = 1234; |
| 73 const bool lost = true; |
| 74 |
| 75 ReturnedResource input; |
| 76 input.id = id; |
| 77 input.sync_token = sync_token; |
| 78 input.count = count; |
| 79 input.lost = lost; |
| 80 base::RunLoop loop; |
| 81 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 82 proxy->EchoReturnedResource(input, [id, sync_token, count, lost, |
| 83 &loop](const ReturnedResource& pass) { |
| 84 EXPECT_EQ(id, pass.id); |
| 85 EXPECT_EQ(sync_token, pass.sync_token); |
| 86 EXPECT_EQ(count, pass.count); |
| 87 EXPECT_EQ(lost, pass.lost); |
| 88 loop.Quit(); |
| 89 }); |
| 90 loop.Run(); |
| 91 } |
| 92 |
57 TEST_F(StructTraitsTest, SurfaceId) { | 93 TEST_F(StructTraitsTest, SurfaceId) { |
58 const uint32_t id_namespace = 1337; | 94 const uint32_t id_namespace = 1337; |
59 const uint32_t local_id = 0xfbadbeef; | 95 const uint32_t local_id = 0xfbadbeef; |
60 const uint64_t nonce = 0xdeadbeef; | 96 const uint64_t nonce = 0xdeadbeef; |
61 SurfaceId input(id_namespace, local_id, nonce); | 97 SurfaceId input(id_namespace, local_id, nonce); |
62 base::RunLoop loop; | 98 base::RunLoop loop; |
63 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 99 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
64 proxy->EchoSurfaceId( | 100 proxy->EchoSurfaceId( |
65 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) { | 101 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) { |
66 EXPECT_EQ(id_namespace, pass.id_namespace()); | 102 EXPECT_EQ(id_namespace, pass.id_namespace()); |
67 EXPECT_EQ(local_id, pass.local_id()); | 103 EXPECT_EQ(local_id, pass.local_id()); |
68 EXPECT_EQ(nonce, pass.nonce()); | 104 EXPECT_EQ(nonce, pass.nonce()); |
69 loop.Quit(); | 105 loop.Quit(); |
70 }); | 106 }); |
71 loop.Run(); | 107 loop.Run(); |
72 } | 108 } |
73 | 109 |
74 } // namespace cc | 110 } // namespace cc |
OLD | NEW |