| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/run_loop.h" |
| 7 #include "cc/ipc/traits_test_service.mojom.h" |
| 8 #include "cc/quads/render_pass_id.h" |
| 9 #include "mojo/public/cpp/bindings/binding_set.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 namespace { |
| 15 |
| 16 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
| 17 public: |
| 18 StructTraitsTest() {} |
| 19 |
| 20 protected: |
| 21 mojom::TraitsTestServicePtr GetTraitsTestProxy() { |
| 22 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
| 23 } |
| 24 |
| 25 private: |
| 26 // TraitsTestService: |
| 27 void EchoRenderPassId(const RenderPassId& r, |
| 28 const EchoRenderPassIdCallback& callback) override { |
| 29 callback.Run(r); |
| 30 } |
| 31 |
| 32 void EchoReturnedResource( |
| 33 const ReturnedResource& r, |
| 34 const EchoReturnedResourceCallback& callback) override { |
| 35 callback.Run(r); |
| 36 } |
| 37 |
| 38 void EchoSurfaceId(const SurfaceId& s, |
| 39 const EchoSurfaceIdCallback& callback) override { |
| 40 callback.Run(s); |
| 41 } |
| 42 |
| 43 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
| 44 }; |
| 45 |
| 46 } // namespace |
| 47 |
| 48 TEST_F(StructTraitsTest, RenderPassId) { |
| 49 const int layer_id = 1337; |
| 50 const uint32_t index = 0xdeadbeef; |
| 51 RenderPassId input(layer_id, index); |
| 52 base::RunLoop loop; |
| 53 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 54 proxy->EchoRenderPassId(input, [&](const RenderPassId& pass) { |
| 55 EXPECT_EQ(input.layer_id, pass.layer_id); |
| 56 EXPECT_EQ(input.index, pass.index); |
| 57 loop.Quit(); |
| 58 }); |
| 59 loop.Run(); |
| 60 } |
| 61 |
| 62 TEST_F(StructTraitsTest, ReturnedResource) { |
| 63 ReturnedResource input; |
| 64 input.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 input.sync_token = gpu::SyncToken(command_buffer_namespace, extra_data_field, |
| 71 command_buffer_id, release_count); |
| 72 input.count = 1234; |
| 73 input.lost = true; |
| 74 base::RunLoop loop; |
| 75 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 76 proxy->EchoReturnedResource(input, [&](const ReturnedResource& pass) { |
| 77 EXPECT_EQ(input.id, pass.id); |
| 78 EXPECT_EQ(input.sync_token, pass.sync_token); |
| 79 EXPECT_EQ(input.count, pass.count); |
| 80 EXPECT_EQ(input.lost, pass.lost); |
| 81 loop.Quit(); |
| 82 }); |
| 83 loop.Run(); |
| 84 } |
| 85 |
| 86 TEST_F(StructTraitsTest, SurfaceId) { |
| 87 const uint32_t id_namespace = 1337; |
| 88 const uint32_t local_id = 0xfbadbeef; |
| 89 const uint64_t nonce = 0xdeadbeef; |
| 90 SurfaceId input(id_namespace, local_id, nonce); |
| 91 base::RunLoop loop; |
| 92 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 93 proxy->EchoSurfaceId(input, [&](const SurfaceId& pass) { |
| 94 EXPECT_EQ(input.id_namespace(), pass.id_namespace()); |
| 95 EXPECT_EQ(input.local_id(), pass.local_id()); |
| 96 EXPECT_EQ(input.nonce(), pass.nonce()); |
| 97 loop.Quit(); |
| 98 }); |
| 99 loop.Run(); |
| 100 } |
| 101 |
| 102 } // namespace cc |
| OLD | NEW |