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 EchoSurfaceId(const SurfaceId& s, |
| 33 const EchoSurfaceIdCallback& callback) override { |
| 34 callback.Run(s); |
| 35 } |
| 36 |
| 37 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
| 38 }; |
| 39 |
| 40 } // namespace |
| 41 |
| 42 TEST_F(StructTraitsTest, RenderPassId) { |
| 43 const int layer_id = 1337; |
| 44 const uint32_t index = 0xdeadbeef; |
| 45 RenderPassId input(layer_id, index); |
| 46 base::RunLoop loop; |
| 47 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 48 proxy->EchoRenderPassId(input, |
| 49 [layer_id, index, &loop](const RenderPassId& pass) { |
| 50 EXPECT_EQ(layer_id, pass.layer_id); |
| 51 EXPECT_EQ(index, pass.index); |
| 52 loop.Quit(); |
| 53 }); |
| 54 loop.Run(); |
| 55 } |
| 56 |
| 57 TEST_F(StructTraitsTest, SurfaceId) { |
| 58 const uint32_t id_namespace = 1337; |
| 59 const uint32_t local_id = 0xfbadbeef; |
| 60 const uint64_t nonce = 0xdeadbeef; |
| 61 SurfaceId input(id_namespace, local_id, nonce); |
| 62 base::RunLoop loop; |
| 63 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 64 proxy->EchoSurfaceId( |
| 65 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) { |
| 66 EXPECT_EQ(id_namespace, pass.id_namespace()); |
| 67 EXPECT_EQ(local_id, pass.local_id()); |
| 68 EXPECT_EQ(nonce, pass.nonce()); |
| 69 loop.Quit(); |
| 70 }); |
| 71 loop.Run(); |
| 72 } |
| 73 |
| 74 } // namespace cc |
OLD | NEW |