| Index: cc/ipc/struct_traits_unittest.cc
|
| diff --git a/cc/ipc/struct_traits_unittest.cc b/cc/ipc/struct_traits_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8243c4b1d3450d2ab6451a4537651356be586e82
|
| --- /dev/null
|
| +++ b/cc/ipc/struct_traits_unittest.cc
|
| @@ -0,0 +1,72 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "base/run_loop.h"
|
| +#include "cc/ipc/traits_test_service.mojom.h"
|
| +#include "cc/quads/render_pass_id.h"
|
| +#include "mojo/public/cpp/bindings/binding_set.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace cc {
|
| +
|
| +namespace {
|
| +
|
| +class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
|
| + public:
|
| + StructTraitsTest() {}
|
| +
|
| + protected:
|
| + mojom::TraitsTestServicePtr GetTraitsTestProxy() {
|
| + return traits_test_bindings_.CreateInterfacePtrAndBind(this);
|
| + }
|
| +
|
| + private:
|
| + // TraitsTestService:
|
| + void EchoRenderPassId(const RenderPassId& r,
|
| + const EchoRenderPassIdCallback& callback) override {
|
| + callback.Run(r);
|
| + }
|
| +
|
| + void EchoSurfaceId(const SurfaceId& s,
|
| + const EchoSurfaceIdCallback& callback) override {
|
| + callback.Run(s);
|
| + }
|
| +
|
| + mojo::BindingSet<TraitsTestService> traits_test_bindings_;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +TEST_F(StructTraitsTest, RenderPassId) {
|
| + const int layer_id = 1337;
|
| + const uint32_t index = 0xdeadbeef;
|
| + RenderPassId input(layer_id, index);
|
| + base::RunLoop loop;
|
| + mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
|
| + proxy->EchoRenderPassId(input, [&](const RenderPassId& pass) {
|
| + EXPECT_EQ(input.layer_id, pass.layer_id);
|
| + EXPECT_EQ(input.index, pass.index);
|
| + loop.Quit();
|
| + });
|
| + loop.Run();
|
| +}
|
| +
|
| +TEST_F(StructTraitsTest, SurfaceId) {
|
| + const uint32_t id_namespace = 1337;
|
| + const uint32_t local_id = 0xfbadbeef;
|
| + const uint64_t nonce = 0xdeadbeef;
|
| + SurfaceId input(id_namespace, local_id, nonce);
|
| + base::RunLoop loop;
|
| + mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
|
| + proxy->EchoSurfaceId(input, [&](const SurfaceId& pass) {
|
| + EXPECT_EQ(input.id_namespace(), pass.id_namespace());
|
| + EXPECT_EQ(input.local_id(), pass.local_id());
|
| + EXPECT_EQ(input.nonce(), pass.nonce());
|
| + loop.Quit();
|
| + });
|
| + loop.Run();
|
| +}
|
| +
|
| +} // namespace cc
|
|
|