| Index: ui/ozone/common/mojo/ozone_gpu_struct_traits_unittest.cc
|
| diff --git a/ui/ozone/common/mojo/ozone_gpu_struct_traits_unittest.cc b/ui/ozone/common/mojo/ozone_gpu_struct_traits_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a9ebd958e9ecf071ef38a8fd1ac20150a605512e
|
| --- /dev/null
|
| +++ b/ui/ozone/common/mojo/ozone_gpu_struct_traits_unittest.cc
|
| @@ -0,0 +1,61 @@
|
| +// Copyright 2017 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/logging.h"
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
|
| +#include "ui/ozone/common/mojo/ozone_gpu_struct_traits_test.mojom.h"
|
| +
|
| +namespace ui {
|
| +
|
| +namespace {
|
| +
|
| +class OzoneGpuStructTraitsTestImpl : public mojom::OzoneGpuStructTraitsTest {
|
| + public:
|
| + explicit OzoneGpuStructTraitsTestImpl(
|
| + mojo::InterfaceRequest<mojom::OzoneGpuStructTraitsTest> request)
|
| + : binding_(this, std::move(request)) {}
|
| +
|
| + // OzoneGpuStructTraitsTest:
|
| + void EchoDisplayModeParams(
|
| + const DisplayMode_Params& input,
|
| + const EchoDisplayModeParamsCallback& callback) override {
|
| + callback.Run(input);
|
| + }
|
| +
|
| + private:
|
| + mojo::Binding<OzoneGpuStructTraitsTest> binding_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(OzoneGpuStructTraitsTestImpl);
|
| +};
|
| +
|
| +TEST(OzoneGpuStructTraitsTest, Basic) {
|
| + // A MessageLoop is needed for Mojo IPC to work.
|
| + base::MessageLoop message_loop;
|
| +
|
| + mojom::OzoneGpuStructTraitsTestPtr proxy;
|
| + OzoneGpuStructTraitsTestImpl impl(MakeRequest(&proxy));
|
| +
|
| + // prepare sample input with random values
|
| + DisplayMode_Params input;
|
| + input.size = gfx::Size(15, 29);
|
| + input.is_interlaced = true;
|
| + input.refresh_rate = 61;
|
| +
|
| + ui::DisplayMode_Params output;
|
| +
|
| + EXPECT_TRUE(proxy->EchoDisplayModeParams(input, &output));
|
| +
|
| + // We want to test each component individually to make sure each data member
|
| + // was correctly serialized and deserialized.
|
| + EXPECT_EQ(input.size, output.size);
|
| + EXPECT_EQ(input.is_interlaced, output.is_interlaced);
|
| + EXPECT_EQ(input.refresh_rate, output.refresh_rate);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +} // namespace ui
|
|
|